/// <summary> /// Adds the elements of another <see cref="IVertexEnumerable"/> /// to the end of this VertexCollection. /// </summary> /// <param name="items"> /// The <see cref="IVertexEnumerable"/> whose elements are to /// be added to the end of this VertexCollection. /// </param> public void AddRange(IVertexEnumerable items) { foreach (IVertex item in items) { this.List.Add(item); } }
public void Measure(IVertexEnumerable vertices) { if (vertices == null) { throw new ArgumentNullException("vertices"); } this.Clear(); int num = 0; IVertexEnumerator enumerator = vertices.GetEnumerator(); while (enumerator.MoveNext()) { VertexIntDictionary dictionary; IVertex vertex2; IVertex vertex = enumerator.get_Current(); if (this.passCounts.get_Item(vertex) == 0) { num++; } (dictionary = this.passCounts).set_Item(vertex2 = vertex, dictionary.get_Item(vertex2) + 1); } if (this.graph.get_VerticesEmpty()) { this.coverage = 0.0; } else { this.coverage = ((double) num) / ((double) this.graph.get_VerticesCount()); } }
public void Measure(IVertexEnumerable vertices) { if (vertices == null) { throw new ArgumentNullException("vertices"); } Clear(); // count the number of passages int count = 0; foreach (IVertex v in vertices) { if (this.passCounts[v] == 0) { ++count; } this.passCounts[v]++; } // compute covergage if (this.graph.VerticesEmpty) { this.coverage = 0; } else { this.coverage = count / (double)this.graph.VerticesCount; } }
/// <summary> /// /// </summary> /// <param name="vertices"></param> /// <param name="count"></param> /// <param name="rnd"></param> /// <returns></returns> public static IVertex Vertex(IVertexEnumerable vertices, int count, Random rnd) { if (vertices == null) { throw new ArgumentNullException("vertices"); } if (rnd == null) { throw new ArgumentNullException("random generator"); } if (count == 0) { throw new ArgumentException("vertices is empty"); } int i = rnd.Next(count); foreach (IVertex v in vertices) { if (i == 0) { return(v); } else { --i; } } // failed throw new ArgumentOutOfRangeException("count"); }
/// <summary> /// Default constructor /// </summary> /// <param name="ec">base collection</param> /// <param name="ep">predicate</param> /// <exception cref="ArgumentNullException">ec or ep null</exception> public FilteredVertexEnumerable(IVertexEnumerable ec, IVertexPredicate ep) { if (ec == null) throw new ArgumentNullException("Vertex collection"); if (ep == null) throw new ArgumentNullException("Vertex predicate"); m_VertexEnumerable = ec; m_VertexPredicate = ep; }
/// <summary> /// Returns the first vertex of the enumerable /// </summary> /// <param name="vertices">enumerable collection of <see cref="IVertex"/></param> /// <returns>first vertex if any, otherwise a null reference</returns> public static IVertex FirstVertex(IVertexEnumerable vertices) { if (vertices==null) throw new ArgumentNullException("vertices"); IVertexEnumerator en = vertices.GetEnumerator(); if (!en.MoveNext()) return null; else return en.Current; }
internal void WriteVertices(VertexColorDictionary colors, IVertexEnumerable vertices) { foreach (IVertex v in vertices) { if (colors[v] == GraphColor.White) { OnWriteVertex(v); OnFormatVertex(v); colors[v] = GraphColor.Black; } } }
/// <summary> /// Default constructor /// </summary> /// <param name="ec">base collection</param> /// <param name="ep">predicate</param> /// <exception cref="ArgumentNullException">ec or ep null</exception> public FilteredVertexEnumerable(IVertexEnumerable ec, IVertexPredicate ep) { if (ec == null) { throw new ArgumentNullException("Vertex collection"); } if (ep == null) { throw new ArgumentNullException("Vertex predicate"); } m_VertexEnumerable = ec; m_VertexPredicate = ep; }
/// <summary> /// Returns the first vertex of the enumerable /// </summary> /// <param name="vertices">enumerable collection of <see cref="IVertex"/></param> /// <returns>first vertex if any, otherwise a null reference</returns> public static IVertex LastVertex(IVertexEnumerable vertices) { if (vertices == null) { throw new ArgumentNullException("vertices"); } IVertexEnumerator en = vertices.GetEnumerator(); IVertex current = null; while (en.MoveNext()) { current = en.Current; } return(current); }
/// <summary> /// Returns the first vertex of the enumerable /// </summary> /// <param name="vertices">enumerable collection of <see cref="IVertex"/></param> /// <returns>first vertex if any, otherwise a null reference</returns> public static IVertex FirstVertex(IVertexEnumerable vertices) { if (vertices == null) { throw new ArgumentNullException("vertices"); } IVertexEnumerator en = vertices.GetEnumerator(); if (!en.MoveNext()) { return(null); } else { return(en.Current); } }
/// <summary> /// /// </summary> /// <param name="vertices"></param> /// <param name="count"></param> /// <param name="rnd"></param> /// <returns></returns> public static IVertex Vertex(IVertexEnumerable vertices, int count, Random rnd) { if (vertices == null) throw new ArgumentNullException("vertices"); if (rnd == null) throw new ArgumentNullException("random generator"); if (count == 0) throw new ArgumentException("vertices is empty"); int i = rnd.Next(count); foreach(IVertex v in vertices) { if (i==0) return v; else --i; } // failed throw new ArgumentOutOfRangeException("count"); }
public void Measure(IVertexEnumerable vertices) { if (vertices == null) throw new ArgumentNullException("vertices"); Clear(); // count the number of passages int count=0; foreach(IVertex v in vertices) { if (this.passCounts[v]==0) ++count; this.passCounts[v]++; } // compute covergage if (this.graph.VerticesEmpty) this.coverage =0; else this.coverage = count / (double)this.graph.VerticesCount; }
/// <summary> /// Returns the first vertex of the enumerable that matches the predicate. /// </summary> /// <param name="vertices">enumerable collection of <see cref="IVertex"/></param> /// <param name="pred">vertex predicate</param> /// <returns>first vertex if any, otherwise a null reference</returns> public static IVertex FirstVertexIf(IVertexEnumerable vertices, IVertexPredicate pred) { if (vertices == null) { throw new ArgumentNullException("vertices"); } if (pred == null) { throw new ArgumentNullException("pred"); } IVertexEnumerator en = vertices.GetEnumerator(); while (en.MoveNext()) { if (pred.Test(en.Current)) { return(en.Current); } } return(null); }
/// <summary> /// Returns the first vertex of the enumerable that matches the predicate. /// </summary> /// <param name="vertices">enumerable collection of <see cref="IVertex"/></param> /// <param name="pred">vertex predicate</param> /// <returns>first vertex if any, otherwise a null reference</returns> public static IVertex FirstVertexIf(IVertexEnumerable vertices, IVertexPredicate pred) { if (vertices==null) throw new ArgumentNullException("vertices"); if (pred==null) throw new ArgumentNullException("pred"); IVertexEnumerator en = vertices.GetEnumerator(); while(en.MoveNext()) { if (pred.Test(en.Current)) return en.Current; } return null; }
/// <summary> /// Returns the first vertex of the enumerable /// </summary> /// <param name="vertices">enumerable collection of <see cref="IVertex"/></param> /// <returns>first vertex if any, otherwise a null reference</returns> public static IVertex LastVertex(IVertexEnumerable vertices) { if (vertices==null) throw new ArgumentNullException("vertices"); IVertexEnumerator en = vertices.GetEnumerator(); IVertex current = null; while(en.MoveNext()) { current = en.Current; } return current; }
/// <summary> /// Initializes a new instance of the <see cref="IVertexEnumerable"/> /// interface, containing elements /// copied from another instance of VertexCollection /// </summary> /// <param name="items"> /// The <see cref="IVertexEnumerable"/> whose elements are to be added to the new VertexCollection. /// </param> public VertexCollection(IVertexEnumerable items) { this.AddRange(items); }
internal void WriteVertices(VertexColorDictionary colors, IVertexEnumerable vertices) { foreach(IVertex v in vertices) { if(colors[v]==GraphColor.White) { OnWriteVertex(v); OnFormatVertex(v); colors[v]=GraphColor.Black; } } }
/// <summary> /// Adds the elements of another <see cref="IVertexEnumerable"/> /// to the end of this VertexCollection. /// </summary> /// <param name="items"> /// The <see cref="IVertexEnumerable"/> whose elements are to /// be added to the end of this VertexCollection. /// </param> public void AddRange(IVertexEnumerable items) { foreach (IVertex item in items) { this.List.Add(item); } }
/// <summary> /// Initializes a new instance of the <see cref="IVertexEnumerable"/> /// interface, containing elements /// copied from another instance of VertexCollection /// </summary> /// <param name="items"> /// The <see cref="IVertexEnumerable"/> whose elements are to be added to the new VertexCollection. /// </param> public VertexCollection(IVertexEnumerable items) { this.AddRange(items); }