Calculates k edge-independent spanning trees of a graph. More...
#include <ogdf/graphalg/EdgeIndependentSpanningTrees.h>
Public Types | |
using | Solution = EdgeArray< std::pair< unsigned int, unsigned int > > |
The solution type. More... | |
Public Member Functions | |
EdgeIndependentSpanningTrees () | |
Creates an instance of edge-independent spanning tree withou associated graph and root. More... | |
EdgeIndependentSpanningTrees (const Graph &G) | |
Creates an instance of edge-independent spanning tree and sets the graph. More... | |
EdgeIndependentSpanningTrees (const Graph &G, node root) | |
Creates an instance of edge-independent spanning tree and sets the graph and root node. More... | |
~EdgeIndependentSpanningTrees ()=default | |
Destructor. More... | |
List< Solution > | findAll (unsigned int k) const |
Finds all k edge-independent spanning trees in graph m_G rooted at m_root. More... | |
List< Solution > | findAllPerm (unsigned int k) const |
Finds all k edge-independent spanning trees in graph m_G rooted at m_root, including permutations. More... | |
bool | findOne (unsigned int k, Solution &f) const |
Finds k edge-independent spanning trees in graph m_G rooted at m_root. More... | |
const Graph * | getGraph () const |
Returns a pointer to the associated graph. More... | |
node | getRoot () const |
Returns the associated root node. More... | |
void | setGraph (const Graph &G) |
Sets the associated graph. More... | |
void | setRoot (node root) |
Sets the associated root node. More... | |
Protected Member Functions | |
void | findDo (unsigned int k, std::function< bool(Solution &)> func) const |
Finds k edge-independent spanning trees and invokes func for each one, The search is stopped if func returns false. More... | |
Private Member Functions | |
bool | checkIndependence (const std::vector< NodeArray< adjEntry >> &parents, unsigned int k) const |
Checks k spanning trees for independence. More... | |
bool | checkNewTree (const Solution &f1, const Solution &f2, unsigned int k) const |
Takes two edge-independent spanning trees and checks for them being unequal under all permutations. More... | |
bool | checkOnePermUnequal (const Solution &f1, const Solution &f2, const std::vector< unsigned int > &perm) const |
Takes two edge-independent spanning trees, permutes one and checks for them being unequal. More... | |
bool | checkTwoPathIndependence (const std::vector< NodeArray< adjEntry >> &parents, node v, unsigned int p1, unsigned int p2) const |
Checks two paths for independence. More... | |
void | clearTree (Solution &f, unsigned int j) const |
Clears the j-th Tree from f . More... | |
bool | createInitialSpanningTrees (Solution &f, unsigned int k) const |
Creates first k spanning trees. More... | |
bool | createParentRel (const Solution &f, unsigned int j, NodeArray< adjEntry > &parent) const |
Creates a parent relation, which for each node in the associated graph contains the adjEntry pointing towards the root node. More... | |
unsigned int | createVals (const Solution &f, unsigned int k, std::vector< edge > &tree) const |
Creates the values needed for nextSpanningTree from f . More... | |
bool | findAndInsertNextTree (Solution &f, unsigned int &t, unsigned int j, std::vector< edge > &tree) const |
Iterates using nextSpanningTree until insertNewTree succeeds. More... | |
bool | insertNewTree (Solution &f, unsigned int t, unsigned int j, std::vector< edge > &tree) const |
bool | isFinished (const Solution &f, unsigned int k) const |
Checks whether iteration is finished. More... | |
bool | isInSubGraph (const std::vector< edge > &sub, const edge &e, unsigned int t) const |
Checks whether e is in the subgraph. More... | |
bool | iterate (Solution &f, unsigned int j, unsigned int k) const |
Iterates over all subgraphs. More... | |
bool | nextSpanningTree (unsigned int &t, std::vector< edge > &tree) const |
Calculates the next spanning tree after tree using backtracking. More... | |
bool | pathExists (const std::vector< edge > &tree, node v1, node v2, unsigned int t) const |
Checks whether v1 and v2 are connected in the subgraph. More... | |
Private Attributes | |
const Graph * | m_G |
The associated graph. More... | |
node | m_root |
The associated root node. More... | |
Calculates k edge-independent spanning trees of a graph.
Given a root note, a set of k edge-independent spanning trees of a graph G is a set of k spanning trees, for which for each two trees the paths from any node to the root are edge-disjoint.
Definition at line 53 of file EdgeIndependentSpanningTrees.h.
using ogdf::EdgeIndependentSpanningTrees::Solution = EdgeArray<std::pair<unsigned int, unsigned int> > |
The solution type.
Since each edge of the associated graph can be contained in up to two different spanning trees (traversed in opposite directions), the first and second members stored for each edge in the solution indicates the IDs of spanning trees containing them (0 meaning none).
Definition at line 63 of file EdgeIndependentSpanningTrees.h.
|
inline |
Creates an instance of edge-independent spanning tree withou associated graph and root.
Definition at line 66 of file EdgeIndependentSpanningTrees.h.
|
inline |
Creates an instance of edge-independent spanning tree and sets the graph.
Definition at line 69 of file EdgeIndependentSpanningTrees.h.
|
inline |
Creates an instance of edge-independent spanning tree and sets the graph and root node.
Definition at line 73 of file EdgeIndependentSpanningTrees.h.
|
default |
Destructor.
|
private |
Checks k spanning trees for independence.
|
private |
Takes two edge-independent spanning trees and checks for them being unequal under all permutations.
|
private |
Takes two edge-independent spanning trees, permutes one and checks for them being unequal.
|
private |
Checks two paths for independence.
|
private |
Clears the j-th Tree from f
.
|
private |
Creates first k spanning trees.
|
private |
Creates a parent relation, which for each node in the associated graph contains the adjEntry pointing towards the root node.
|
private |
Creates the values needed for nextSpanningTree from f
.
|
private |
Iterates using nextSpanningTree until insertNewTree succeeds.
|
protected |
Finds k edge-independent spanning trees and invokes func
for each one, The search is stopped if func
returns false.
bool ogdf::EdgeIndependentSpanningTrees::findOne | ( | unsigned int | k, |
Solution & | f | ||
) | const |
|
inline |
Returns a pointer to the associated graph.
Definition at line 88 of file EdgeIndependentSpanningTrees.h.
|
inline |
Returns the associated root node.
Definition at line 97 of file EdgeIndependentSpanningTrees.h.
|
private |
|
private |
Checks whether iteration is finished.
|
private |
Checks whether e
is in the subgraph.
|
private |
Iterates over all subgraphs.
|
private |
Calculates the next spanning tree after tree using backtracking.
|
private |
Checks whether v1
and v2
are connected in the subgraph.
|
inline |
Sets the associated graph.
Definition at line 91 of file EdgeIndependentSpanningTrees.h.
|
inline |
Sets the associated root node.
Definition at line 100 of file EdgeIndependentSpanningTrees.h.
|
private |
The associated graph.
Definition at line 108 of file EdgeIndependentSpanningTrees.h.
|
private |
The associated root node.
Definition at line 109 of file EdgeIndependentSpanningTrees.h.