Exemplo n.º 1
0
 /// <summary>
 /// Tests whether a complete unique path exists in a graph
 /// using Euler's Theorem.
 /// </summary>
 /// <param name="graph">The <see cref="Subgraph" /> containing the edges.</param>
 /// <returns><c>true</c> if a sequence exists.</returns>
 private bool HasSequence(Subgraph graph)
 {
     int oddDegreeCount = 0;
     IEnumerator i = graph.GetNodeEnumerator();
     while(i.MoveNext())
     {
         Node node = (Node) i.Current;
         if (node.Degree % 2 == 1)
             oddDegreeCount++;
     }
     return oddDegreeCount <= 2;
 }
Exemplo n.º 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="graph"></param>
 /// <returns></returns>
 private static Node FindLowestDegreeNode(Subgraph graph)
 {
     int minDegree = Int32.MaxValue;
     Node minDegreeNode = null;
     IEnumerator i = graph.GetNodeEnumerator();
     while (i.MoveNext())
     {
         Node node = (Node) i.Current;
         if (minDegreeNode == null || node.Degree < minDegree)
         {
             minDegree = node.Degree;
             minDegreeNode = node;
         }
     }
     return minDegreeNode;
 }