Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

EdgeIndependentSpanningTrees.h
Go to the documentation of this file.
1 
32 #pragma once
33 
34 #include <vector>
35 #include <set>
36 #include <ogdf/basic/List.h>
37 #include <ogdf/basic/EdgeArray.h>
38 
39 namespace ogdf {
40 
49 public:
59 
61  EdgeIndependentSpanningTrees() : m_G{nullptr}, m_root{nullptr} {}
62 
65 
67  EdgeIndependentSpanningTrees(const Graph &G, node root) : m_G{&G}, m_root{root} {}
68 
70  ~EdgeIndependentSpanningTrees() = default;
71 
73  bool findOne(unsigned int k, Solution &f) const;
74 
76  List<Solution> findAll(unsigned int k) const;
77 
79  List<Solution> findAllPerm(unsigned int k) const;
80 
82  const Graph *getGraph() const {
83  return m_G;
84  }
85 
87  void setGraph(const Graph &G) {
88  OGDF_ASSERT(!G.empty());
89  m_G = &G;
90  }
91 
93  node getRoot() const {
94  return m_root;
95  }
96 
98  void setRoot(node root) {
99  m_root = root;
100  }
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, const std::vector<unsigned int> &perm) const;
113 
115  bool checkNewTree(const Solution &f1, const Solution &f2, unsigned int k) const;
116 
118  bool createParentRel(const Solution &f, unsigned int j, NodeArray<adjEntry> &parent) const;
119 
121  bool checkIndependence(const std::vector<NodeArray<adjEntry>> &parents, unsigned int k) const;
122 
124  bool checkTwoPathIndependence(const std::vector<NodeArray<adjEntry>> &parents, node v, 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, std::vector<edge> &tree) const;
154 };
155 
156 }
EdgeIndependentSpanningTrees(const Graph &G, node root)
Creates an instance of edge-independent spanning tree and sets the graph and root node...
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:492
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
const Graph * getGraph() const
Returns a pointer to the associated graph.
node firstNode() const
Returns the first node in the list of all nodes.
Definition: Graph_d.h:618
EdgeIndependentSpanningTrees()
Creates an instance of edge-independent spanning tree withou associated graph and root...
void setRoot(node root)
Sets the associated root node.
EdgeIndependentSpanningTrees(const Graph &G)
Creates an instance of edge-independent spanning tree and sets the graph.
Dynamic arrays indexed with edges.
Definition: EdgeArray.h:112
Dynamic arrays indexed with nodes.
Definition: Graph_d.h:438
Declaration and implementation of EdgeArray class.
void setGraph(const Graph &G)
Sets the associated graph.
Doubly linked lists (maintaining the length of the list).
Definition: List.h:40
Class for the representation of edges.
Definition: Graph_d.h:292
Class for the representation of nodes.
Definition: Graph_d.h:169
const Graph * m_G
The associated graph.
Calculates k edge-independent spanning trees of a graph.
node getRoot() const
Returns the associated root node.
for every hyperedge e a minimal subcubic tree connecting all hypernodes incident with e together is a...
The namespace for all OGDF objects.
bool empty() const
Returns true iff the graph is empty, i.e., contains no nodes.
Definition: Graph_d.h:595
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
Definition: basic.h:41
Declaration of doubly linked lists and iterators.