Interface SteinerTreeAlgo
-
public interface SteinerTreeAlgo
An algorithm for the Steiner tree problem.The Steiner tree problem is a generalization of the minimum spanning tree problem. Given a graph \(G=(V,E)\) and a set of terminals vertices \(T \subseteq V\), the Steiner tree problem is to find a minimum weight tree that spans all the terminals. The tree may contain additional vertices that are not terminals, which are usually called Steiner vertices. The Steiner tree problem is NP-hard, therefore algorithms implementing this interface are heuristics, and do not guarantee to find the optimal solution, only a solution with bounded approximation factor.
Use
newInstance()
to get a default implementation of this interface. A builder obtained vianewBuilder()
may support different options to obtain different implementations.- Author:
- Barak Ugav
- See Also:
- Wikipedia,
MinimumSpanningTree
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
SteinerTreeAlgo.Builder
A builder forSteinerTreeAlgo
objects.static interface
SteinerTreeAlgo.IResult
A result object forSteinerTreeAlgo
computation forIntGraph
.static interface
SteinerTreeAlgo.Result<V,E>
A result object forSteinerTreeAlgo
computation.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <V,E>
SteinerTreeAlgo.Result<V,E>computeSteinerTree(Graph<V,E> g, WeightFunction<E> w, Collection<V> terminals)
Compute the minimum Steiner tree of a given graph.static <V,E>
booleanisSteinerTree(Graph<V,E> g, Collection<V> terminals, Collection<E> edges)
Check whether a given set of edges is a valid Steiner tree for a given graph and terminals.static SteinerTreeAlgo.Builder
newBuilder()
Create a new Steiner tree algorithm builder.static SteinerTreeAlgo
newInstance()
Create a new Steiner tree algorithm object.
-
-
-
Method Detail
-
computeSteinerTree
<V,E> SteinerTreeAlgo.Result<V,E> computeSteinerTree(Graph<V,E> g, WeightFunction<E> w, Collection<V> terminals)
Compute the minimum Steiner tree of a given graph.The algorithm with search for the minimum Steiner tree that spans all the terminals with respect to the given edge weight function. The tree may contain additional vertices that are not terminals.
If
g
is anIntGraph
, aSteinerTreeAlgo.IResult
object will be returned. In that case, its better to pass aIWeightFunction
asw
, andIntCollection
asterminals
to avoid boxing/unboxing.- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- a graphw
- an edge weight functionterminals
- a set of terminals vertices- Returns:
- a result object containing all the edges of the computed tree
-
isSteinerTree
static <V,E> boolean isSteinerTree(Graph<V,E> g, Collection<V> terminals, Collection<E> edges)
Check whether a given set of edges is a valid Steiner tree for a given graph and terminals.A set of edges is a valid Steiner tree if it spans all the terminals, does not contain any cycles, form a single connected components, and there are no non-terminal leaves in the tree.
If
g
is anIntGraph
, its better to pass aIntCollection
asterminals
andedges
to avoid boxing/unboxing.- Type Parameters:
V
- the vertices typeE
- the edges type- Parameters:
g
- a graphterminals
- a set of terminals verticesedges
- a set of edges- Returns:
true
if the given set of edges is a valid Steiner tree
-
newInstance
static SteinerTreeAlgo newInstance()
Create a new Steiner tree algorithm object.This is the recommended way to instantiate a new
SteinerTreeAlgo
object. TheSteinerTreeAlgo.Builder
might support different options to obtain different implementations.- Returns:
- a default implementation of
SteinerTreeAlgo
-
newBuilder
static SteinerTreeAlgo.Builder newBuilder()
Create a new Steiner tree algorithm builder.Use
newInstance()
for a default implementation.- Returns:
- a new builder that can build
SteinerTreeAlgo
objects
-
-