Exemple #1
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();
        }
Exemple #2
0
        private void breadthFirstSearchItem_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.edgeColors = new EdgeColorDictionary();
            foreach (IEdge edge in this.netronPanel.Graph.Edges)
            {
                this.edgeColors[edge] = GraphColor.White;
            }
            this.vertexColors = new VertexColorDictionary();
            BreadthFirstSearchAlgorithm bfs = new BreadthFirstSearchAlgorithm(
                this.netronPanel.Graph,
                new VertexBuffer(),
                this.vertexColors);

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

            // link to algo
            bfs.RegisterTreeEdgeBuilderHandlers(tracer);
            bfs.RegisterVertexColorizerHandlers(tracer);

            bfs.TreeEdge    += new EdgeEventHandler(dfs_TreeEdge);
            bfs.NonTreeEdge += new EdgeEventHandler(dfs_BackEdge);
            bfs.BlackTarget += new EdgeEventHandler(dfs_ForwardOrCrossEdge);


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

            // running algorithm
            VertexMethodCaller vm =
                new VertexMethodCaller(
                    new ComputeVertexDelegate(bfs.Compute),
                    Traversal.FirstVertex(this.netronPanel.Graph)
                    );
            Thread thread = new Thread(new ThreadStart(vm.Run));

            thread.Start();
        }
Exemple #3
0
        private void menuItem8_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.vertexCounts = new VertexIntDictionary();
            this.edgeCounts   = new EdgeIntDictionary();
            foreach (IVertex vertex in this.netronPanel.Graph.Vertices)
            {
                this.vertexCounts[vertex] = 0;
            }
            foreach (IEdge edge in this.netronPanel.Graph.Edges)
            {
                this.edgeCounts[edge] = 0;
            }

            this.edgeWeights = new EdgeDoubleDictionary();
            foreach (IEdge edge in this.netronPanel.Graph.Edges)
            {
                edgeWeights[edge] = 1;
            }
            WeightedMarkovEdgeChain chain  = new WeightedMarkovEdgeChain(edgeWeights);
            RandomWalkAlgorithm     walker = new RandomWalkAlgorithm(
                this.netronPanel.Graph
                );

            walker.TreeEdge += new EdgeEventHandler(walker_WeightedTreeEdge);

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

            walker.TreeEdge += new EdgeEventHandler(tracer.TreeEdge);


            Thread thread = new Thread(new ThreadStart(walker.Generate));

            thread.Start();
        }
Exemple #4
0
        private void depthFirstSearchAlgorithmItem_Click(object sender, System.EventArgs e)
        {
            if (this.netronPanel.Graph == null)
            {
                throw new Exception("Generate a graph first");
            }

            // clear colors
            ResetVertexAndEdgeColors();

            // create algorithm
            this.edgeColors = new EdgeColorDictionary();
            foreach (IEdge edge in this.netronPanel.Graph.Edges)
            {
                this.edgeColors[edge] = GraphColor.White;
            }

            this.vertexColors = new VertexColorDictionary();
            DepthFirstSearchAlgorithm dfs = new DepthFirstSearchAlgorithm(
                this.netronPanel.Graph,
                this.vertexColors);

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

            // link to algo
            dfs.RegisterTreeEdgeBuilderHandlers(tracer);
            dfs.RegisterVertexColorizerHandlers(tracer);

            dfs.TreeEdge           += new EdgeEventHandler(dfs_TreeEdge);
            dfs.BackEdge           += new EdgeEventHandler(dfs_BackEdge);
            dfs.ForwardOrCrossEdge += new EdgeEventHandler(dfs_ForwardOrCrossEdge);

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

            // running algorithm
            Thread thread = new Thread(new ThreadStart(dfs.Compute));

            thread.Start();
        }
        private void menuItem8_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.vertexCounts = new VertexIntDictionary();
            this.edgeCounts = new EdgeIntDictionary();
            foreach(IVertex vertex in this.netronPanel.Graph.Vertices)
                this.vertexCounts[vertex]=0;
            foreach(IEdge edge in this.netronPanel.Graph.Edges)
                this.edgeCounts[edge]=0;

            this.edgeWeights =new EdgeDoubleDictionary();
            foreach(IEdge edge in this.netronPanel.Graph.Edges)
                edgeWeights[edge]=1;
            WeightedMarkovEdgeChain chain = new WeightedMarkovEdgeChain(edgeWeights);
            RandomWalkAlgorithm walker = new RandomWalkAlgorithm(
                this.netronPanel.Graph
                );

            walker.TreeEdge+=new EdgeEventHandler(walker_WeightedTreeEdge);

            LayoutAlgorithmTraverVisitor tracer = new LayoutAlgorithmTraverVisitor(this.netronPanel.Populator);
            walker.TreeEdge +=new EdgeEventHandler(tracer.TreeEdge);

            Thread thread = new Thread(new ThreadStart(walker.Generate));
            thread.Start();
        }
        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();
        }
        private void depthFirstSearchAlgorithmItem_Click(object sender, System.EventArgs e)
        {
            if (this.netronPanel.Graph==null)
                throw new Exception("Generate a graph first");

            // clear colors
            ResetVertexAndEdgeColors();

            // create algorithm
            this.edgeColors=new EdgeColorDictionary();
            foreach(IEdge edge in this.netronPanel.Graph.Edges)
                this.edgeColors[edge]=GraphColor.White;

            this.vertexColors = new VertexColorDictionary();
            DepthFirstSearchAlgorithm dfs = new DepthFirstSearchAlgorithm(
                this.netronPanel.Graph,
                this.vertexColors);

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

            // link to algo
            dfs.RegisterTreeEdgeBuilderHandlers(tracer);
            dfs.RegisterVertexColorizerHandlers(tracer);

            dfs.TreeEdge +=new EdgeEventHandler(dfs_TreeEdge);
            dfs.BackEdge +=new EdgeEventHandler(dfs_BackEdge);
            dfs.ForwardOrCrossEdge +=new EdgeEventHandler(dfs_ForwardOrCrossEdge);

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

            // running algorithm
            Thread thread = new Thread(new ThreadStart(dfs.Compute));
            thread.Start();
        }
        private void breadthFirstSearchItem_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.edgeColors=new EdgeColorDictionary();
            foreach(IEdge edge in this.netronPanel.Graph.Edges)
                this.edgeColors[edge]=GraphColor.White;
            this.vertexColors = new VertexColorDictionary();
            BreadthFirstSearchAlgorithm bfs = new BreadthFirstSearchAlgorithm(
                this.netronPanel.Graph,
                new VertexBuffer(),
                this.vertexColors);

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

            // link to algo
            bfs.RegisterTreeEdgeBuilderHandlers(tracer);
            bfs.RegisterVertexColorizerHandlers(tracer);

            bfs.TreeEdge +=new EdgeEventHandler(dfs_TreeEdge);
            bfs.NonTreeEdge+=new EdgeEventHandler(dfs_BackEdge);
            bfs.BlackTarget +=new EdgeEventHandler(dfs_ForwardOrCrossEdge);

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

            // running algorithm
            VertexMethodCaller vm=
                new VertexMethodCaller(
                    new ComputeVertexDelegate(bfs.Compute),
                    Traversal.FirstVertex(this.netronPanel.Graph)
                    );
            Thread thread = new Thread(new ThreadStart(vm.Run));
            thread.Start();
        }