public static IAnyGraphNode GetRedundancyInstigator(this IAnyGraphNode currentNode, IAnyGraphNode node, List <IAnyGraphNode> scanned) { scanned.Add(currentNode); if (currentNode.Links.Count == 0) { return(null); } foreach (IAnyGraphNode current in currentNode.Links.Where(x => x.connection != null).Select(x => x.connection)) { if (current == node) { return(currentNode); } else if (scanned.Contains(current)) { continue; } List <IAnyGraphNode> next = new List <IAnyGraphNode>(); next.AddRange(scanned); IAnyGraphNode nextInstigator = current.GetRedundancyInstigator(node, next); if (nextInstigator != null) { return(nextInstigator); } } return(null); }
public static bool IsNodeRedundant(this IAnyGraphNode currentNode, IAnyGraphNode node, List <IAnyGraphNode> scanned) { scanned.Add(currentNode); if (currentNode.Links.Count == 0) { return(false); } foreach (IAnyGraphNode current in currentNode.Links.Where(x => x.connection != null).Select(x => x.connection)) { if (current == node) { return(true); } else if (scanned.Contains(current)) { continue; } List <IAnyGraphNode> next = new List <IAnyGraphNode>(); next.AddRange(scanned); if (current.IsNodeRedundant(node, next)) { return(true); } } return(false); }
public static IAnyGraphNode GetRedundancyInstigator(this IAnyGraphNode currentNode, IAnyGraphNode node, List<IAnyGraphNode> scanned) { scanned.Add (currentNode); if(currentNode.Links.Count == 0){ return null; } foreach(IAnyGraphNode current in currentNode.Links.Where (x => x.connection != null).Select (x => x.connection)){ if(current == node){ return currentNode; } else if(scanned.Contains (current)){ continue; } List<IAnyGraphNode> next = new List<IAnyGraphNode>(); next.AddRange (scanned); IAnyGraphNode nextInstigator = current.GetRedundancyInstigator (node, next); if(nextInstigator != null){ return nextInstigator; } } return null; }
public static bool IsNodeRedundant(this IAnyGraphNode currentNode, IAnyGraphNode node, List<IAnyGraphNode> scanned) { scanned.Add (currentNode); if(currentNode.Links.Count == 0){ return false; } foreach(IAnyGraphNode current in currentNode.Links.Where (x => x.connection != null).Select (x => x.connection)){ if(current == node){ return true; } else if(scanned.Contains (current)){ continue; } List<IAnyGraphNode> next = new List<IAnyGraphNode>(); next.AddRange (scanned); if(current.IsNodeRedundant (node, next)){ return true; } } return false; }
public static IAnyGraphNode GetRedundancyInstigator(this IAnyGraphNode currentNode) { return(currentNode.GetRedundancyInstigator(currentNode, new List <IAnyGraphNode>())); }
public static bool IsNodeRedundant(this IAnyGraphNode node) { return(node.IsNodeRedundant(node, new List <IAnyGraphNode>())); }