@Test public void test_graph_DAG() throws Exception { final File file = PropertiesUtils.getResourceFile("ingest_acyc_2.json"); final JsonNode json = JsonHandler.getFromFile(file); final Graph g = new Graph(json); assertNotNull(g.getGraphWithLongestPaths()); assertTrue(g.getGraphWithLongestPaths().size() == 3); Set<String> level_0 = g.getGraphWithLongestPaths().get(0); assertNotNull(level_0); assertTrue(level_0.size() == 2); assertTrue(level_0.contains("ID030")); assertTrue(level_0.contains("ID027")); Set<String> level_1 = g.getGraphWithLongestPaths().get(1); assertNotNull(level_1); assertTrue(level_1.size() == 2); assertTrue(level_1.contains("ID031")); assertTrue(level_1.contains("ID028")); Set<String> level_2 = g.getGraphWithLongestPaths().get(2); assertNotNull(level_2); assertTrue(level_2.size() == 3); assertTrue(level_2.contains("ID032")); assertTrue(level_2.contains("ID033")); assertTrue(level_2.contains("ID029")); }
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();  }