/// <summary>
 /// Adds the elements of another EdgeCollectionCollection to the end of this EdgeCollectionCollection.
 /// </summary>
 /// <param name="items">
 /// The EdgeCollectionCollection whose elements are to be added to the end of this EdgeCollectionCollection.
 /// </param>
 public void AddRange(EdgeCollectionCollection items)
 {
     foreach (EdgeCollection item in items)
     {
         this.List.Add(item);
     }
 }
 public EdgeCollectionCollection AllPaths()
 {
     EdgeCollectionCollection collections = new EdgeCollectionCollection();
     EdgeCollection.Enumerator enumerator = this.EndPathEdges.GetEnumerator();
     while (enumerator.MoveNext())
     {
         IEdge se = enumerator.get_Current();
         collections.Add(this.Path(se));
     }
     return collections;
 }
 public EdgeCollectionCollection AllPaths()
 {
     EdgeCollectionCollection collections = new EdgeCollectionCollection();
     VertexCollection.Enumerator enumerator = this.EndPathVertices.GetEnumerator();
     while (enumerator.MoveNext())
     {
         IVertex v = enumerator.get_Current();
         collections.Add(this.Path(v));
     }
     return collections;
 }
		/// <summary>
		/// Returns the minimal set of path from the entry point that
		/// executes all actions
		/// </summary>
		/// <returns></returns>
		public EdgeCollectionCollection AllPaths()
		{
			EdgeCollectionCollection es = new EdgeCollectionCollection();

			foreach(IEdge e in EndPathEdges)
				es.Add( Path( e ) );

			return es;
		}
 /// <summary>
 /// Initializes a new instance of the EdgeCollectionCollection class, containing elements
 /// copied from another instance of EdgeCollectionCollection
 /// </summary>
 /// <param name="items">
 /// The EdgeCollectionCollection whose elements are to be added to the new EdgeCollectionCollection.
 /// </param>
 public EdgeCollectionCollection(EdgeCollectionCollection items)
 {
     this.AddRange(items);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="collection"></param>
 public Enumerator(EdgeCollectionCollection collection)
 {
     this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator();
 }
		/// <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>
		/// 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>
        /// Returns the minimal set of path from the entry point that
        /// executes all actions
        /// </summary>
        /// <returns></returns>
        public EdgeCollectionCollection AllPaths()
        {
            EdgeCollectionCollection es = new EdgeCollectionCollection();

            foreach(IVertex v in EndPathVertices)
                es.Add( Path( v ) );

            return es;
        }
 public EdgeCollectionCollection Trails(IVertex s)
 {
     if (s == null)
     {
         throw new ArgumentNullException("s");
     }
     if (this.Circuit.Count == 0)
     {
         throw new Exception("Circuit is empty");
     }
     int num = 0;
     num = 0;
     while (num < this.Circuit.Count)
     {
         IEdge edge = this.Circuit.get_Item(num);
         if (!this.TemporaryEdges.Contains(edge) && (edge.get_Source() == s))
         {
             break;
         }
         num++;
     }
     if (num == this.Circuit.Count)
     {
         throw new Exception("Did not find vertex in eulerian trail?");
     }
     EdgeCollectionCollection collections = new EdgeCollectionCollection();
     EdgeCollection edges = new EdgeCollection();
     BreadthFirstSearchAlgorithm algorithm = new BreadthFirstSearchAlgorithm(this.VisitedGraph);
     PredecessorRecorderVisitor vis = new PredecessorRecorderVisitor();
     algorithm.RegisterPredecessorRecorderHandlers(vis);
     algorithm.Compute(s);
     int num2 = num;
     while (num < this.Circuit.Count)
     {
         IEdge edge2 = this.Circuit.get_Item(num);
         if (this.TemporaryEdges.Contains(edge2))
         {
             if (edges.Count != 0)
             {
                 collections.Add(edges);
             }
             edges = vis.Path(edge2.get_Target());
         }
         else
         {
             edges.Add(edge2);
         }
         num++;
     }
     for (num = 0; num < num2; num++)
     {
         IEdge edge3 = this.Circuit.get_Item(num);
         if (this.TemporaryEdges.Contains(edge3))
         {
             if (edges.Count != 0)
             {
                 collections.Add(edges);
             }
             edges = vis.Path(edge3.get_Target());
         }
         else
         {
             edges.Add(edge3);
         }
     }
     if (edges.Count != 0)
     {
         collections.Add(edges);
     }
     return collections;
 }
 public EdgeCollectionCollection Trails()
 {
     EdgeCollectionCollection collections = new EdgeCollectionCollection();
     EdgeCollection edges = new EdgeCollection();
     EdgeCollection.Enumerator enumerator = this.Circuit.GetEnumerator();
     while (enumerator.MoveNext())
     {
         IEdge edge = enumerator.get_Current();
         if (this.TemporaryEdges.Contains(edge))
         {
             if (edges.Count != 0)
             {
                 collections.Add(edges);
             }
             edges = new EdgeCollection();
         }
         else
         {
             edges.Add(edge);
         }
     }
     if (edges.Count != 0)
     {
         collections.Add(edges);
     }
     return collections;
 }
 /// <summary>
 /// Adds the elements of another EdgeCollectionCollection to the end of this EdgeCollectionCollection.
 /// </summary>
 /// <param name="items">
 /// The EdgeCollectionCollection whose elements are to be added to the end of this EdgeCollectionCollection.
 /// </param>
 public void AddRange(EdgeCollectionCollection items)
 {
     foreach (EdgeCollection item in items)
     {
         this.List.Add(item);
     }
 }
 /// <summary>
 /// Initializes a new instance of the EdgeCollectionCollection class, containing elements
 /// copied from another instance of EdgeCollectionCollection
 /// </summary>
 /// <param name="items">
 /// The EdgeCollectionCollection whose elements are to be added to the new EdgeCollectionCollection.
 /// </param>
 public EdgeCollectionCollection(EdgeCollectionCollection items)
 {
     this.AddRange(items);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="collection"></param>
 public Enumerator(EdgeCollectionCollection collection)
 {
     this.wrapped = ((System.Collections.CollectionBase)collection).GetEnumerator();
 }