Ejemplo n.º 1
0
 public Graph(Graph g)
     : this(g.V)
 {
     this.E = g.E;
     for (int v = 0; v < g.V; v++)
     {
         Part1.Stack<int> reverse = new Part1.Stack<int>();
         foreach (int w in g.Adj[v])
             reverse.Push(w);
         foreach (int w in reverse)
             this.Adj[v].Add(w);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new edge-weighted graph that is a deep copy of G.
 /// </summary>
 /// <param name="G"></param>
 public EdgeWeightedGraph(EdgeWeightedGraph G)
     : this(G.V())
 {
     this._e = G.E();
     for (int v = 0; v < G.V(); v++)
     {
         // reverse so that adjacency list is in same order as original
         Part1.Stack<Edge> reverse = new Part1.Stack<Edge>();
         foreach (Edge e in G.Adj[v])
             reverse.Push(e);
         foreach (Edge e in reverse)
             this.Adj[v].Add(e);
     }
 }