Ejemplo n.º 1
0
 /// <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());
     }
 }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        /// <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");
        }
Ejemplo n.º 5
0
		/// <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;
		}
Ejemplo n.º 6
0
 /// <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;
 }
Ejemplo n.º 7
0
 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;
         }
     }
 }
Ejemplo n.º 8
0
        /// <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;
        }
Ejemplo n.º 9
0
        /// <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);
        }
Ejemplo n.º 10
0
        /// <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);
            }
        }
Ejemplo n.º 11
0
		/// <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;
        }
Ejemplo n.º 13
0
        /// <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);
        }
Ejemplo n.º 14
0
        /// <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;
        }
Ejemplo n.º 15
0
 /// <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;
 }
Ejemplo n.º 16
0
 /// <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;
         }
     }
 }
Ejemplo n.º 18
0
		/// <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);
			}
		}
Ejemplo n.º 19
0
		/// <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);
		}