List of usage examples for com.google.common.graph ValueGraph edges
@Override Set<EndpointPair<N>> edges();
From source file:io.acoia.graphs.MinimumSpanningTree.java
/** * Sorts the edges of the provided ValueGraph and then calls kruskals(ValueGraph<N, E> g, * List<EndpointPair<N>> sortedEdges). Due to the need to sort the edges this method requires edge * values in the graph to implement Comparable. * /* w w w . j av a2 s . com*/ * Due to the need to sort this method sorts the edges (O(E log(E))) before calling Kruskal's (O(E (V))) . */ public static <N, E extends Comparable<E>> ValueGraph<N, E> kruskals(ValueGraph<N, E> g) { Set<EndpointPair<N>> edges = g.edges(); List<EndpointPair<N>> sortedEdges = edges.stream().sorted((ep1, ep2) -> g .edgeValue(ep1.nodeU(), ep1.nodeV()).compareTo(g.edgeValue(ep2.nodeU(), ep2.nodeV()))) .collect(Collectors.toList()); return kruskals(g, sortedEdges); }