/** * The only way to get a new graph * * @param root the graph's root name * @return */ public static GraphTree makeGraph(String root) { GraphTree rootNode = new GraphTree(root); rootNode.pathsMap = new HashMap<Integer, GraphTree>(); rootNode.pathsMap.put(rootNode.getPath().hashCode(), rootNode); return rootNode; }
synchronized private void addChild(String childName) { if(!childsMap.containsKey(childName)) { GraphTree newChild = new GraphTree(childName); childsMap.put(childName, newChild); newChild.parent = this; newChild.pathsMap = pathsMap; pathsMap.put(newChild.getPath().hashCode(), newChild); } }