Różnice
Różnice między wybraną wersją a wersją aktualną.
|
|
pl:miw:miw08_rbs_ml:showednode [2017/07/17 10:08] |
pl:miw:miw08_rbs_ml:showednode [2019/06/27 15:50] (aktualna) |
| <code=java> |
| package MachineLearning; |
| |
| |
| import java.util.*; |
| |
| /** |
| * Klasa służy do pokazania sobie jak jest drzewo zbudowane |
| * @author Angello |
| * |
| */ |
| public class ShowedNode |
| { |
| public String TestName; |
| public Integer[] P; |
| HashMap<Integer, ShowedNode> m_nodes = new HashMap<Integer, ShowedNode>(); |
| public Integer Category; |
| private static Integer counter = 0; |
| |
| /** |
| * Dodaje kolejny węzeł lub liść poniżej aktualnego węzła |
| * @param key |
| * @param node |
| */ |
| public void addNode(Integer key, ShowedNode node) |
| { |
| m_nodes.put(key, node); |
| } |
| |
| /** |
| * Zapisuje do pliku jak zbudować drzewo w programie graphviz |
| * @param sw |
| * @return |
| */ |
| public String getGraphvizName(WriteFile sw) |
| { |
| String nodeName; |
| String tempChildName; |
| |
| if (m_nodes.size() == 0) // Tylko liść |
| { |
| nodeName = (++counter).toString(); |
| sw.writeLine( nodeName + " [label=\"" + Thermostat.values()[(this.Category)].toString() + "\", shape = record];"); |
| } |
| else |
| { |
| nodeName = (++counter).toString(); |
| sw.writeLine( nodeName + " [label=\"" + this.TestName + "\", shape = ellipse];"); |
| for (Integer key : m_nodes.keySet()) // Dla wszystkich wyników testu |
| { |
| tempChildName = m_nodes.get(key).getGraphvizName(sw); // Wywołanie dla potomnych |
| tempChildName = tempChildName + ""; |
| sw.writeLine(nodeName + " -> " + tempChildName + "[ label = " + key + " ];"); // bieżący node -> nazwa którą dostałem |
| } |
| } |
| |
| return nodeName; |
| } |
| } |
| |
| |
| </code> |