@Test public void test_graph_Acyc_multi_roots() throws Exception { final File file = PropertiesUtils.getResourceFile("ingest_tree_multi_roots.json"); final JsonNode json = JsonHandler.getFromFile(file); final Graph g = new Graph(json); assertNotNull(g.getGraphWithLongestPaths()); assertTrue(g.getGraphWithLongestPaths().size() == 2); Set<String> level_0 = g.getGraphWithLongestPaths().get(0); assertTrue(level_0.contains("ID10")); assertTrue(level_0.contains("ID4")); Set<String> level_1 = g.getGraphWithLongestPaths().get(1); assertTrue(level_1.contains("ID14")); assertTrue(level_1.contains("ID8")); }
public Map<Integer, Set<String>> getGraphWithLongestPaths() { longestsPath = new HashMap<>(); Map<Integer, Integer> paths = findAllLongestsPath(roots); if (paths != null) { for (final Map.Entry<Integer, Integer> e : paths.entrySet()) { final Integer unitId = e.getKey(); final Integer level = e.getValue(); if (longestsPath.containsKey(level) && longestsPath.get(level) != null) { longestsPath.get(level).add(indexMapping.get(unitId)); } else { final Set<String> units = new HashSet<>(); units.add(indexMapping.get(unitId)); longestsPath.put(level, units); } } } paths = null; return longestsPath; }
Graph { public Map<Integer, Set<String>> getGraphWithLongestPaths() { longestsPath = new HashMap<>(); Map<Integer, Integer> paths = findAllLongestsPath(roots); if (paths != null) { for (final Map.Entry<Integer, Integer> e : paths.entrySet()) { final Integer unitId = e.getKey(); final Integer level = e.getValue(); if (longestsPath.containsKey(level) && longestsPath.get(level) != null) { longestsPath.get(level).add(indexMapping.get(unitId)); } else { final Set<String> units = new HashSet<>(); units.add(indexMapping.get(unitId)); longestsPath.put(level, units); } } } paths = null; return longestsPath; } }
Graph { public Map<Integer, Set<String>> getGraphWithLongestPaths() { longestsPath = new HashMap<>(); Map<Integer, Integer> paths = findAllLongestsPath(roots); if (paths != null) { for (final Map.Entry<Integer, Integer> e : paths.entrySet()) { final Integer unitId = e.getKey(); final Integer level = e.getValue(); if (longestsPath.containsKey(level) && longestsPath.get(level) != null) { longestsPath.get(level).add(indexMapping.get(unitId)); } else { final Set<String> units = new HashSet<>(); units.add(indexMapping.get(unitId)); longestsPath.put(level, units); } } } paths = null; return longestsPath; } Graph(JsonNode jsonGraph); }
Graph { public Map<Integer, Set<String>> getGraphWithLongestPaths() { longestsPath = new HashMap<>(); Map<Integer, Integer> paths = findAllLongestsPath(roots); if (paths != null) { for (final Map.Entry<Integer, Integer> e : paths.entrySet()) { final Integer unitId = e.getKey(); final Integer level = e.getValue(); if (longestsPath.containsKey(level) && longestsPath.get(level) != null) { longestsPath.get(level).add(indexMapping.get(unitId)); } else { final Set<String> units = new HashSet<>(); units.add(indexMapping.get(unitId)); longestsPath.put(level, units); } } } paths = null; return longestsPath; } Graph(JsonNode jsonGraph); Map<Integer, Set<String>> getGraphWithLongestPaths(); }
Graph { public Map<Integer, Set<String>> getGraphWithLongestPaths() { longestsPath = new HashMap<>(); Map<Integer, Integer> paths = findAllLongestsPath(roots); if (paths != null) { for (final Map.Entry<Integer, Integer> e : paths.entrySet()) { final Integer unitId = e.getKey(); final Integer level = e.getValue(); if (longestsPath.containsKey(level) && longestsPath.get(level) != null) { longestsPath.get(level).add(indexMapping.get(unitId)); } else { final Set<String> units = new HashSet<>(); units.add(indexMapping.get(unitId)); longestsPath.put(level, units); } } } paths = null; return longestsPath; } Graph(JsonNode jsonGraph); Map<Integer, Set<String>> getGraphWithLongestPaths();  }