コード例 #1
0
        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 Repro13160()
        {
            // create a new graph			
            var graph = new BidirectionalGraph<int, SEquatableEdge<int>>(false);

            // adding vertices		    
            for (int i = 0; i < 3; ++i)
                for(int j = 0;j<3;++j)
                    graph.AddVertex(i * 3 + j);

            // adding Width edges			    
            for (int i = 0; i < 3; ++i)
                for(int j = 0; j < 2;++j)
                graph.AddEdge(new SEquatableEdge<int>(i * 3 +j, i * 3 + j + 1));

            // adding Length edges			    
            for (int i = 0; i < 2; ++i)
                for(int j = 0; j < 3;++j)
                graph.AddEdge(new SEquatableEdge<int>(i * 3 + j, (i+1) * 3 + j));

            // create cross edges 
            foreach (var e in graph.Edges)
                graph.AddEdge(new SEquatableEdge<int>(e.Target, e.Source));

            // breaking graph apart
            for (int i = 0; i < 3; ++i)
                for (int j = 0; j < 3; ++j)
                    if (i == 1)
                        graph.RemoveVertex(i * 3 + j);

            var target = new CyclePoppingRandomTreeAlgorithm<int, SEquatableEdge<int>>(graph);
            target.Compute(2);
            foreach(var kv in target.Successors)
                Console.WriteLine("{0}: {1}", kv.Key, kv.Value);
        }
コード例 #3
0
        public void IsolatedVertex()
        {
            AdjacencyGraph g = new AdjacencyGraph();
            g.AddVertex();

            target = new CyclePoppingRandomTreeAlgorithm(g);
            target.RandomTree();
        }
        public void IsolatedVertex()
        {
            AdjacencyGraph<int, Edge<int>> g = new AdjacencyGraph<int, Edge<int>>(true);
            g.AddVertex(0);

            target = new CyclePoppingRandomTreeAlgorithm<int, Edge<int>>(g);
            target.RandomTree();
        }
コード例 #5
0
 public void CyclePoppingRandomTreeAll(AdjacencyGraph <string, Edge <string> > g)
 {
     foreach (var v in g.Vertices)
     {
         var target = new CyclePoppingRandomTreeAlgorithm <string, Edge <string> >(g);
         target.Compute(v);
     }
 }
コード例 #6
0
        public void Repro13160()
        {
            // create a new graph
            var graph = new BidirectionalGraph <int, SEquatableEdge <int> >(false);

            // adding vertices
            for (int i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    graph.AddVertex(i * 3 + j);
                }
            }

            // adding Width edges
            for (int i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 2; ++j)
                {
                    graph.AddEdge(new SEquatableEdge <int>(i * 3 + j, i * 3 + j + 1));
                }
            }

            // adding Length edges
            for (int i = 0; i < 2; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    graph.AddEdge(new SEquatableEdge <int>(i * 3 + j, (i + 1) * 3 + j));
                }
            }

            // create cross edges
            foreach (var e in graph.Edges)
            {
                graph.AddEdge(new SEquatableEdge <int>(e.Target, e.Source));
            }

            // breaking graph apart
            for (int i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    if (i == 1)
                    {
                        graph.RemoveVertex(i * 3 + j);
                    }
                }
            }

            var target = new CyclePoppingRandomTreeAlgorithm <int, SEquatableEdge <int> >(graph);

            target.Compute(2);
            foreach (var kv in target.Successors)
            {
                Console.WriteLine("{0}: {1}", kv.Key, kv.Value);
            }
        }
        public void IsolatedVerticesWithRoot()
        {
            var g = new AdjacencyGraph<int, Edge<int>>(true);
            g.AddVertex(0);
            g.AddVertex(1);

            var target = new CyclePoppingRandomTreeAlgorithm<int, Edge<int>>(g);
            target.RandomTreeWithRoot(0);
        }
コード例 #8
0
        public void IsolatedVertex()
        {
            AdjacencyGraph <int, Edge <int> > g = new AdjacencyGraph <int, Edge <int> >(true);

            g.AddVertex(0);

            target = new CyclePoppingRandomTreeAlgorithm <int, Edge <int> >(g);
            target.RandomTree();
        }
コード例 #9
0
        public void RootIsNotAccessible()
        {
            AdjacencyGraph g = new AdjacencyGraph();
            IVertex root = g.AddVertex();
            IVertex v = g.AddVertex();
            g.AddEdge(root, v);

            target = new CyclePoppingRandomTreeAlgorithm(g);
            target.RandomTreeWithRoot(root);
        }
        public void RootIsNotAccessible()
        {
            AdjacencyGraph<int, Edge<int>> g = new AdjacencyGraph<int, Edge<int>>(true);
            g.AddVertex(0);
            g.AddVertex(1);
            g.AddEdge(new Edge<int>(0, 1));

            target = new CyclePoppingRandomTreeAlgorithm<int, Edge<int>>(g);
            target.RandomTreeWithRoot(0);
        }
コード例 #11
0
        public void RootIsNotAccessible()
        {
            AdjacencyGraph <int, Edge <int> > g = new AdjacencyGraph <int, Edge <int> >(true);

            g.AddVertex(0);
            g.AddVertex(1);
            g.AddEdge(new Edge <int>(0, 1));

            target = new CyclePoppingRandomTreeAlgorithm <int, Edge <int> >(g);
            target.RandomTreeWithRoot(0);
        }
コード例 #12
0
 public void CyclePoppingRandomTreeAll()
 {
     foreach (var g in TestGraphFactory.GetAdjacencyGraphs())
     {
         foreach (var v in g.Vertices)
         {
             var target = new CyclePoppingRandomTreeAlgorithm<string, Edge<string>>(g);
             target.Compute(v);
         }
     }
 }
コード例 #13
0
        public void IsolatedVerticesWithRoot()
        {
            var g = new AdjacencyGraph <int, Edge <int> >(true);

            g.AddVertex(0);
            g.AddVertex(1);

            var target = new CyclePoppingRandomTreeAlgorithm <int, Edge <int> >(g);

            target.RandomTreeWithRoot(0);
        }
コード例 #14
0
 public void CyclePoppingRandomTreeAll()
 {
     foreach (var g in TestGraphFactory.GetAdjacencyGraphs())
     {
         foreach (var v in g.Vertices)
         {
             var target = new CyclePoppingRandomTreeAlgorithm <string, Edge <string> >(g);
             target.Compute(v);
         }
     }
 }
コード例 #15
0
 public void Loop()
 {
     target = new CyclePoppingRandomTreeAlgorithm(GraphFactory.Loop());
     target.RandomTree();
 }
コード例 #16
0
        public void Loop()
        {
            CyclePoppingRandomTreeAlgorithm <string, Edge <string> > target = new CyclePoppingRandomTreeAlgorithm <string, Edge <string> >(new AdjacencyGraphFactory().Loop());

            target.RandomTree();
        }
コード例 #17
0
        public void GenerateWalls(int outi, int outj, int ini, int inj)
        {
            // here we use a uniform probability distribution among the out-edges
            CyclePoppingRandomTreeAlgorithm pop =
                new CyclePoppingRandomTreeAlgorithm(this.graph);

            // we can also weight the out-edges
            /*
            EdgeDoubleDictionary weights = new EdgeDoubleDictionary();
            foreach(IEdge e in this.graph.Edges)
                weights[e]=1;
            pop.EdgeChain = new WeightedMarkovEdgeChain(weights);
            */
            IVertex root = this.latice[outi,outj];
            if (root==null)
                throw new ArgumentException("outi,outj vertex not found");

            pop.RandomTreeWithRoot(this.latice[outi,outj]);
            this.successors = pop.Successors;

            // build the path to ini, inj
            IVertex v = this.latice[ini,inj];
            if (v==null)
                throw new ArgumentException("ini,inj vertex not found");
            this.outPath = new EdgeCollection();
            while (v!=root)
            {
                IEdge e = this.successors[v];
                if (e==null)
                    throw new Exception();
                this.outPath.Add(e);
                v = e.Target;
            }
        }
 public void Loop()
 {
     CyclePoppingRandomTreeAlgorithm<string, Edge<string>>  target = new CyclePoppingRandomTreeAlgorithm<string, Edge<string>>(new AdjacencyGraphFactory().Loop());
     target.RandomTree();
 }