Esempio n. 1
0
 public void DeleteNode(GraphNode node)
 {
     if (AllNodes.Contains(node))
     {
         OnDeleteNode.Post().Node = node;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Adds a node with the given data to the tree as a child of a given parent node
        /// </summary>
        /// <param name="parent">The parent of this new node</param>
        /// <param name="data">The value the new node will contain</param>
        /// <returns>A reference to the newly created node</returns>
        public TreeNode <T> Add(TreeNode <T> parent, T data)
        {
            if (!AllNodes.Contains(parent))
            {
                throw new Exception("Parent node not found in list of all nodes!");
            }

            var newNode = new TreeNode <T>(parent, data);

            AllNodes.Add(newNode);
            return(newNode);
        }
        public void AddNode(Node node)
        {
            if (AllNodes.Contains(node))
            {
                return;
            }

            AllNodes.Add(node);

            if (!DirectContingents.ContainsKey(node))
            {
                DirectContingents.Add(node, new List <Node>());
            }

            if (!DirectDependents.ContainsKey(node))
            {
                DirectDependents.Add(node, new List <Node>());
            }
        }