Interface SteinerTreeAlgo
-
public interface SteinerTreeAlgoAn 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 interfaceSteinerTreeAlgo.BuilderA builder forSteinerTreeAlgoobjects.static interfaceSteinerTreeAlgo.IResultA result object forSteinerTreeAlgocomputation forIntGraph.static interfaceSteinerTreeAlgo.Result<V,E>A result object forSteinerTreeAlgocomputation.
-
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.BuildernewBuilder()Create a new Steiner tree algorithm builder.static SteinerTreeAlgonewInstance()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
gis anIntGraph, aSteinerTreeAlgo.IResultobject will be returned. In that case, its better to pass aIWeightFunctionasw, andIntCollectionasterminalsto 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
gis anIntGraph, its better to pass aIntCollectionasterminalsandedgesto 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:
trueif 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
SteinerTreeAlgoobject. TheSteinerTreeAlgo.Buildermight 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
SteinerTreeAlgoobjects
-
-