Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- new Graph([
- A: [B: 5, H: 2],
- B: [A: 5, C: 7],
- C: [B: 7, D: 3, G: 4],
- D: [C: 20, E: 4],
- E: [F: 5],
- F: [G: 6],
- G: [C: 4],
- H: [G: 3]
- ])
- */
- /*
- private static final Graph<String> COMPLEX_GRAPH = new Graph<>(Map.of(
- "A", Map.of("B", 5, "H", 2),
- "B", Map.of("A", 5, "C", 7),
- "C", Map.of("B", 7, "D", 3, "G", 4),
- "D", Map.of("C", 20, "E", 4),
- "E", Map.of("F", 5),
- "F", Map.of("G", 6),
- "G", Map.of("C", 4),
- "H", Map.of("G", 3)
- ));
- */
- private static final Graph<String> COMPLEX_GRAPH;
- static {
- var fromA = new LinkedHashMap<String, Number>();
- fromA.put("B", 5);
- fromA.put("H", 2);
- var fromB = new LinkedHashMap<String, Number>();
- fromB.put("A", 5);
- fromB.put("C", 7);
- var fromC = new LinkedHashMap<String, Number>();
- fromC.put("B", 7);
- fromC.put("D", 3);
- fromC.put("G", 4);
- var fromD = new LinkedHashMap<String, Number>();
- fromD.put("C", 20);
- fromD.put("E", 4);
- var fromE = new LinkedHashMap<String, Number>();
- fromE.put("F", 5);
- var fromF = new LinkedHashMap<String, Number>();
- fromF.put("G", 6);
- var fromG = new LinkedHashMap<String, Number>();
- fromG.put("C", 4);
- var fromH = new LinkedHashMap<String, Number>();
- fromH.put("G", 3);
- var nodes = new LinkedHashMap<String, Map<String, Number>>();
- nodes.put("A", fromA);
- nodes.put("B", fromB);
- nodes.put("C", fromC);
- nodes.put("D", fromD);
- nodes.put("E", fromE);
- nodes.put("F", fromF);
- nodes.put("G", fromG);
- nodes.put("H", fromH);
- COMPLEX_GRAPH = new Graph<>(nodes);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement