コード例 #1
0
 /* Called at the end of the animation,
  * determines whether destination was or
  * wasn't found and colors nodes appropriately.
  */
 private void finalize(bool wasFound)
 {
     if (wasFound)
     {
         Node tmp = graph.Destination;
         do
         {
             tmp.Color = FOUND_N;
             if (incomingEdge[tmp] == null)
             {
                 break;
             }
             Edge edge = incomingEdge[tmp] as Edge;
             edge.Color = FOUND_E;
             tmp        = Node.GetOther(tmp, edge);
         }while(tmp != null);
         MessageBox.Show("Destination Node Found!", "Found!");
     }
     else
     {
         MessageBox.Show("Destination Node not Found!", "Not Found!");
     }
 }
コード例 #2
0
 /* Takes all the edges from popNode and adds the
  * connecting nodes to list "pushing" which are nodes
  * that are about to be pushed to the PQ.  Also adjusts
  * incoming edge if necessary and adjusts colors appropriately.
  */
 private void step2()
 {
     pushing.Clear();
     for (int i = 0; i < popNode.Edges.Length(); i++)
     {
         Edge edge = popNode.Edges[i];
         Node n    = Node.GetOther(popNode, edge);
         if (popped.Contains(n))
         {
             continue;
         }
         edge.Color        = INQUEUE_E;
         proposedWeight[n] = edge.Weight + Node.GetOther(n, edge).Distance;
         if ((int)proposedWeight[n] < n.Distance)
         {
             incomingEdge[n] = edge;
         }
         n.Text  = edge.Weight.ToString() + "+" + popNode.Distance.ToString();
         n.Color = INQUEUE_N;
         pushing.Add(n);
     }
     stepCount = 2;
 }