Interface MinimumDirectedSpanningTree
- All Known Implementing Classes:
MinimumDirectedSpanningTreeAbstract
,MinimumDirectedSpanningTreeTarjan
A spanning tree in directed graph is defined similarly to a spanning tree in undirected graph, but the 'spanning
tree' does not yield a strongly connected graph, rather a tree in which all the vertices are reachable from the root.
Note that differing from the undirected MinimumSpanningTree
, the root is given as part of the input, and the
result spanning tree will span only the vertices reachable from the root with a single tree, and not a forest.
Use newInstance()
to get a default implementation of this interface.
- Author:
- Barak Ugav
-
Method Summary
Modifier and TypeMethodDescription<V,
E> MinimumSpanningTree.Result <V, E> computeMinimumDirectedSpanningTree
(Graph<V, E> g, WeightFunction<E> w, V root) Compute a minimum directed spanning tree (MDST) in a directed graph, rooted at the given vertex.static MinimumDirectedSpanningTree
Create a new directed-MST algorithm object.
-
Method Details
-
computeMinimumDirectedSpanningTree
<V,E> MinimumSpanningTree.Result<V,E> computeMinimumDirectedSpanningTree(Graph<V, E> g, WeightFunction<E> w, V root) Compute a minimum directed spanning tree (MDST) in a directed graph, rooted at the given vertex.Note that the returned spanning tree is a single tree that span only the vertices reachable from the root, and not a forest that span the whole graph.
If
g
is anIntGraph
, aMinimumSpanningTree.IResult
object will be returned. In that case, its better to pass aIWeightFunction
asw
to avoid boxing/unboxing.- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- a directed graphw
- an edge weight functionroot
- vertex in the graph the spanning tree will be rooted from- Returns:
- all edges composing the spanning tree
- Throws:
IllegalArgumentException
- ifg
is not directed
-
newInstance
Create a new directed-MST algorithm object.This is the recommended way to instantiate a new
MinimumDirectedSpanningTree
object.- Returns:
- a default implementation of
MinimumDirectedSpanningTree
-