Example #1
0
        public List <RoadNetwork> BuildNetworks()
        {
            var networks = new List <RoadNetwork>();

            // Create one network for each connected set of segments of a specific type.
            var edgesToProcess = new List <RoadTopologyEdge>(Edges);

            while (edgesToProcess.Count > 0)
            {
                var edge = edgesToProcess[edgesToProcess.Count - 1];
                edgesToProcess.RemoveAt(edgesToProcess.Count - 1);

                var seenEdges = new List <RoadTopologyEdge>();
                seenEdges.Add(edge);

                var network = new RoadNetwork(edge.Template);
                networks.Add(network);

                network.AddEdge(edge);

                void FollowPath(RoadTopologyNode node)
                {
                    foreach (var nextEdge in node.Edges)
                    {
                        if (nextEdge.Template != edge.Template ||
                            seenEdges.Contains(nextEdge))
                        {
                            continue;
                        }

                        network.AddEdge(nextEdge);
                        edgesToProcess.Remove(nextEdge);

                        seenEdges.Add(nextEdge);

                        FollowPath(nextEdge.Start);
                        FollowPath(nextEdge.End);
                    }
                }

                FollowPath(edge.Start);
                FollowPath(edge.End);
            }

            return(networks);
        }
Example #2
0
        private void Populate1()
        {
            RoadNetwork network = new RoadNetwork();

            Vertex start = network.AddVertex(100, 10);

            Vertex a = network.AddVertex(50, 10);
            Vertex b = network.AddVertex(150, 10);
            Vertex c = network.AddVertex(50, 75);
            Vertex d = network.AddVertex(100, 75);
            Vertex e = network.AddVertex(150, 75);

            Vertex f = network.AddVertex(50, 150);
            Vertex g = network.AddVertex(100, 150);
            Vertex h = network.AddVertex(150, 150);

            Vertex i = network.AddVertex(50, 210);
            Vertex j = network.AddVertex(150, 210);

            Vertex end = network.AddVertex(100, 210);

            network.AddEdge(start, a);
            network.AddEdge(start, b);

            network.AddEdge(a, c);
            network.AddEdge(b, e);

            network.AddEdge(c, d);
            network.AddEdge(e, d);

            network.AddEdge(c, f);
            network.AddEdge(d, g);
            network.AddEdge(e, h);

            network.AddEdge(f, g);
            network.AddEdge(h, g);

            network.AddEdge(f, i);
            network.AddEdge(h, j);

            network.AddEdge(i, end);
            network.AddEdge(j, end);

            parent1.Network = network;

            ConjugationOperator op = new ConjugationOperator();

            RoadNetwork cut = new RoadNetwork(network);

            op.Cut(cut);

            cut1.Network = cut;
        }
Example #3
0
        private void Populate2()
        {
            RoadNetwork network = new RoadNetwork();

            Vertex start = network.AddVertex(100, 10);

            Vertex a = network.AddVertex(50, 50);
            Vertex b = network.AddVertex(150, 50);

            Vertex c = network.AddVertex(25, 75);
            Vertex d = network.AddVertex(100, 75);
            Vertex e = network.AddVertex(175, 75);

            Vertex f = network.AddVertex(100, 150);

            Vertex g = network.AddVertex(50, 190);
            Vertex h = network.AddVertex(150, 190);

            Vertex end = network.AddVertex(100, 210);

            network.AddEdge(start, a);
            network.AddEdge(start, b);
            network.AddEdge(a, c);
            network.AddEdge(a, d);
            network.AddEdge(b, d);
            network.AddEdge(b, e);

            network.AddEdge(c, f);
            network.AddEdge(e, f);

            network.AddEdge(f, g);
            network.AddEdge(f, h);

            network.AddEdge(g, end);
            network.AddEdge(h, end);

            parent2.Network = network;

            ConjugationOperator op = new ConjugationOperator();

            RoadNetwork cut = new RoadNetwork(network);

            op.Cut(cut);

            cut2.Network = cut;
        }