private void BuildBranch() { branchList = new List <Branch>(); nodeList = new List <Node>(); Node node; EletronicUnit unit = source; Branch branch; node = source.GetNegativePole(); Stack <Node> nodes = new Stack <Node>(); Stack <Branch> branches = new Stack <Branch>(); branch = new Branch(node); node.index = nodeList.Count; bool IN = true; do { if (node.Count == 0) { if (nodes.Count == 0) { break; } else { node = nodes.Pop(); branch = branches.Pop(); IN = false; continue; } } else if (node.IsForking()) { if (nodeList.Contains(node)) { SaveBranch(node, branch); if (nodes.Count == 0) { break; } else { node = nodes.Pop(); branch = branches.Pop(); IN = true; continue; } } else if (!IN) { SaveBranchAndNode(node, branch); int count = node.Count; for (int i = 0; i < count; i++) { nodes.Push(node.GetNode(i)); branches.Push(new Branch(node)); } node = nodes.Pop(); branch = branches.Pop(); IN = true; continue; } else if (IN) { SaveBranchAndNode(node, branch); unit = node.GetUnit(); branch = new Branch(node); node = unit.GetOutNode(node); branch.Append(unit); } } else if (!IN && !node.IsForking()) { node = node.GetNode(0); if (nodeList.Contains(node)) { SaveBranch(node, branch); if (nodes.Count == 0) { break; } else { node = nodes.Pop(); branch = branches.Pop(); IN = true; continue; } } } else { unit = node.GetUnit(); branch.Append(unit); node = unit.GetOutNode(node); } IN = !IN; } while (true); }
public void Insert(int index, EletronicUnit unit) { Units.Insert(index, unit); }
public Node(EletronicUnit unit) { this.unit = unit; feet = new List <Node>(); }
public void Append(EletronicUnit unit) { Units.Add(unit); R = R + unit.R; }