/** * Create a new graph tree * * @param label The name of the tree * @param root The name of the first element in the tree * @return a graph tree */ private GraphTree addTree(String label, String root) { if(!treeMap.containsKey(label)) { GraphTree newTree = GraphTree.makeGraph(root); treeMap.put(label, newTree); return newTree; } return null; }
public GraphTree getGraphTree() { GraphTree gt = GraphTree.makeGraph(name); for(Map.Entry<String, List<String>> e: paths.entrySet()) { String id = e.getKey(); List<String> path = e.getValue(); GraphNode gn = hostlist.getGraphById(id.hashCode()); if(gn == null) { logger.warn(jrds.Util.delayedFormatString("Graph not found for %s: %s", name, id)); continue; } gt.addGraphByPath(path, gn); } return gt; } }
@Test public void test2() { GraphTree gt1 = GraphTree.makeGraph("root"); gt1.addPath("a", "b"); Assert.assertNotNull("Graph node not found", gt1.getByPath("root", "a", "b")); }
@Test public void test1() { GraphTree gt1 = GraphTree.makeGraph("root"); GraphNode gn = new MockGraph(); gt1.addGraphByPath(doList("a", "b", gn.getName()), gn); Assert.assertNotNull("Graph node not found", gt1.getByPath("root", "a", "b")); }