/// <summary> /// Adds the elements of another EdgeCollection to the end of this EdgeCollection. /// </summary> /// <param name="items"> /// The EdgeCollection whose elements are to be added to the end of this EdgeCollection. /// </param> public virtual void AddRange(EdgeCollection items) { foreach (IEdge item in items) { this.List.Add(item); } }
/// <summary> /// Adds the elements of an array to the end of this EdgeCollectionCollection. /// </summary> /// <param name="items"> /// The array whose elements are to be added to the end of this EdgeCollectionCollection. /// </param> public void AddRange(EdgeCollection[] items) { foreach (EdgeCollection item in items) { this.List.Add(item); } }
public EdgeRecorderVisitor(EdgeCollection edges) { if (edges == null) { throw new ArgumentNullException("edges"); } this.edges = edges; }
/// <summary> /// Filtered edge collection /// </summary> /// <param name="ec">base collection</param> /// <param name="ep">filtering predicate</param> public FilteredEdgeEnumerable(EdgeCollection ec, IEdgePredicate ep) { if (ec == null) throw new ArgumentNullException("edge collection"); if (ep == null) throw new ArgumentNullException("edge predicate"); m_EdgeCollection = ec; m_EdgePredicate = ep; }
/// <summary> /// Construct an eulerian trail builder /// </summary> /// <param name="g"></param> public EulerianTrailAlgorithm(IVertexAndEdgeListGraph g) { if (g==null) throw new ArgumentNullException("g"); visitedGraph = g; circuit = new EdgeCollection(); temporaryCircuit = new EdgeCollection(); currentVertex = null; temporaryEdges = new EdgeCollection(); }
/// <summary> /// Determines whether this VertexEdgesDictionary contains a specific value. /// </summary> /// <param name="value"> /// The EdgeCollection value to locate in this VertexEdgesDictionary. /// </param> /// <returns> /// true if this VertexEdgesDictionary contains an element with the specified value; /// otherwise, false. /// </returns> public virtual bool ContainsValue(EdgeCollection value) { foreach (EdgeCollection item in this.Dictionary.Values) { if (item == value) { return(true); } } return(false); }
/// <summary> /// Builds a new empty directed graph /// </summary> public AdjacencyGraph( IVertexAndEdgeProvider provider, bool allowParallelEdges ) { if (provider == null) throw new ArgumentNullException("provider"); m_Provider = provider; m_AllowParallelEdges = allowParallelEdges; m_VertexOutEdges = new VertexEdgesDictionary(); m_Edges = new EdgeCollection(); }
/// <summary> /// /// </summary> /// <param name="edgePredecessors"></param> /// <param name="endPathEdges"></param> public EdgePredecessorRecorderVisitor( EdgeEdgeDictionary edgePredecessors, EdgeCollection endPathEdges ) { if (edgePredecessors==null) throw new ArgumentNullException("edgePredecessors"); if (endPathEdges==null) throw new ArgumentNullException("endPathEdges"); this.edgePredecessors = edgePredecessors; this.endPathEdges = endPathEdges; }
public GraphBalancerAlgorithm(IMutableBidirectionalVertexAndEdgeListGraph visitedGraph, IVertex source, IVertex sink) { this.source = null; this.sink = null; this.balancingSource = null; this.balancingSourceEdge = null; this.balancingSink = null; this.balancingSinkEdge = null; this.capacities = new EdgeDoubleDictionary(); this.preFlow = new EdgeIntDictionary(); this.surplusVertices = new VertexCollection(); this.surplusEdges = new EdgeCollection(); this.deficientVertices = new VertexCollection(); this.deficientEdges = new EdgeCollection(); this.balanced = false; if (visitedGraph == null) { throw new ArgumentNullException("visitedGraph"); } if (source == null) { throw new ArgumentNullException("source"); } if (!visitedGraph.ContainsVertex(source)) { throw new ArgumentException("source is not part of the graph"); } if (sink == null) { throw new ArgumentNullException("sink"); } if (!visitedGraph.ContainsVertex(sink)) { throw new ArgumentException("sink is not part of the graph"); } this.visitedGraph = visitedGraph; this.source = source; this.sink = sink; IEdgeEnumerator enumerator = this.VisitedGraph.get_Edges().GetEnumerator(); while (enumerator.MoveNext()) { IEdge edge = enumerator.get_Current(); this.capacities.Add(edge, double.MaxValue); } IEdgeEnumerator enumerator2 = this.VisitedGraph.get_Edges().GetEnumerator(); while (enumerator2.MoveNext()) { IEdge edge2 = enumerator2.get_Current(); this.preFlow.Add(edge2, 1); } }
public void AddReversedEdges() { if (this.Augmented) { throw new InvalidOperationException("Graph already augmented"); } EdgeCollection edges = new EdgeCollection(); IEdgeEnumerator enumerator = this.VisitedGraph.get_Edges().GetEnumerator(); while (enumerator.MoveNext()) { IEdge edge = enumerator.get_Current(); if (!this.reversedEdges.Contains(edge)) { IEdge edge2 = this.FindReversedEdge(edge); if (edge2 != null) { this.reversedEdges.set_Item(edge, edge2); if (!this.reversedEdges.Contains(edge2)) { this.reversedEdges.set_Item(edge2, edge); } } else { edges.Add(edge); } } } EdgeCollection.Enumerator enumerator2 = edges.GetEnumerator(); while (enumerator2.MoveNext()) { IEdge edge3 = enumerator2.get_Current(); if (!this.reversedEdges.Contains(edge3)) { IEdge edge4 = this.FindReversedEdge(edge3); if (edge4 != null) { this.reversedEdges.set_Item(edge3, edge4); } else { edge4 = this.VisitedGraph.AddEdge(edge3.get_Target(), edge3.get_Source()); this.augmentedEgdes.Add(edge4); this.reversedEdges.set_Item(edge3, edge4); this.reversedEdges.set_Item(edge4, edge3); this.OnReservedEdgeAdded(new EdgeEventArgs(edge4)); } } } this.augmented = true; }
/// <summary> /// Filtered edge collection /// </summary> /// <param name="ec">base collection</param> /// <param name="ep">filtering predicate</param> public FilteredEdgeEnumerable(EdgeCollection ec, IEdgePredicate ep) { if (ec == null) { throw new ArgumentNullException("edge collection"); } if (ep == null) { throw new ArgumentNullException("edge predicate"); } m_EdgeCollection = ec; m_EdgePredicate = ep; }
public KruskalMinimumSpanningTreeAlgorithm( IVertexAndEdgeListGraph visitedGraph, EdgeDoubleDictionary weights ) { if (visitedGraph==null) throw new ArgumentNullException("visitedGraph"); if (weights==null) throw new ArgumentNullException("weights"); this.visitedGraph = visitedGraph; this.weights=weights; this.spanningTreeEdges = new EdgeCollection(); }
public EdgeCollection[] AllMergedPaths() { EdgeCollection[] edgesArray = new EdgeCollection[this.EndPathEdges.Count]; EdgeColorDictionary colors = new EdgeColorDictionary(); IDictionaryEnumerator enumerator = this.EdgePredecessors.GetEnumerator(); while (enumerator.MoveNext()) { DictionaryEntry current = (DictionaryEntry) enumerator.Current; colors.set_Item((IEdge) current.Key, 0); colors.set_Item((IEdge) current.Value, 0); } for (int i = 0; i < this.EndPathEdges.Count; i++) { edgesArray[i] = this.MergedPath(this.EndPathEdges.get_Item(i), colors); } return edgesArray; }
/// <summary> /// Adds an instance of type EdgeCollection to the end of this EdgeCollectionCollection. /// </summary> /// <param name="value"> /// The EdgeCollection to be added to the end of this EdgeCollectionCollection. /// </param> public void Add(EdgeCollection value) { this.List.Add(value); }
/// <summary> /// Inserts an element into the EdgeCollectionCollection at the specified index /// </summary> /// <param name="index"> /// The index at which the EdgeCollection is to be inserted. /// </param> /// <param name="value"> /// The EdgeCollection to insert. /// </param> public void Insert(int index, EdgeCollection value) { this.List.Insert(index, value); }
/// <summary> /// Removes the first occurrence of a specific EdgeCollection from this EdgeCollectionCollection. /// </summary> /// <param name="value"> /// The EdgeCollection value to remove from this EdgeCollectionCollection. /// </param> public void Remove(EdgeCollection value) { this.List.Remove(value); }
/// <summary> /// Returns the path leading to the vertex v. /// </summary> /// <param name="v">end of the path</param> /// <returns>path leading to v</returns> public EdgeCollection Path(IVertex v) { EdgeCollection path = new EdgeCollection(); IVertex vc = v; while (Predecessors.Contains(v)) { IEdge e = Predecessors[v]; path.Insert(0,e); v=e.Source; } return path; }
/// <summary> /// Adds temporary edges to the graph to make all vertex even. /// </summary> /// <param name="g"></param> /// <returns></returns> public EdgeCollection AddTemporaryEdges(IMutableVertexAndEdgeListGraph g) { if (g==null) throw new ArgumentNullException("g"); // first gather odd edges. VertexCollection oddVertices = AlgoUtility.OddVertices(g); // check that there are an even number of them if (oddVertices.Count%2!=0) throw new Exception("number of odd vertices in not even!"); // add temporary edges to create even edges: EdgeCollection ec = new EdgeCollection(); bool found,foundbe,foundadjacent; while (oddVertices.Count > 0) { IVertex u = oddVertices[0]; // find adjacent odd vertex. found = false; foundadjacent = false; foreach(IEdge e in g.OutEdges(u)) { IVertex v = e.Target; if (v!=u && oddVertices.Contains(v)) { foundadjacent=true; // check that v does not have an out-edge towards u foundbe = false; foreach(IEdge be in g.OutEdges(v)) { if (be.Target==u) { foundbe = true; break; } } if (foundbe) continue; // add temporary edge IEdge tempEdge = g.AddEdge(v,u); // add to collection ec.Add(tempEdge); // remove u,v from oddVertices oddVertices.Remove(u); oddVertices.Remove(v); // set u to null found = true; break; } } if (!foundadjacent) { // pick another vertex if (oddVertices.Count<2) throw new Exception("Eulerian trail failure"); IVertex v = oddVertices[1]; IEdge tempEdge = g.AddEdge(u,v); // add to collection ec.Add(tempEdge); // remove u,v from oddVertices oddVertices.Remove(u); oddVertices.Remove(v); // set u to null found = true; } if (!found) { oddVertices.Remove(u); oddVertices.Add(u); } } temporaryEdges = ec; return ec; }
/// <summary> /// Create a merged path. /// </summary> /// <remarks> /// <para> /// This method creates an edge path that stops if an edge is not white /// or the edge has no more predecessors. /// </para> /// </remarks> /// <param name="se">end edge</param> /// <param name="colors">edge color dictionary</param> /// <returns>path to edge</returns> public EdgeCollection MergedPath(IEdge se,EdgeColorDictionary colors) { EdgeCollection path = new EdgeCollection(); IEdge ec = se; GraphColor c = colors[ec]; if (c!=GraphColor.White) return path; else colors[ec]=GraphColor.Black; path.Insert(0,ec); while (EdgePredecessors.Contains(ec)) { IEdge e = EdgePredecessors[ec]; c = colors[e]; if (c!=GraphColor.White) return path; else colors[e]=GraphColor.Black; path.Insert(0,e); ec=e; } return path; }
/// <summary> /// Default constructor /// </summary> public EdgePredecessorRecorderVisitor() { edgePredecessors = new EdgeEdgeDictionary(); endPathEdges = new EdgeCollection(); }
/// <summary> /// Computes the set of eulerian trails that traverse the edge set. /// </summary> /// <remarks> /// This method returns a set of disjoint eulerian trails. This set /// of trails spans the entire set of edges. /// </remarks> /// <returns>Eulerian trail set</returns> public EdgeCollectionCollection Trails() { EdgeCollectionCollection trails = new EdgeCollectionCollection(); EdgeCollection trail = new EdgeCollection(); foreach(IEdge e in this.Circuit) { if (TemporaryEdges.Contains(e)) { // store previous trail and start new one. if(trail.Count != 0) trails.Add(trail); // start new trail trail = new EdgeCollection(); } else trail.Add(e); } if(trail.Count != 0) trails.Add(trail); return trails; }
/// <summary> /// Create an empty edge visitor /// </summary> public EdgeRecorderVisitor() { this.edges = new EdgeCollection(); }
public EdgeCollection Path(IVertex v) { EdgeCollection edges = new EdgeCollection(); IVertex vertex = v; while (this.Predecessors.Contains(v)) { IEdge edge = this.Predecessors.get_Item(v); edges.Insert(0, edge); v = edge.get_Source(); } return edges; }
/// <summary> /// Adds an element with the specified key and value to this VertexEdgesDictionary. /// </summary> /// <param name="key"> /// The Vertex key of the element to add. /// </param> /// <param name="value"> /// The EdgeCollection value of the element to add. /// </param> public virtual void Add(IVertex key, EdgeCollection value) { this.Dictionary.Add(key, value); }
/// <summary> /// Remove the edge (u,v) from the graph. /// If the graph allows parallel edges this remove all occurrences of /// (u,v). /// </summary> /// <param name="u">source vertex</param> /// <param name="v">target vertex</param> public override void RemoveEdge(IVertex u, IVertex v) { if (u == null) throw new ArgumentNullException("source vertex"); if (v == null) throw new ArgumentNullException("targetvertex"); EdgeCollection outEdges = VertexOutEdges[u]; EdgeCollection inEdges = VertexInEdges[v]; // marking edges to remove EdgeCollection removedEdges = new EdgeCollection(); foreach(IEdge e in outEdges) { if (e.Target == v) removedEdges.Add(e); } foreach(IEdge e in inEdges) { if (e.Source == u) removedEdges.Add(e); } //removing edges foreach(IEdge e in removedEdges) RemoveEdge(e); }
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; } }
/// <summary> /// Create a new enumerator on the collection /// </summary> /// <param name="collection">collection to enumerate</param> public Enumerator(EdgeCollection collection) { this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator(); }
/// <summary> /// Determines whether a specfic EdgeCollection value is in this EdgeCollectionCollection. /// </summary> /// <param name="value"> /// The EdgeCollection value to locate in this EdgeCollectionCollection. /// </param> /// <returns> /// true if value is found in this EdgeCollectionCollection; /// false otherwise. /// </returns> public bool Contains(EdgeCollection value) { return(this.List.Contains(value)); }
/// <summary> /// Remove the edge (u,v) from the graph. /// If the graph allows parallel edges this remove all occurrences of /// (u,v). /// </summary> /// <param name="u">source vertex</param> /// <param name="v">target vertex</param> public virtual void RemoveEdge(IVertex u, IVertex v) { if (u == null) throw new ArgumentNullException("source vertex"); if (v == null) throw new ArgumentNullException("targetvertex"); EdgeCollection edges = VertexOutEdges[u]; if (edges==null) throw new EdgeNotFoundException(); // marking edges to remove EdgeCollection removedEdges = new EdgeCollection(); foreach(IEdge e in edges) { if (e.Target == v) removedEdges.Add(e); } //removing edges foreach(IEdge e in removedEdges) edges.Remove(e); }
/// <summary> /// Returns the path leading to the vertex v. /// </summary> /// <param name="se">end of the path</param> /// <returns>path leading to v</returns> public EdgeCollection Path(IEdge se) { EdgeCollection path = new EdgeCollection(); IEdge ec = se; path.Insert(0,ec); while (EdgePredecessors.Contains(ec)) { IEdge e = EdgePredecessors[ec]; path.Insert(0,e); ec=e; } return path; }
/// <summary> /// Remove all the out-edges of vertex u for which the predicate pred /// returns true. /// </summary> /// <param name="u">vertex</param> /// <param name="pred">edge predicate</param> public virtual void RemoveOutEdgeIf(IVertex u, IEdgePredicate pred) { if (u==null) throw new ArgumentNullException("vertex u"); if (pred == null) throw new ArgumentNullException("predicate"); EdgeCollection edges = VertexOutEdges[u]; EdgeCollection removedEdges = new EdgeCollection(); foreach(IEdge e in edges) if (pred.Test(e)) removedEdges.Add(e); foreach(IEdge e in removedEdges) RemoveEdge(e); }
/// <summary> /// Returns the array of merged paths /// </summary> public EdgeCollection[] AllMergedPaths() { EdgeCollection[] es = new EdgeCollection[EndPathEdges.Count]; EdgeColorDictionary colors = new EdgeColorDictionary(); foreach(DictionaryEntry de in EdgePredecessors) { colors[(IEdge)de.Key]=GraphColor.White; colors[(IEdge)de.Value]=GraphColor.White; } for(int i=0;i<EndPathEdges.Count;++i) es[i] = MergedPath( EndPathEdges[i], colors ); return es; }
/// <summary> /// Initializes a new instance of the EdgeCollection class, containing elements /// copied from another instance of EdgeCollection /// </summary> /// <param name="items"> /// The EdgeCollection whose elements are to be added to the new EdgeCollection. /// </param> public EdgeCollection(EdgeCollection items) { this.AddRange(items); }
/// <summary> /// Adds an element with the specified key and value to this VertexEdgesDictionary. /// </summary> /// <param name="key"> /// The Vertex key of the element to add. /// </param> /// <param name="value"> /// The EdgeCollection value of the element to add. /// </param> public void Add(IVertex key, EdgeCollection value) { this.Dictionary.Add(key, value); }
/// <summary> /// Computes a set of eulerian trail, starting at <paramref name="s"/> /// that spans the entire graph. /// </summary> /// <remarks> /// <para> /// This method computes a set of eulerian trail starting at <paramref name="s"/> /// that spans the entire graph.The algorithm outline is as follows: /// </para> /// <para> /// The algorithms iterates throught the Eulerian circuit of the augmented /// graph (the augmented graph is the graph with additional edges to make /// the number of odd vertices even). /// </para> /// <para> /// If the current edge is not temporary, it is added to the current trail. /// </para> /// <para> /// If the current edge is temporary, the current trail is finished and /// added to the trail collection. The shortest path between the /// start vertex <paramref name="s"/> and the target vertex of the /// temporary edge is then used to start the new trail. This shortest /// path is computed using the <see cref="BreadthFirstSearchAlgorithm"/>. /// </para> /// </remarks> /// <param name="s">start vertex</param> /// <returns>eulerian trail set, all starting at s</returns> /// <exception cref="ArgumentNullException">s is a null reference.</exception> /// <exception cref="Exception">Eulerian trail not computed yet.</exception> public EdgeCollectionCollection Trails(IVertex s) { if (s==null) throw new ArgumentNullException("s"); if (this.Circuit.Count==0) throw new Exception("Circuit is empty"); // find the first edge in the circuit. int i=0; for(i=0;i<this.Circuit.Count;++i) { IEdge e = this.Circuit[i]; if (TemporaryEdges.Contains(e)) continue; if (e.Source == s) break; } if (i==this.Circuit.Count) throw new Exception("Did not find vertex in eulerian trail?"); // create collections EdgeCollectionCollection trails = new EdgeCollectionCollection(); EdgeCollection trail = new EdgeCollection(); BreadthFirstSearchAlgorithm bfs = new BreadthFirstSearchAlgorithm(VisitedGraph); PredecessorRecorderVisitor vis = new PredecessorRecorderVisitor(); bfs.RegisterPredecessorRecorderHandlers(vis); bfs.Compute(s); // go throught the edges and build the predecessor table. int start = i; for (;i<this.Circuit.Count;++i) { IEdge e = this.Circuit[i]; if (TemporaryEdges.Contains(e)) { // store previous trail and start new one. if(trail.Count != 0) trails.Add(trail); // start new trail // take the shortest path from the start vertex to // the target vertex trail = vis.Path(e.Target); } else trail.Add(e); } // starting again on the circuit for (i=0;i<start;++i) { IEdge e = this.Circuit[i]; if (TemporaryEdges.Contains(e)) { // store previous trail and start new one. if(trail.Count != 0) trails.Add(trail); // start new trail // take the shortest path from the start vertex to // the target vertex trail = vis.Path(e.Target); } else trail.Add(e); } // adding the last element if (trail.Count!=0) trails.Add(trail); return trails; }
/// <summary> /// Remove all the edges from graph g for which the predicate pred /// returns true. /// </summary> /// <param name="pred">edge predicate</param> public virtual void RemoveEdgeIf(IEdgePredicate pred) { if (pred == null) throw new ArgumentNullException("predicate"); // marking edge for removal EdgeCollection removedEdges = new EdgeCollection(); foreach(IEdge e in Edges) { if (pred.Test(e)) removedEdges.Add(e); } // removing edges foreach(IEdge e in removedEdges) RemoveEdge(e); }
/// <summary> /// Determines whether this VertexEdgesDictionary contains a specific value. /// </summary> /// <param name="value"> /// The EdgeCollection value to locate in this VertexEdgesDictionary. /// </param> /// <returns> /// true if this VertexEdgesDictionary contains an element with the specified value; /// otherwise, false. /// </returns> public bool ContainsValue(EdgeCollection value) { foreach (EdgeCollection item in this.Dictionary.Values) { if (item == value) return true; } return false; }
/// <summary> /// Augments the <see cref="VisitedGraph"/> with reversed edges. /// </summary> /// <exception cref="InvalidOperationException"> /// The graph has already been augmented. /// </exception> public void AddReversedEdges() { if (this.Augmented) throw new InvalidOperationException("Graph already augmented"); // step 1, find edges that need reversing EdgeCollection notReversedEdges = new EdgeCollection(); foreach (IEdge edge in this.VisitedGraph.Edges) { // if reversed already found, continue if (this.reversedEdges.Contains(edge)) continue; IEdge reversedEdge = this.FindReversedEdge(edge); if (reversedEdge != null) { // setup edge this.reversedEdges[edge] = reversedEdge; // setup reversed if needed if (!this.reversedEdges.Contains(reversedEdge)) this.reversedEdges[reversedEdge] = edge; continue; } // this edge has no reverse notReversedEdges.Add(edge); } // step 2, go over each not reversed edge, add reverse foreach (IEdge edge in notReversedEdges) { if (this.reversedEdges.Contains(edge)) continue; // already been added IEdge reversedEdge = this.FindReversedEdge(edge); if (reversedEdge != null) { this.reversedEdges[edge] = reversedEdge; continue; } // need to create one reversedEdge = this.VisitedGraph.AddEdge(edge.Target, edge.Source); this.augmentedEgdes.Add(reversedEdge); this.reversedEdges[edge] = reversedEdge; this.reversedEdges[reversedEdge] = edge; this.OnReservedEdgeAdded(new EdgeEventArgs(reversedEdge)); } this.augmented = true; }
/// <summary> /// Return the zero-based index of the first occurrence of a specific value /// in this EdgeCollectionCollection /// </summary> /// <param name="value"> /// The EdgeCollection value to locate in the EdgeCollectionCollection. /// </param> /// <returns> /// The zero-based index of the first occurrence of the _ELEMENT value if found; /// -1 otherwise. /// </returns> public int IndexOf(EdgeCollection value) { return(this.List.IndexOf(value)); }
/// <summary> /// Merges the temporary circuit with the current circuit /// </summary> /// <returns>true if all the graph edges are in the circuit</returns> protected bool CircuitAugmentation() { EdgeCollection newC=new EdgeCollection(); int i,j; // follow C until w is found for(i=0;i<Circuit.Count;++i) { IEdge e = Circuit[i]; if (e.Source==CurrentVertex) break; newC.Add(e); } // follow D until w is found again for(j=0;j<TemporaryCircuit.Count;++j) { IEdge e = TemporaryCircuit[j]; newC.Add(e); OnCircuitEdge(e); if (e.Target==CurrentVertex) break; } TemporaryCircuit.Clear(); // continue C for(;i<Circuit.Count;++i) { IEdge e = Circuit[i]; newC.Add(e); } // set as new circuit circuit = newC; // check if contains all edges if (Circuit.Count == VisitedGraph.EdgesCount) return true; return false; }