Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
 public static IAnyGraphNode GetRedundancyInstigator(this IAnyGraphNode currentNode)
 {
     return(currentNode.GetRedundancyInstigator(currentNode, new List <IAnyGraphNode>()));
 }
Esempio n. 6
0
 public static bool IsNodeRedundant(this IAnyGraphNode node)
 {
     return(node.IsNodeRedundant(node, new List <IAnyGraphNode>()));
 }