Exemple #1
0
        /// <summary>
        /// Returns the number of elements in this enumerator.
        /// </summary>
        public static int Count(this DirectedDynamicGraph.EdgeEnumerator enumerator)
        {
            var c = 0;

            enumerator.Reset();

            while (enumerator.MoveNext())
            {
                c++;
            }
            return(c);
        }
Exemple #2
0
        /// <summary>
        /// Moves the enumerator until the given condition is true or throws an exception if the condition is never true.
        /// </summary>
        public static DirectedDynamicGraph.EdgeEnumerator First(this DirectedDynamicGraph.EdgeEnumerator enumerator,
                                                                Func <DirectedDynamicGraph.EdgeEnumerator, bool> stop)
        {
            enumerator.Reset();

            while (enumerator.MoveNext())
            {
                if (stop(enumerator))
                {
                    return(enumerator);
                }
            }
            throw new Exception("No edge found that satisfies the given condition.");
        }
Exemple #3
0
 /// <summary>
 /// Gets the edge from vertex1 -> vertex2.
 /// </summary>
 public static DynamicEdge GetEdge(this DirectedDynamicGraph.EdgeEnumerator enumerator, uint vertex1, uint vertex2)
 {
     if (!enumerator.MoveTo(vertex1))
     {
         throw new Exception("Vexter does not exist.");
     }
     while (enumerator.MoveNext())
     {
         if (enumerator.Neighbour == vertex2)
         {
             return(enumerator.Current);
         }
     }
     throw new Exception(string.Format("Edge {0}->{1} not found.", vertex1, vertex2));
 }