コード例 #1
0
 public void AddEdge(ref DEdge edge)
 {
     if (!this.edgesList.Contains(edge))
     {
         this.edgesList.Add(edge);
         this.unvisitedEdgesList.Add(edge);
     }
 }
コード例 #2
0
        public void VisitEdge(DNode a, DNode b)
        {
            DEdge edge = FindEdge(a, b);

            if (this.edgesList.Contains(edge) &&
                !this.visitedEdgesList.Contains(edge) &&
                this.unvisitedEdgesList.Contains(edge))
            {
                this.visitedEdgesList.Add(edge);
                this.unvisitedEdgesList.Remove(edge);
                edge.Visit();
            }
        }
コード例 #3
0
        public static void BuildNetwork4(String[] a)
        {
            //define nodes with U as start node
            DNode nodeU = new DNode("u");
            DNode nodeV = new DNode("v");
            DNode nodeW = new DNode("w");
            DNode nodeX = new DNode("x");
            DNode nodeY = new DNode("y");
            DNode nodeZ = new DNode("z");

            nodeU.SetStartNode();

            //define network and add nodes to network
            network = new DNetwork(4);
            network.AddNode(ref nodeU);
            network.AddNode(ref nodeV);
            network.AddNode(ref nodeW);
            network.AddNode(ref nodeX);
            network.AddNode(ref nodeY);
            network.AddNode(ref nodeZ);

            //define edges and add to network
            DEdge edgeUV = new DEdge(ref nodeU, ref nodeV, Int32.Parse(a[0]));
            DEdge edgeUX = new DEdge(ref nodeU, ref nodeX, Int32.Parse(a[1]));
            DEdge edgeUW = new DEdge(ref nodeU, ref nodeW, Int32.Parse(a[2]));
            DEdge edgeUY = new DEdge(ref nodeU, ref nodeY, Int32.Parse(a[3]));
            DEdge edgeZW = new DEdge(ref nodeZ, ref nodeW, Int32.Parse(a[4]));
            DEdge edgeZY = new DEdge(ref nodeZ, ref nodeY, Int32.Parse(a[5]));
            DEdge edgeZV = new DEdge(ref nodeZ, ref nodeV, Int32.Parse(a[6]));
            DEdge edgeZX = new DEdge(ref nodeZ, ref nodeX, Int32.Parse(a[7]));
            DEdge edgeVX = new DEdge(ref nodeV, ref nodeX, Int32.Parse(a[8]));
            DEdge edgeVW = new DEdge(ref nodeV, ref nodeW, Int32.Parse(a[10]));
            DEdge edgeXY = new DEdge(ref nodeX, ref nodeY, Int32.Parse(a[12]));
            DEdge edgeYW = new DEdge(ref nodeY, ref nodeW, Int32.Parse(a[13]));

            network.AddEdge(ref edgeUV);
            network.AddEdge(ref edgeUX);
            network.AddEdge(ref edgeZW);
            network.AddEdge(ref edgeZY);
            network.AddEdge(ref edgeXY);
            network.AddEdge(ref edgeVW);
            network.AddEdge(ref edgeVX);
            network.AddEdge(ref edgeYW);
            network.AddEdge(ref edgeUW);
            network.AddEdge(ref edgeUY);
            network.AddEdge(ref edgeZV);
            network.AddEdge(ref edgeZX);
        }