상속: RootedAlgorithmBase, IEdgeColorizerAlgorithm, IEdgePredecessorRecorderAlgorithm, ITreeBuilderAlgorithm
        public override Problem[] Check(Method method)
        {
            this.populator.BuildGraphFromMethod(method);

            EdgeDepthFirstSearchAlgorithm edfs = new EdgeDepthFirstSearchAlgorithm(this.populator.Graph);
            NullStateVisitor vis = new NullStateVisitor(this.populator.Graph);
            edfs.RegisterEdgeColorizerHandlers(vis);

            vis.Log.WriteLine("-- Fault detection for {0}.{1}",
                method.DeclaringType.ToString(),
                method.Name
                );

            int index=0;
            ArrayList problems = new ArrayList();
            for(index=0;index<method.Parameters.Length;++index)
            {
                Parameter param = method.Parameters[index];
                vis.Clear();
                vis.Log.WriteLine("-- {0} parameter",param.Name);
                vis.ParameterIndex=index;
                edfs.Initialize();
                edfs.Compute( this.populator.Graph.Root );

                if (vis.Warnings.Count>0 || vis.Errors.Count > 0)
                {
                    this.Problems.Add(
                        this.GetResolution(method.Name.Name,param.Name.Name)
                        );
                }
            }

            Problem[] ps=new Problem[problems.Count];
            problems.CopyTo(ps,0);

            return ps;
        }
예제 #2
0
        private void edgeDepthFirstSearchItem_Click(object sender, System.EventArgs e)
        {
            if (this.netronPanel.Graph==null)
                throw new Exception("Generate a graph first");
            if (this.netronPanel.Populator==null)
                throw new Exception("Populator should not be null.");

            ResetVertexAndEdgeColors();

            // create algorithm
            this.vertexColors=null;
            this.edgeColors = new EdgeColorDictionary();
            EdgeDepthFirstSearchAlgorithm edfs =
                new EdgeDepthFirstSearchAlgorithm(this.netronPanel.Graph,this.edgeColors);

            // create tracer
            LayoutAlgorithmTraverVisitor tracer = new LayoutAlgorithmTraverVisitor(this.netronPanel.Populator);

            // link to algo
            edfs.RegisterTreeEdgeBuilderHandlers(tracer);
            edfs.RegisterEdgeColorizerHandlers(tracer);

            // add handler to tracers
            tracer.UpdateVertex +=new ShapeVertexEventHandler(tracer_UpdateVertex);
            tracer.UpdateEdge +=new ConnectionEdgeEventHandler(tracer_UpdateEdge);

            // running algorithm
            Thread thread = new Thread(new ThreadStart(edfs.Compute));
            thread.Start();
        }
예제 #3
0
        /// <summary>
        /// Records all the edges that are part of the subtree of v
        /// </summary>
        /// <param name="g">visited graph</param>
        /// <param name="e">root edge</param>
        /// <param name="maxDepth">maximum expolration depth</param>
        /// <returns></returns>
        public static EdgeCollection OutEdgeTree(
            IEdgeListAndIncidenceGraph g,
            IEdge e,
            int maxDepth
            )
        {
            if (g==null)
                throw new ArgumentNullException("g");
            if (e==null)
                throw new ArgumentNullException("e");

            EdgeDepthFirstSearchAlgorithm dfs = new EdgeDepthFirstSearchAlgorithm(g);
            dfs.BackEdge +=new EdgeEventHandler(dfs_BackEdge);
            EdgeRecorderVisitor vis =new EdgeRecorderVisitor();
            vis.Edges.Add(e);

            dfs.DiscoverTreeEdge +=new EdgeEdgeEventHandler(vis.RecordTarget);

            dfs.MaxDepth = maxDepth;
            dfs.Initialize();
            dfs.Visit(e,0);

            return vis.Edges;
        }
예제 #4
0
        /// <summary>
        /// Creates a new edge dfs algorithm
        /// </summary>
        /// <param name="g"></param>
        /// <returns></returns>
        public EdgeDepthFirstSearchAlgorithm CreateEdgeDfs(IEdgeListAndIncidenceGraph g)
        {
            EdgeDepthFirstSearchAlgorithm edfs = new EdgeDepthFirstSearchAlgorithm(
                g
                );
            edfs.TreeEdge += new EdgeEventHandler(this.TreeEdge);
            edfs.FinishEdge += new EdgeEventHandler(this.FinishEdge);

            return edfs;
        }
예제 #5
0
        /// <summary>
        /// Adds an algorithm tracer to the edge dfs algorithm
        /// </summary>
        /// <param name="edfs"></param>
        /// <param name="path"></param>
        /// <returns>tracer</returns>
        public AlgorithmTracerVisitor AddTracer(EdgeDepthFirstSearchAlgorithm edfs, string path)
        {
            // The visitor that draws the graph at each iteration
            AlgorithmTracerVisitor vis = new AlgorithmTracerVisitor(
                (IVertexAndEdgeListGraph)edfs.VisitedGraph,
                "tr",
                path,
                GraphvizImageType.Png);

            // setting some vertex,edge style options
            vis.Algo.VertexFormat.Style = GraphvizVertexStyle.Filled;
            vis.Algo.VertexFormat.FillColor = Color.LightSkyBlue;

            vis.Algo.FormatVertex += new FormatVertexEventHandler(this.FormatVertex);
            vis.Algo.FormatEdge += new FormatEdgeEventHandler(this.FormatEdge);
            edfs.RegisterTreeEdgeBuilderHandlers(vis);
            edfs.FinishEdge += new EdgeEventHandler(vis.FinishEdge);

            return vis;
        }
예제 #6
0
        /// <summary>
        /// Add a predecessor recorder to the edge dfs algorithm.
        /// </summary>
        /// <param name="edfs"></param>
        /// <returns>predecessor recorder</returns>
        public EdgePredecessorRecorderVisitor AddPredecessorRecorder(EdgeDepthFirstSearchAlgorithm edfs)
        {
            // The visitor that will record actions path for us
            EdgePredecessorRecorderVisitor erec = new EdgePredecessorRecorderVisitor();
            edfs.DiscoverTreeEdge += new EdgeEdgeEventHandler(erec.DiscoverTreeEdge);
            edfs.FinishEdge += new EdgeEventHandler(erec.FinishEdge);

            return erec;
        }