CMR  1.3.0
matroid_decomposition.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <set>
4 
5 #include <boost/graph/adjacency_list.hpp>
6 #include <boost/numeric/ublas/matrix.hpp>
7 #include <boost/graph/properties.hpp>
8 
9 #include "matroid_graph.hpp"
10 
11 namespace tu
12 {
13 
19  typedef std::set <int> matroid_element_set;
20 
26  {
27  public:
36 
41  virtual ~decomposed_matroid();
42 
47  virtual bool is_leaf() const = 0;
48 
53  virtual bool is_regular() const = 0;
54 
59  inline const matroid_element_set& elements() const
60  {
61  return _elements;
62  }
63 
68  inline const matroid_element_set& extra_elements() const
69  {
70  return _extra_elements;
71  }
72 
73  private:
74  matroid_element_set _elements;
75  matroid_element_set _extra_elements;
76  };
77 
83  {
84  public:
85 
96  explicit decomposed_matroid_leaf(matroid_graph* graph, matroid_graph* cograph, bool is_R10, const std::set <int>& elements,
98 
103  virtual ~decomposed_matroid_leaf();
104 
109  virtual bool is_leaf() const
110  {
111  return true;
112  }
113 
118  const matroid_graph* graph() const
119  {
120  return _graph;
121  }
122 
127  const matroid_graph* cograph() const
128  {
129  return _cograph;
130  }
131 
136  bool is_R10() const
137  {
138  return _is_R10;
139  }
140 
145  bool is_graphic() const
146  {
147  return graph() != NULL;
148  }
149 
154  bool is_cographic() const
155  {
156  return cograph() != NULL;
157  }
158 
163  virtual bool is_regular() const
164  {
165  return is_graphic() || is_cographic() || is_R10();
166  }
167 
168  protected:
171  bool _is_R10;
172  };
173 
179  {
180  public:
181 
193  explicit decomposed_matroid_separator(decomposed_matroid* first, decomposed_matroid* second, int type, const std::set <int>& elements,
195 
201 
202  enum { ONE_SEPARATION = 1 };
203  enum { TWO_SEPARATION = 2 };
204  enum { THREE_SEPARATION = 3 };
205 
210  inline int separation_type() const
211  {
212  return _type;
213  }
214 
219  inline decomposed_matroid* first() const
220  {
221  return _first;
222  }
223 
228  inline decomposed_matroid* second() const
229  {
230  return _second;
231  }
232 
237  virtual bool is_leaf() const
238  {
239  return false;
240  }
241 
246  virtual bool is_regular() const
247  {
248  return _first->is_regular() && _second->is_regular();
249  }
250 
251  protected:
254  int _type;
255  };
256 
257 } /* namespace tu */
Definition: matroid_decomposition.hpp:83
bool _is_R10
Definition: matroid_decomposition.hpp:171
bool is_graphic() const
Definition: matroid_decomposition.hpp:145
matroid_graph * _cograph
Definition: matroid_decomposition.hpp:170
bool is_R10() const
Definition: matroid_decomposition.hpp:136
virtual bool is_leaf() const
Definition: matroid_decomposition.hpp:109
const matroid_graph * graph() const
Definition: matroid_decomposition.hpp:118
const matroid_graph * cograph() const
Definition: matroid_decomposition.hpp:127
virtual ~decomposed_matroid_leaf()
Definition: matroid_decomposition.cpp:50
virtual bool is_regular() const
Definition: matroid_decomposition.hpp:163
matroid_graph * _graph
Definition: matroid_decomposition.hpp:169
decomposed_matroid_leaf(matroid_graph *graph, matroid_graph *cograph, bool is_R10, const std::set< int > &elements, const matroid_element_set &extra_elements)
Definition: matroid_decomposition.cpp:39
bool is_cographic() const
Definition: matroid_decomposition.hpp:154
Definition: matroid_decomposition.hpp:179
decomposed_matroid * _second
Definition: matroid_decomposition.hpp:253
decomposed_matroid_separator(decomposed_matroid *first, decomposed_matroid *second, int type, const std::set< int > &elements, const matroid_element_set &extra_elements)
Definition: matroid_decomposition.cpp:69
int separation_type() const
Definition: matroid_decomposition.hpp:210
virtual bool is_leaf() const
Definition: matroid_decomposition.hpp:237
int _type
Definition: matroid_decomposition.hpp:254
decomposed_matroid * first() const
Definition: matroid_decomposition.hpp:219
virtual ~decomposed_matroid_separator()
Definition: matroid_decomposition.cpp:80
@ ONE_SEPARATION
Definition: matroid_decomposition.hpp:202
decomposed_matroid * second() const
Definition: matroid_decomposition.hpp:228
virtual bool is_regular() const
Definition: matroid_decomposition.hpp:246
@ THREE_SEPARATION
Definition: matroid_decomposition.hpp:204
@ TWO_SEPARATION
Definition: matroid_decomposition.hpp:203
decomposed_matroid * _first
Definition: matroid_decomposition.hpp:252
Definition: matroid_decomposition.hpp:26
decomposed_matroid(const matroid_element_set &elements, const matroid_element_set &extra_elements)
Definition: matroid_decomposition.cpp:13
virtual bool is_leaf() const =0
const matroid_element_set & extra_elements() const
Definition: matroid_decomposition.hpp:68
virtual bool is_regular() const =0
const matroid_element_set & elements() const
Definition: matroid_decomposition.hpp:59
virtual ~decomposed_matroid()
Definition: matroid_decomposition.cpp:24
Definition: algorithm.hpp:14
std::set< int > matroid_element_set
Definition: matroid_decomposition.hpp:19
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, boost::no_property, matroid_element_property > matroid_graph
Definition: matroid_graph.hpp:21