Package org.graph4j.spanning
Class WeightedSpanningTreeIterator
java.lang.Object
org.graph4j.spanning.WeightedSpanningTreeIterator
- All Implemented Interfaces:
Iterator<Collection<Edge>>
- Direct Known Subclasses:
MinimumSpanningTreeIterator
Iterates over all spanning trees of a graph, in ascending or descending order
by their weight.
The iterator returns the collection of edges of a spanning tree, which can be
used to create the actual tree with the method
Graph.subgraph(java.util.Collection).
See: G.K. Janssens, K. Sörensen, An algorithm to generate all spanning trees
in order of increasing cost, Pesquisa Operacional, 2005-08, Vol. 25 (2), p.
219-229, https://www.scielo.br/j/pope/a/XHswBwRwJyrfL88dmMwYNWp/?lang=en- Author:
- Cristian Frăsinaru
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Edge[]protected final Graphprotected final intprotected final PriorityQueue<WeightedSpanningTreeIterator.Part> -
Constructor Summary
ConstructorsConstructorDescriptionCreates an iterator over the spanning trees of the specified graph, in ascending order of their weight.WeightedSpanningTreeIterator(Graph graph, boolean ascending) Creates an iterator over the spanning trees of the specified graph, in ascending or descending order by their weight. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Field Details
-
graph
-
numVertices
protected final int numVertices -
edges
-
queue
-
-
Constructor Details
-
WeightedSpanningTreeIterator
Creates an iterator over the spanning trees of the specified graph, in ascending order of their weight.- Parameters:
graph- the input graph.
-
WeightedSpanningTreeIterator
Creates an iterator over the spanning trees of the specified graph, in ascending or descending order by their weight.- Parameters:
graph- the input graph.ascending-trueif the spanning trees are returned in ascending order by their weight,falseif the order should be descending.
-
-
Method Details
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<Collection<Edge>>
-
next
- Specified by:
nextin interfaceIterator<Collection<Edge>>
-
refine
-