java.lang.Object
org.jhotdraw8.graph.algo.MinimumSpanningTreeAlgo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateForest(@NonNull Collection<VV> vertices) <V,A, C extends Number & Comparable<C>, P extends OrderedPair<V, V>>
@NonNull List<P> findMinimumSpanningTree(@NonNull Collection<V> vertices, @NonNull List<P> orderedEdges, @Nullable List<P> rejectedEdges) Given a set of vertices and a list of arrows ordered by cost, returns the minimum spanning tree.<V,A, C extends Number & Comparable<C>, P extends OrderedPair<V, V>>
@NonNull SimpleMutableDirectedGraph<V, P> findMinimumSpanningTreeGraph(@NonNull Collection<V> vertices, @NonNull List<P> orderedArrows, @Nullable List<P> includedArrows, List<P> rejectedArrows) Given a set of vertices and a list of arrows ordered by cost, returns a builder with the minimum spanning tree.<V,A, C extends Number & Comparable<C>>
@NonNull SimpleMutableDirectedGraph<V, A> findMinimumSpanningTreeGraph(@NonNull DirectedGraph<V, A> graph, @NonNull Function<A, C> costf) Given an undirected graph and a cost function, returns a builder with the minimum spanning tree.<V,A, C extends Number & Comparable<C>>
@NonNull SimpleMutableDirectedGraph<V, A> findMinimumSpanningTreeGraph(@NonNull DirectedGraph<V, A> graph, @NonNull Function3<V, V, A, C> costf) Given an undirected graph and a cost function, returns a builder with the minimum spanning tree.static <VV> void
-
Constructor Details
-
MinimumSpanningTreeAlgo
public MinimumSpanningTreeAlgo()
-
-
Method Details
-
createForest
-
union
-
findMinimumSpanningTree
public <V,A, @NonNull List<P> findMinimumSpanningTreeC extends Number & Comparable<C>, P extends OrderedPair<V, V>> (@NonNull Collection<V> vertices, @NonNull List<P> orderedEdges, @Nullable List<P> rejectedEdges) Given a set of vertices and a list of arrows ordered by cost, returns the minimum spanning tree.Uses Kruskal's algorithm.
- Type Parameters:
P- the pair data type- Parameters:
vertices- a directed graphorderedEdges- list of edges sorted by cost in ascending order (lowest cost first, highest cost last).rejectedEdges- optional, all excluded edges are added to this list, if it is provided.- Returns:
- the arrows that are part of the minimum spanning tree.
-
findMinimumSpanningTreeGraph
public <V,A, @NonNull SimpleMutableDirectedGraph<V,C extends Number & Comparable<C>> A> findMinimumSpanningTreeGraph(@NonNull DirectedGraph<V, A> graph, @NonNull Function<A, C> costf) Given an undirected graph and a cost function, returns a builder with the minimum spanning tree.- Parameters:
graph- the graph. This must be an undirected graph represented as a directed graph with two identical arrows for each edge.costf- the cost function- Returns:
- the graph builder
-
findMinimumSpanningTreeGraph
public <V,A, @NonNull SimpleMutableDirectedGraph<V,C extends Number & Comparable<C>> A> findMinimumSpanningTreeGraph(@NonNull DirectedGraph<V, A> graph, @NonNull Function3<V, V, A, C> costf) Given an undirected graph and a cost function, returns a builder with the minimum spanning tree.- Parameters:
graph- the graph. This must be an undirected graph represented as a directed graph with two identical arrows for each edge.costf- the cost function- Returns:
- the graph builder
-
findMinimumSpanningTreeGraph
public <V,A, @NonNull SimpleMutableDirectedGraph<V,C extends Number & Comparable<C>, P extends OrderedPair<V, V>> P> findMinimumSpanningTreeGraph(@NonNull Collection<V> vertices, @NonNull List<P> orderedArrows, @Nullable List<P> includedArrows, List<P> rejectedArrows) Given a set of vertices and a list of arrows ordered by cost, returns a builder with the minimum spanning tree. This is an undirected graph with an arrow in each direction.- Type Parameters:
P- the pair data type- Parameters:
vertices- the list of verticesorderedArrows- list of arrows sorted by cost in ascending order (lowest cost first, highest cost last)includedArrows- optional, all included arrows are added to this list, if it is provided.rejectedArrows- optional, all excluded arrows are added to this list, if it is provided.- Returns:
- the graph builder
-