예제 #1
0
파일: Graph.cs 프로젝트: pfriesch/Towel
 /// <summary>Removes an edge from the graph.</summary>
 /// <param name="start">The starting point of the edge to remove.</param>
 /// <param name="end">The ending point of the edge to remove.</param>
 public void Remove(T start, T end)
 {
     if (_map.TryGet(start, out MapHashLinked <bool, T> foundValue) && foundValue.TryRemove(end))
     {
         return;
     }
     throw new InvalidOperationException("Removing a non-existing edge from the graph.");
 }
예제 #2
0
 /// <summary>Determines if a node is the child of another node.</summary>
 /// <param name="node">The child to check the parent of.</param>
 /// <param name="parent">The parent to check the child of.</param>
 /// <returns>True if the node is a child of the parent; False if not.</returns>
 public bool IsChildOf(T node, T parent)
 {
     if (_tree.TryGet(parent, out Node nodeData))
     {
         return(nodeData.Children.Contains(node));
     }
     else
     {
         throw new InvalidOperationException("Attempting to get the children of a non-existing node");
     }
 }