コード例 #1
0
        private bool CycleFromCurrentNode(BindingNode node, BindingNode previousNode, HashSet <BindingNode> unvisited, HashSet <BindingNode> seen)
        {
            /*
             * Recursively checks whether the current node will lead to a cycle
             */

            if (seen.Contains(node))
            {
                return(true);
            }
            else
            {
                unvisited.Remove(node);
                seen.Add(node);

                bool cycle = false;

                foreach (BindingNode child in node.AdjacentNodes
                         .Where(child => !child.Equals(previousNode))) // Prevent the traversal from looping back over two-way bindings
                {
                    cycle = cycle || CycleFromCurrentNode(child, node, unvisited, seen);
                }

                return(cycle);
            }
        }
コード例 #2
0
        public void Bind(BindPoint first, BindPoint second)
        {
            /*
             * Link the two nodes in one direction
             */

            BindingNode firstNode  = FindNodeForPoint(first);
            BindingNode secondNode = FindNodeForPoint(second);

            firstNode.AddEdgeTo(secondNode);
        }
コード例 #3
0
        public void RemoveBindings(BindPoint[] sources, BindPoint[] destinations)
        {
            /*
             * Remove all bindings between the sources and the destinations
             */

            foreach (BindPoint source in sources)
            {
                BindingNode node = FindNodeForPoint(source);
                node.AdjacentNodes.RemoveAll((BindingNode n) => destinations.Contains(n.Vertex));
            }
        }
コード例 #4
0
 public void AddEdgeTo(BindingNode other)
 {
     AdjacentNodes.Add(other);
 }
コード例 #5
0
 public void AddEdgeTo(BindingNode other)
 {
     AdjacentNodes.Add(other);
 }
コード例 #6
0
        private bool CycleFromCurrentNode(BindingNode node, BindingNode previousNode, HashSet<BindingNode> unvisited, HashSet<BindingNode> seen)
        {
            /*
             * Recursively checks whether the current node will lead to a cycle
             */

            if (seen.Contains(node)) return true;
            else
            {
                unvisited.Remove(node);
                seen.Add(node);

                bool cycle = false;

                foreach (BindingNode child in node.AdjacentNodes
                    .Where(child => !child.Equals(previousNode)))  // Prevent the traversal from looping back over two-way bindings
                {
                    cycle = cycle || CycleFromCurrentNode(child, node, unvisited, seen);
                }

                return cycle;
            }
        }