Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

EdgeIndependentSpanningTrees.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <ogdf/basic/EdgeArray.h>
35 #include <ogdf/basic/List.h>
36 
37 #include <set>
38 #include <vector>
39 
40 namespace ogdf {
41 
52 public:
62 
64  EdgeIndependentSpanningTrees() : m_G {nullptr}, m_root {nullptr} { }
65 
68  : EdgeIndependentSpanningTrees {G, G.firstNode()} { }
69 
71  EdgeIndependentSpanningTrees(const Graph& G, node root) : m_G {&G}, m_root {root} { }
72 
74  ~EdgeIndependentSpanningTrees() = default;
75 
77  bool findOne(unsigned int k, Solution& f) const;
78 
80  List<Solution> findAll(unsigned int k) const;
81 
83  List<Solution> findAllPerm(unsigned int k) const;
84 
86  const Graph* getGraph() const { return m_G; }
87 
89  void setGraph(const Graph& G) {
90  OGDF_ASSERT(!G.empty());
91  m_G = &G;
92  }
93 
95  node getRoot() const { return m_root; }
96 
98  void setRoot(node root) { m_root = root; }
99 
100 protected:
103  void findDo(unsigned int k, std::function<bool(Solution&)> func) const;
104 
105 private:
106  const Graph* m_G;
108 
110  bool checkOnePermUnequal(const Solution& f1, const Solution& f2,
111  const std::vector<unsigned int>& perm) const;
112 
114  bool checkNewTree(const Solution& f1, const Solution& f2, unsigned int k) const;
115 
117  bool createParentRel(const Solution& f, unsigned int j, NodeArray<adjEntry>& parent) const;
118 
120  bool checkIndependence(const std::vector<NodeArray<adjEntry>>& parents, unsigned int k) const;
121 
123  bool checkTwoPathIndependence(const std::vector<NodeArray<adjEntry>>& parents, node v,
124  unsigned int p1, unsigned int p2) const;
125 
127  bool iterate(Solution& f, unsigned int j, unsigned int k) const;
128 
130  bool isFinished(const Solution& f, unsigned int k) const;
131 
133  unsigned int createVals(const Solution& f, unsigned int k, std::vector<edge>& tree) const;
134 
136  void clearTree(Solution& f, unsigned int j) const;
137 
139  bool nextSpanningTree(unsigned int& t, std::vector<edge>& tree) const;
140 
142  bool pathExists(const std::vector<edge>& tree, node v1, node v2, unsigned int t) const;
143 
145  bool isInSubGraph(const std::vector<edge>& sub, const edge& e, unsigned int t) const;
146 
148  bool createInitialSpanningTrees(Solution& f, unsigned int k) const;
149 
150  bool insertNewTree(Solution& f, unsigned int t, unsigned int j, std::vector<edge>& tree) const;
151 
153  bool findAndInsertNextTree(Solution& f, unsigned int& t, unsigned int j,
154  std::vector<edge>& tree) const;
155 };
156 
157 }
ogdf
The namespace for all OGDF objects.
Definition: AugmentationModule.h:36
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:54
ogdf::EdgeIndependentSpanningTrees::m_G
const Graph * m_G
The associated graph.
Definition: EdgeIndependentSpanningTrees.h:106
ogdf::EdgeIndependentSpanningTrees::setGraph
void setGraph(const Graph &G)
Sets the associated graph.
Definition: EdgeIndependentSpanningTrees.h:89
ogdf::EdgeIndependentSpanningTrees::m_root
node m_root
The associated root node.
Definition: EdgeIndependentSpanningTrees.h:107
ogdf::EdgeIndependentSpanningTrees::setRoot
void setRoot(node root)
Sets the associated root node.
Definition: EdgeIndependentSpanningTrees.h:98
ogdf::EdgeIndependentSpanningTrees::getGraph
const Graph * getGraph() const
Returns a pointer to the associated graph.
Definition: EdgeIndependentSpanningTrees.h:86
EdgeArray.h
Declaration and implementation of EdgeArray class.
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:651
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:862
ogdf::EdgeIndependentSpanningTrees::EdgeIndependentSpanningTrees
EdgeIndependentSpanningTrees(const Graph &G, node root)
Creates an instance of edge-independent spanning tree and sets the graph and root node.
Definition: EdgeIndependentSpanningTrees.h:71
OGDF_EXPORT
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:101
ogdf::EdgeElement
Class for the representation of edges.
Definition: Graph_d.h:356
List.h
Declaration of doubly linked lists and iterators.
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:233
ogdf::EdgeIndependentSpanningTrees::EdgeIndependentSpanningTrees
EdgeIndependentSpanningTrees(const Graph &G)
Creates an instance of edge-independent spanning tree and sets the graph.
Definition: EdgeIndependentSpanningTrees.h:67
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:709
ogdf::EdgeIndependentSpanningTrees::EdgeIndependentSpanningTrees
EdgeIndependentSpanningTrees()
Creates an instance of edge-independent spanning tree withou associated graph and root.
Definition: EdgeIndependentSpanningTrees.h:64
ogdf::EdgeIndependentSpanningTrees
Calculates k edge-independent spanning trees of a graph.
Definition: EdgeIndependentSpanningTrees.h:51
ogdf::EdgeIndependentSpanningTrees::getRoot
node getRoot() const
Returns the associated root node.
Definition: EdgeIndependentSpanningTrees.h:95