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/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 
42 namespace ogdf {
43 
54 public:
64 
66  EdgeIndependentSpanningTrees() : m_G {nullptr}, m_root {nullptr} { }
67 
70  : EdgeIndependentSpanningTrees {G, G.firstNode()} { }
71 
73  EdgeIndependentSpanningTrees(const Graph& G, node root) : m_G {&G}, m_root {root} { }
74 
76  ~EdgeIndependentSpanningTrees() = default;
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 
102 protected:
105  void findDo(unsigned int k, std::function<bool(Solution&)> func) const;
106 
107 private:
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 }
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
Graph.h
Includes declaration of graph class.
OGDF_ASSERT
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:66
ogdf::EdgeIndependentSpanningTrees::m_G
const Graph * m_G
The associated graph.
Definition: EdgeIndependentSpanningTrees.h:108
ogdf::EdgeIndependentSpanningTrees::setGraph
void setGraph(const Graph &G)
Sets the associated graph.
Definition: EdgeIndependentSpanningTrees.h:91
ogdf::EdgeIndependentSpanningTrees::m_root
node m_root
The associated root node.
Definition: EdgeIndependentSpanningTrees.h:109
ogdf::EdgeIndependentSpanningTrees::setRoot
void setRoot(node root)
Sets the associated root node.
Definition: EdgeIndependentSpanningTrees.h:100
ogdf::EdgeIndependentSpanningTrees::getGraph
const Graph * getGraph() const
Returns a pointer to the associated graph.
Definition: EdgeIndependentSpanningTrees.h:88
ogdf::internal::GraphRegisteredArray
RegisteredArray for nodes, edges and adjEntries of a graph.
Definition: Graph_d.h:658
ogdf::Graph
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:869
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:73
basic.h
Basic declarations, included by all source files.
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:363
List.h
Declaration of doubly linked lists and iterators.
ogdf::NodeElement
Class for the representation of nodes.
Definition: Graph_d.h:240
ogdf::EdgeIndependentSpanningTrees::EdgeIndependentSpanningTrees
EdgeIndependentSpanningTrees(const Graph &G)
Creates an instance of edge-independent spanning tree and sets the graph.
Definition: EdgeIndependentSpanningTrees.h:69
ogdf::internal::EdgeArrayBase2
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
Definition: Graph_d.h:716
ogdf::EdgeIndependentSpanningTrees::EdgeIndependentSpanningTrees
EdgeIndependentSpanningTrees()
Creates an instance of edge-independent spanning tree withou associated graph and root.
Definition: EdgeIndependentSpanningTrees.h:66
ogdf::EdgeIndependentSpanningTrees
Calculates k edge-independent spanning trees of a graph.
Definition: EdgeIndependentSpanningTrees.h:53
ogdf::EdgeIndependentSpanningTrees::getRoot
node getRoot() const
Returns the associated root node.
Definition: EdgeIndependentSpanningTrees.h:97