From 01cb9f504c860bc1c037a44f3a76bf342a293d46 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Tue, 22 Mar 2016 12:28:35 -0400 Subject: General formatting cleanup and documentation update --- BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/graph') diff --git a/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java b/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java index 3b54b27..2f2ac04 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java +++ b/BJC-Utils2/src/main/java/bjc/utils/graph/Graph.java @@ -35,7 +35,7 @@ public class Graph { * Create a new graph */ public Graph() { - graph = new HashMap>(); + graph = new HashMap<>(); } /** @@ -121,20 +121,18 @@ public class Graph { * Uses Prim's algorothm to calculate a MST for the graph. If the graph * is non-connected, this will lead to unpredictable results. * - * @param graph - * a connected graph. * @return a list of edges that constitute the MST */ public List> getMinSpanTree() { // Set of all of the currently available edges - Queue> availEdges = new PriorityQueue>(10, + Queue> availEdges = new PriorityQueue<>(10, (e1, e2) -> e1.getDistance() - e2.getDistance()); // The MST of the graph - List> minEdges = new ArrayList>(); + List> minEdges = new ArrayList<>(); // The set of all of the visited vertices. - Set visited = new HashSet(); + Set visited = new HashSet<>(); // Start at the initial vertex and visit it IHolder src = new GenHolder<>(getInitial()); @@ -146,12 +144,11 @@ public class Graph { forAllEdgesMatchingAt(src.unwrap(vl -> vl), (tgt, weight) -> !visited.contains(tgt), - (tgt, weight) -> availEdges.add(new Edge( + (tgt, weight) -> availEdges.add(new Edge<>( src.unwrap(vl -> vl), tgt, weight))); // Get the edge with the minimum distance - IHolder> minEdge = new GenHolder<>( - availEdges.poll()); + IHolder> minEdge = new GenHolder<>(availEdges.poll()); // Only consider edges where we haven't visited the target of // the edge @@ -240,6 +237,7 @@ public class Graph { /** * Create a graph from a list of edges + * @param The type of data stored in the edges * * @param edges * The list of edges to build from -- cgit v1.2.3