Exemplo n.º 1
0
        private void ConnectSharedChildren(Dictionary <int, PartitionNode> added_children)
        {
            // For created children finds and connects other parents sharing the same children.
            Dictionary <int, PartitionNode> all_siblings = GetMySiblings();

            foreach (KeyValuePair <int, PartitionNode> child in added_children)
            {
                foreach (int sibling_num in NodeHelperFuncs.getRelevantSiblings(child.Key))
                {
                    if (all_siblings.ContainsKey(sibling_num) && all_siblings[sibling_num] != null)
                    {
                        int sChildNum = NodeHelperFuncs.getSharedSiblingChildNumber(child.Key, sibling_num);
                        all_siblings[sibling_num].SetSingleChild(sChildNum, child.Value);
                        child.Value.AddParent(all_siblings[sibling_num], NodeHelperFuncs.GetParentPosition(sChildNum));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void RemoveChild(int child, bool check_siblings = true)
        {
            if (!Children.ContainsKey(child))
            {
                return;
            }
            if (IsRootNode() || !check_siblings)
            {
                Children.Remove(child);
                return;
            }
            Dictionary <int, PartitionNode> siblings = GetMySiblings();

            foreach (int sibling_num in NodeHelperFuncs.getRelevantSiblings(child))
            {
                if (siblings.ContainsKey(sibling_num) && siblings[sibling_num] != null)
                {
                    int sib_child_num = NodeHelperFuncs.getSharedSiblingChildNumber(child, sibling_num);
                    siblings[sibling_num].RemoveChild(sib_child_num, false);
                }
            }
            Children.Remove(child);
        }