public void Test(IVertexAndEdgeListGraph g, IVertex root)
        {
            this.root = root;

            RandomWalkAlgorithm walker = new RandomWalkAlgorithm(g);
            walker.TreeEdge +=new EdgeEventHandler(walker_TreeEdge);
            walker.Generate(root,50);

            BidirectionalAdaptorGraph bg = new BidirectionalAdaptorGraph(g);
            ReversedBidirectionalGraph rg = new ReversedBidirectionalGraph(bg);
            CyclePoppingRandomTreeAlgorithm pop = new CyclePoppingRandomTreeAlgorithm(rg);

            pop.InitializeVertex +=new VertexEventHandler(this.InitializeVertex);
            pop.FinishVertex +=new VertexEventHandler(this.FinishVertex);
            pop.TreeEdge += new EdgeEventHandler(this.TreeEdge);

            pop.InitializeVertex +=new VertexEventHandler(vis.InitializeVertex);
            pop.TreeEdge += new EdgeEventHandler(vis.TreeEdge);
            pop.ClearTreeVertex += new VertexEventHandler(vis.ClearTreeVertex);

            pop.RandomTreeWithRoot(root);

            // plot tree...
            GraphvizAlgorithm gv = new GraphvizAlgorithm(g,".",GraphvizImageType.Svg);
            gv.FormatEdge +=new FormatEdgeEventHandler(this.FormatEdge);
            gv.FormatVertex +=new FormatVertexEventHandler(this.FormatVertex);

            gv.Write("randomtree");
        }
        public void Generate(
            [UsingFactories(typeof(EdgeChainFactory))] 
            KeyValuePair<IVertexAndEdgeListGraph<string,Edge<string>>,IEdgeChain<string,Edge<String>>> eg
            )
        {
            RandomWalkAlgorithm<string, Edge<string>> walker =
                new RandomWalkAlgorithm<string, Edge<string>>(eg.Key, eg.Value);

            walker.Generate(TraversalHelper.GetFirstVertex(eg.Key));
        }
        public void RoundRobinTest(IVertexListGraph<string, Edge<string>> g)
        {
            if (g.VertexCount == 0)
                return;

            RandomWalkAlgorithm<String, Edge<string>> walker =
                new RandomWalkAlgorithm<String, Edge<string>>(g);
            walker.EdgeChain = new NormalizedMarkovEdgeChain<string, Edge<string>>();

            string root = TraversalHelper.GetFirstVertex(g);
            walker.Generate(root);
        }
        public void GenerateWithVisitor(
            [UsingFactories(typeof(EdgeChainFactory))] 
            KeyValuePair<IVertexAndEdgeListGraph<string,Edge<string>>,IEdgeChain<string,Edge<String>>> eg
            )
        {
            RandomWalkAlgorithm<string, Edge<string>> walker =
                new RandomWalkAlgorithm<string, Edge<string>>(eg.Key, eg.Value);

            EdgeRecorderObserver<string, Edge<string>> vis = new EdgeRecorderObserver<string, Edge<string>>();
            vis.Attach(walker);
            walker.Generate(TraversalHelper.GetFirstVertex(eg.Key));
            vis.Detach(walker);
        }
Esempio n. 5
0
        public void GenerateWithVisitor(
            [UsingFactories(typeof(EdgeChainFactory))]
            KeyValuePair <IVertexAndEdgeListGraph <string, Edge <string> >, IEdgeChain <string, Edge <String> > > eg
            )
        {
            RandomWalkAlgorithm <string, Edge <string> > walker =
                new RandomWalkAlgorithm <string, Edge <string> >(eg.Key, eg.Value);

            EdgeRecorderObserver <string, Edge <string> > vis = new EdgeRecorderObserver <string, Edge <string> >();

            vis.Attach(walker);
            walker.Generate(TraversalHelper.GetFirstVertex(eg.Key));
            vis.Detach(walker);
        }
        public void RoundRobinTest <TVertex, TEdge>(IVertexListGraph <TVertex, TEdge> g)
            where TEdge : IEdge <TVertex>
        {
            if (g.VertexCount == 0)
            {
                return;
            }

            foreach (var root in g.Vertices)
            {
                var walker =
                    new RandomWalkAlgorithm <TVertex, TEdge>(g);
                walker.EdgeChain = new NormalizedMarkovEdgeChain <TVertex, TEdge>();
                walker.Generate(root);
            }
        }
        public void RoundRobinTestWithVisitor(IVertexListGraph<string, Edge<string>> g)
        {
            if (g.VertexCount == 0)
                return;

            RandomWalkAlgorithm<String, Edge<string>> walker =
                new RandomWalkAlgorithm<String, Edge<string>>(g);
            walker.EdgeChain = new NormalizedMarkovEdgeChain<string, Edge<string>>();

            string root = TraversalHelper.GetFirstVertex(g);

            EdgeRecorderObserver<string, Edge<string>> vis = new EdgeRecorderObserver<string, Edge<string>>();
            vis.Attach(walker);
            walker.Generate(root);
            vis.Detach(walker);
        }
Esempio n. 8
0
        public void RoundRobinTest(IVertexListGraph <string, Edge <string> > g)
        {
            if (g.VertexCount == 0)
            {
                return;
            }

            RandomWalkAlgorithm <String, Edge <string> > walker =
                new RandomWalkAlgorithm <String, Edge <string> >(g);

            walker.EdgeChain = new NormalizedMarkovEdgeChain <string, Edge <string> >();

            string root = TraversalHelper.GetFirstVertex(g);

            walker.Generate(root);
        }
        public void RoundRobinTestWithVisitor <TVertex, TEdge>(IVertexListGraph <TVertex, TEdge> g)
            where TEdge : IEdge <TVertex>
        {
            if (g.VertexCount == 0)
            {
                return;
            }

            foreach (var root in g.Vertices)
            {
                var walker =
                    new RandomWalkAlgorithm <TVertex, TEdge>(g);
                walker.EdgeChain = new NormalizedMarkovEdgeChain <TVertex, TEdge>();

                var vis = new EdgeRecorderObserver <TVertex, TEdge>();
                using (vis.Attach(walker))
                    walker.Generate(root);
            }
        }
Esempio n. 10
0
        public void RoundRobinTestWithVisitor(IVertexListGraph <string, Edge <string> > g)
        {
            if (g.VertexCount == 0)
            {
                return;
            }

            RandomWalkAlgorithm <String, Edge <string> > walker =
                new RandomWalkAlgorithm <String, Edge <string> >(g);

            walker.EdgeChain = new NormalizedMarkovEdgeChain <string, Edge <string> >();

            string root = TraversalHelper.GetFirstVertex(g);

            EdgeRecorderObserver <string, Edge <string> > vis = new EdgeRecorderObserver <string, Edge <string> >();

            vis.Attach(walker);
            walker.Generate(root);
            vis.Detach(walker);
        }