This commit is contained in:
Tim 2020-11-26 10:57:02 +01:00
parent b526997439
commit 6697c937ef
2 changed files with 106 additions and 61 deletions

View File

@ -93,6 +93,8 @@ public class DecisionTreeBuilder {
// Aktueller Inhalt der Wurzel des Teilbaumes
DecisionNode k = pTree.getContent();
printHirarchical(pTree, 0);
// TODO: Ausgabe des Baumes implemeniteren
// Mit k.toString() kann der Inhalt
@ -104,6 +106,35 @@ public class DecisionTreeBuilder {
// baumAusgeben(pBaum.getLeftTree(), pTiefe+1);
}
public void printHirarchical(BinaryTree<DecisionNode> pRoot, int xOff) {
if (pRoot.getContent() == null) {
return;
}
printOffset(xOff);
System.out.println(pRoot.getContent());
if (!pRoot.getLeftTree().isEmpty()) {
xOff++;
printHirarchical(pRoot.getLeftTree(), xOff);
xOff--;
}
if (!pRoot.getRightTree().isEmpty()) {
xOff++;
printHirarchical(pRoot.getRightTree(), xOff);
xOff--;
}
}
private void printOffset(int off) {
for (int i = 0; i < off; i++) {
if (i == off - 1) {
System.out.print("|> ");
} else {
System.out.print("| ");
}
}
}
/**
* Klassifiziert die {@link #TESTDATA Testdaten} im Baum und
* vergleicht das Ergebnis mit dem tatsächlich in den Testdaten

View File

@ -1,6 +1,6 @@
#BlueJ package file
dependency1.from=Classification
dependency1.to=Passenger
dependency1.from=FileSystem
dependency1.to=List
dependency1.type=UsesDependency
dependency10.from=DecisionTreeBuilder
dependency10.to=ID3
@ -14,16 +14,16 @@ dependency12.type=UsesDependency
dependency13.from=DecisionTreeBuilder
dependency13.to=FileSystem
dependency13.type=UsesDependency
dependency2.from=Decision
dependency2.from=Classification
dependency2.to=Passenger
dependency2.type=UsesDependency
dependency3.from=FileSystem
dependency3.to=List
dependency3.from=ID3
dependency3.to=Passenger
dependency3.type=UsesDependency
dependency4.from=ID3
dependency4.from=DecisionNode
dependency4.to=Passenger
dependency4.type=UsesDependency
dependency5.from=DecisionNode
dependency5.from=Decision
dependency5.to=Passenger
dependency5.type=UsesDependency
dependency6.from=DecisionTreeBuilder
@ -42,18 +42,18 @@ editor.fx.0.height=722
editor.fx.0.width=1031
editor.fx.0.x=90
editor.fx.0.y=24
objectbench.height=66
objectbench.width=1098
objectbench.height=100
objectbench.width=1256
package.divider.horizontal=0.6
package.divider.vertical=0.8983286908077994
package.editor.height=622
package.editor.width=975
package.editor.x=39
package.editor.y=24
package.frame.height=776
package.frame.width=1122
package.divider.vertical=0.881243063263041
package.editor.height=787
package.editor.width=1145
package.editor.x=0
package.editor.y=0
package.frame.height=1000
package.frame.width=1296
package.numDependencies=13
package.numTargets=9
package.numTargets=11
package.showExtends=true
package.showUses=true
project.charset=UTF-8
@ -62,66 +62,80 @@ readme.name=@README
readme.width=47
readme.x=10
readme.y=10
target1.height=50
target1.name=Classification
target1.height=40
target1.name=BinaryTree$BTNode
target1.showInterface=false
target1.type=ClassTarget
target1.type=SubTargetClassRole
target1.width=110
target1.x=120
target1.y=200
target1.x=460
target1.y=370
target10.height=50
target10.name=Passenger
target10.showInterface=false
target10.type=ClassTarget
target10.width=90
target10.x=670
target10.y=100
target11.height=50
target11.name=Decision
target11.showInterface=false
target11.type=ClassTarget
target11.width=110
target11.x=530
target11.y=200
target2.height=50
target2.name=Decision
target2.name=List$ListNode
target2.showInterface=false
target2.type=ClassTarget
target2.type=SubTargetClassRole
target2.width=110
target2.x=530
target2.y=200
target3.height=50
target3.name=FileSystem
target2.x=460
target2.y=290
target3.height=60
target3.name=DecisionTreeBuilder
target3.showInterface=false
target3.type=ClassTarget
target3.width=90
target3.x=90
target3.y=10
target4.height=120
target4.name=BinaryTree
target3.width=120
target3.x=290
target3.y=440
target4.height=50
target4.name=FileSystem
target4.showInterface=false
target4.type=ClassTarget
target4.width=440
target4.x=630
target4.y=30
target4.width=90
target4.x=30
target4.y=170
target5.height=50
target5.name=ID3
target5.name=Classification
target5.showInterface=false
target5.type=ClassTarget
target5.width=80
target5.x=780
target5.y=450
target6.height=50
target6.name=List
target5.width=110
target5.x=160
target5.y=130
target6.height=70
target6.name=BinaryTree
target6.showInterface=false
target6.type=ClassTarget
target6.width=150
target6.x=840
target6.y=240
target6.width=160
target6.x=150
target6.y=20
target7.height=50
target7.name=Passenger
target7.name=ID3
target7.showInterface=false
target7.type=ClassTarget
target7.width=90
target7.x=10
target7.y=80
target7.width=80
target7.x=610
target7.y=500
target8.height=50
target8.name=DecisionNode
target8.name=List
target8.showInterface=false
target8.type=AbstractTarget
target8.width=80
target8.x=360
target8.y=150
target9.height=250
target9.name=DecisionTreeBuilder
target8.type=ClassTarget
target8.width=150
target8.x=110
target8.y=230
target9.height=50
target9.name=DecisionNode
target9.showInterface=false
target9.type=ClassTarget
target9.width=350
target9.x=210
target9.y=320
target9.type=AbstractTarget
target9.width=110
target9.x=390
target9.y=160