/// <summary> /// Add a new branch to the path. /// New branches are assumed to be brand-new, consisting of nothing more than their default initial node. /// </summary> /// <param name="branch"></param> private void Add(Branch branch) { if (branch.Count > 1) { throw new PathException(PATH_EXCEPTION_TYPE.BRANCH_POPULATED); } Branches.Add(branch.ID, branch); OuterBranchIDs.Add(branch.ID); SetNodeDirectoryData(branch.InNode); }
/// <summary> /// Branch the passed branch. /// Remove the branch from the OuterBranchIds collection and add new branches based on it's InNode InDirection (the outer-most node in a branch). /// Throw an exception if the branch is open. /// </summary> /// <param name="branchingBranch"></param> public void Branch(int branchId) { Branch branchingBranch = Branches[branchId]; if (branchingBranch.Open) { throw new PathException(PATH_EXCEPTION_TYPE.BRANCH_OPEN); } OuterBranchIDs.Remove(branchingBranch.ID); foreach (NODE_DIRECTION direction in branchingBranch.InNode.InDirection.GetDirections()) { Branch outerBranch = new Branch(_branchId++, branchingBranch.InNode, direction, this); Add(outerBranch); } }