Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
EdgeIndependentSpanningTrees.h
Go to the documentation of this file.
1
32#pragma once
33
34#include <ogdf/basic/Graph.h>
35#include <ogdf/basic/List.h>
36#include <ogdf/basic/basic.h>
37
38#include <functional>
39#include <utility>
40#include <vector>
41
42namespace ogdf {
43
54public:
64
66 EdgeIndependentSpanningTrees() : m_G {nullptr}, m_root {nullptr} { }
67
71
73 EdgeIndependentSpanningTrees(const Graph& G, node root) : m_G {&G}, m_root {root} { }
74
77
79 bool findOne(unsigned int k, Solution& f) const;
80
82 List<Solution> findAll(unsigned int k) const;
83
85 List<Solution> findAllPerm(unsigned int k) const;
86
88 const Graph* getGraph() const { return m_G; }
89
91 void setGraph(const Graph& G) {
92 OGDF_ASSERT(!G.empty());
93 m_G = &G;
94 }
95
97 node getRoot() const { return m_root; }
98
100 void setRoot(node root) { m_root = root; }
101
102protected:
105 void findDo(unsigned int k, std::function<bool(Solution&)> func) const;
106
107private:
108 const Graph* m_G;
110
112 bool checkOnePermUnequal(const Solution& f1, const Solution& f2,
113 const std::vector<unsigned int>& perm) const;
114
116 bool checkNewTree(const Solution& f1, const Solution& f2, unsigned int k) const;
117
119 bool createParentRel(const Solution& f, unsigned int j, NodeArray<adjEntry>& parent) const;
120
122 bool checkIndependence(const std::vector<NodeArray<adjEntry>>& parents, unsigned int k) const;
123
125 bool checkTwoPathIndependence(const std::vector<NodeArray<adjEntry>>& parents, node v,
126 unsigned int p1, unsigned int p2) const;
127
129 bool iterate(Solution& f, unsigned int j, unsigned int k) const;
130
132 bool isFinished(const Solution& f, unsigned int k) const;
133
135 unsigned int createVals(const Solution& f, unsigned int k, std::vector<edge>& tree) const;
136
138 void clearTree(Solution& f, unsigned int j) const;
139
141 bool nextSpanningTree(unsigned int& t, std::vector<edge>& tree) const;
142
144 bool pathExists(const std::vector<edge>& tree, node v1, node v2, unsigned int t) const;
145
147 bool isInSubGraph(const std::vector<edge>& sub, const edge& e, unsigned int t) const;
148
150 bool createInitialSpanningTrees(Solution& f, unsigned int k) const;
151
152 bool insertNewTree(Solution& f, unsigned int t, unsigned int j, std::vector<edge>& tree) const;
153
155 bool findAndInsertNextTree(Solution& f, unsigned int& t, unsigned int j,
156 std::vector<edge>& tree) const;
157};
158
159}
Includes declaration of graph class.
Declaration of doubly linked lists and iterators.
Basic declarations, included by all source files.
Class for the representation of edges.
Definition Graph_d.h:364
Calculates k edge-independent spanning trees of a graph.
bool insertNewTree(Solution &f, unsigned int t, unsigned int j, std::vector< edge > &tree) const
bool checkTwoPathIndependence(const std::vector< NodeArray< adjEntry > > &parents, node v, unsigned int p1, unsigned int p2) const
Checks two paths for independence.
node getRoot() const
Returns the associated root node.
bool findAndInsertNextTree(Solution &f, unsigned int &t, unsigned int j, std::vector< edge > &tree) const
Iterates using nextSpanningTree until insertNewTree succeeds.
bool nextSpanningTree(unsigned int &t, std::vector< edge > &tree) const
Calculates the next spanning tree after tree using backtracking.
bool findOne(unsigned int k, Solution &f) const
Finds k edge-independent spanning trees in graph m_G rooted at m_root.
bool isInSubGraph(const std::vector< edge > &sub, const edge &e, unsigned int t) const
Checks whether e is in the subgraph.
EdgeIndependentSpanningTrees()
Creates an instance of edge-independent spanning tree withou associated graph and root.
const Graph * getGraph() const
Returns a pointer to the associated graph.
bool checkIndependence(const std::vector< NodeArray< adjEntry > > &parents, unsigned int k) const
Checks k spanning trees for independence.
EdgeIndependentSpanningTrees(const Graph &G)
Creates an instance of edge-independent spanning tree and sets the graph.
bool isFinished(const Solution &f, unsigned int k) const
Checks whether iteration is finished.
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 ...
void setGraph(const Graph &G)
Sets the associated graph.
bool createInitialSpanningTrees(Solution &f, unsigned int k) const
Creates first k spanning trees.
const Graph * m_G
The associated graph.
List< Solution > findAllPerm(unsigned int k) const
Finds all k edge-independent spanning trees in graph m_G rooted at m_root, including permutations.
List< Solution > findAll(unsigned int k) const
Finds all k edge-independent spanning trees in graph m_G rooted at m_root.
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...
void clearTree(Solution &f, unsigned int j) const
Clears the j-th Tree from f.
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.
~EdgeIndependentSpanningTrees()=default
Destructor.
unsigned int createVals(const Solution &f, unsigned int k, std::vector< edge > &tree) const
Creates the values needed for nextSpanningTree from f.
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.
bool iterate(Solution &f, unsigned int j, unsigned int k) const
Iterates over all subgraphs.
void setRoot(node root)
Sets the associated root node.
EdgeIndependentSpanningTrees(const Graph &G, node root)
Creates an instance of edge-independent spanning tree and sets the graph and root node.
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.
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:866
Doubly linked lists (maintaining the length of the list).
Definition List.h:1451
Class for the representation of nodes.
Definition Graph_d.h:241
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition Graph_d.h:717
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition Graph_d.h:659
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF dynamic library (shared object / DLL),...
Definition config.h:117
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition basic.h:52
The namespace for all OGDF objects.