public static void printChildrenA(NodeA current, NodeA[] nodes, int depth) { for (int childIndex = 0; childIndex < current.getChildren().Length; childIndex++) { for (int nodeIndex = 0; nodeIndex < nodes.Length; nodeIndex++) { if (current.getChildren()[childIndex] == nodes[nodeIndex].getId()) { for (int i = 0; i < depth; i++) { Console.Write(" "); } Console.WriteLine(nodes[nodeIndex].getId()); printChildrenA(nodes[nodeIndex], nodes, depth + 1); } } } }
public static NodeB[] addRecursiveChildren(NodeA[] treeA, NodeA parent) { NodeB[] treeB = new NodeB[parent.getChildren().Length]; int index = 0; for (int i = 0; i < treeA.Length; i++) { for (int j = 0; j < parent.getChildren().Length; j++) { if (treeA[i].getId() == parent.getChildren()[j]) { NodeB child = new NodeB(treeA[i].getId()); child.setChildren(addRecursiveChildren(treeA, treeA[i])); treeB[index] = child; index++; } } } return(treeB); }