示例#1
0
        public static GraphZL GetGraphZLInstance()
        {
            Vertex a = new Vertex("a");
            Vertex b = new Vertex("b");
            Vertex c = new Vertex("c");
            Vertex d = new Vertex("d");
            Vertex e = new Vertex("e");
            Vertex f = new Vertex("f");
            Vertex g = new Vertex("g");
            Vertex h = new Vertex("h");
            Vertex i = new Vertex("i");
            Vertex j = new Vertex("j");

            a.adjacentVertexs = new Vertex[] { c, d, e };
            b.adjacentVertexs = new Vertex[] { e, f };
            c.adjacentVertexs = new Vertex[] { a, d, f };
            d.adjacentVertexs = new[] { a, c };
            e.adjacentVertexs = new[] { a, b, f };
            f.adjacentVertexs = new[] { b, c, e };
            g.adjacentVertexs = new[] { h, j };
            h.adjacentVertexs = new[] { g, i };
            i.adjacentVertexs = new[] { h, j };
            j.adjacentVertexs = new[] { g, i };
            GraphZL graph = new GraphZL(new Vertex[] { a, b, c, d, e, f, g, h, i, j });

            return(graph);
        }
 public static void DFS(GraphZL graph)
 {
     foreach (var ver in graph.vertexs)
     {
         if (ver.Mark == false)
         {
             dfs(ver);
         }
     }
 }
示例#3
0
 public static void BFS(GraphZL graph)
 {
     foreach (var vert in graph.vertexs)
     {
         if (vert.Mark == false)
         {
             bfs(vert);
         }
     }
 }