Exemplo n.º 1
0
 private bool IsAncestor(DFSTNode node, DFSTNode supposedAncestor)
 {
     V_0 = (DFSTNode)node.get_Predecessor();
     while (V_0 != null)
     {
         if (V_0 == supposedAncestor)
         {
             return(true);
         }
         V_0 = (DFSTNode)V_0.get_Predecessor();
     }
     return(false);
 }
Exemplo n.º 2
0
 public List <DFSTNode> GetPath(DFSTNode ancestorNode, DFSTNode descenderNode)
 {
     V_0 = new List <DFSTNode>();
     V_1 = descenderNode;
     while (V_1 != null && V_1 != ancestorNode)
     {
         V_0.Add(V_1);
         V_1 = (DFSTNode)V_1.get_Predecessor();
     }
     if (V_1 == null)
     {
         throw new Exception("No path between the two nodes.");
     }
     V_0.Add(V_1);
     V_0.Reverse();
     return(V_0);
 }