Beispiel #1
0
  @Test
  public void testPrintMyTreeNode() {
    MyTreeNode<String> root = new MyTreeNode<>(null, null, "root");
    MyTreeNode<String> c1 = new MyTreeNode<>(root, null, "c1");
    MyTreeNode<String> c2 = new MyTreeNode<>(root, null, "c2");
    MyTreeNode<String> c3 = new MyTreeNode<>(root, null, "c3");

    root.addChild(c1);
    root.addChild(c2);
    root.addChild(c3);

    MyTreeNode<String> c11 = new MyTreeNode<>(null, null, "c1-1");
    MyTreeNode<String> c12 = new MyTreeNode<>(null, null, "c1-2");
    MyTreeNode<String> c13 = new MyTreeNode<>(null, null, "c1-3");

    MyTreeNode<String> c21 = new MyTreeNode<>(null, null, "c2-1");
    MyTreeNode<String> c22 = new MyTreeNode<>(null, null, "c2-2");
    MyTreeNode<String> c23 = new MyTreeNode<>(null, null, "c2-3");

    c1.addChild(c11);
    c1.addChild(c12);
    c1.addChild(c13);

    c2.addChild(c21);
    c2.addChild(c22);
    c2.addChild(c23);

    MyTreeNode<String> c231 = new MyTreeNode<>(null, null, "c2-3-1");
    MyTreeNode<String> c232 = new MyTreeNode<>(null, null, "c2-3-2");

    c23.addChild(c231);
    c23.addChild(c232);

    MyTreeNode<String> c31 = new MyTreeNode<>(null, null, "c3-1");
    MyTreeNode<String> c32 = new MyTreeNode<>(null, null, "c3-2");
    c3.addChild(c31);
    c3.addChild(c32);
    AlgUtil.printTreeNode(root);
  }