Scaffolding  0.1
This program can assemble genome scaffolds using the pairing information in paired-end reads.
scaffold_graph.hpp
Go to the documentation of this file.
1 
7 #ifndef SCAFFOLD_GRAPH_HPP
8 #define SCAFFOLD_GRAPH_HPP
9 
10 #include "utils/predicates.hpp"
11 #include "utils/graph_typedefs.hpp"
12 #include "utils/scaffolding_typedefs.hpp"
13 #include "utils/graph_infos.hpp"
15 
16 
17 namespace scaffold{
18  using namespace graph_infos;
19  using namespace predicates;
20 
22 
26  {
27  public:
28  typedef RawScaffoldGraph Graph;
29  protected:
30  Graph* const _the_graph;
31  Matching<Graph> matched;
32 
34  public:
35 
36  typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
37  typedef typename boost::graph_traits<Graph>::edge_descriptor Edge;
38  typedef typename Graph::vertex_bundled VertexProperty;
39  typedef typename Graph::edge_bundled EdgeProperty;
40  typedef typename Graph::graph_bundled GraphProperty;
41  typedef typename boost::property_map<Graph, unsigned VertexProperty::*>::const_type cVertexIndexMap;
42  typedef typename boost::property_map<Graph, unsigned VertexProperty::*>::type VertexIndexMap;
43  typedef typename boost::unordered_set<Vertex> VertexSet;
44 
45  protected:
47  void copy_and_init_matching(const ScaffoldGraph& g, Matching<Graph>* const translate, const bool update_infos)
48  {
49  // if translate is given as NULL, then allocate a translation map
50  Matching<Graph>* const t = (translate ? translate : new Matching<Graph>());
51  // copy the graph
52  boost::copy_graph(*g._the_graph, *_the_graph,
53  orig_to_copy(associative_property_map<Matching<Graph> >(*t)).vertex_index_map(g.get_index_map()));
54  // copy the matching
55  DEBUG4(std::cout << "initializing matching of the copy"<<std::endl);
56  copy_matching<Graph>(g.matched, matched, *t);
57  // update infos if neccessary
58  if(update_infos) infos.read_from_infos(g.infos, *t);
59  // clean up the translation map if we allocated it
60  if(!translate) delete t;
61  }
62 
65  {
66  std::cout << "parsing matching"<<std::endl;
67  matched.clear();
68  for(EdgeIterRange<Graph> r = boost::edges(*_the_graph); r.first != r.second; ++r.first){
69  const Edge& e = *r.first;
70  const EdgeProperty& e_info = (*_the_graph)[e];
71  if(e_info.is_matching_edge()){
72  const Vertex u = source(e);
73  const Vertex v = target(e);
74  matched.emplace(u, v);
75  matched.emplace(v, u);
76  }// if
77  }// for
78  }// function
79 
81  void delete_matching(const Vertex& u)
82  {
83  remove_matching_pair<Graph>(u, matched);
84  }
85 
86  public:
89  _the_graph(new Graph()), infos(*_the_graph)
90  {}
91 
93  ScaffoldGraph(const Graph& g):
94  _the_graph(new Graph(g)), infos(*_the_graph)
95  {
96  update_vertex_indices();
97  parse_matching_from_graph();
98  }
99 
101 
103  ScaffoldGraph(Graph* const g):
104  _the_graph(g), infos(*_the_graph)
105  {
106  update_vertex_indices();
107  parse_matching_from_graph();
108  }
109 
111 
112  ScaffoldGraph(const ScaffoldGraph& g, Matching<Graph>* const translate, const bool update_infos = true) :
113  _the_graph(new Graph()), infos(*_the_graph)
114  {
115  copy_and_init_matching(g, translate, update_infos);
116  }
118  ~ScaffoldGraph() { delete _the_graph; }
119 
121  void update_vertex_indices(const unsigned first_index = 0)
122  {
123  setup_vertex_indices(*_the_graph, first_index);
124  }
125 
127  const VertexIndexMap get_index_map() const
128  {
129  return boost::get(&VertexProperty::index, *_the_graph);
130  }
131 
133 
134  std::pair<Edge, bool> find_edge(const Vertex& u, const Vertex& v) const
135  {
136  return boost::edge(u, v, *_the_graph);
137  }
138 
140  void clear_vertex(const Vertex& u)
141  {
142  for(auto r = get_incident_non_matching(u); r;) delete_edge(*(r++));
143  }
144 
146 
149  void delete_vertex(const Vertex& u, const bool update_indices = true, const bool update_infos = true)
150  {
151  // step 0: remove u from the graph
152  if(update_infos)
153  for(auto r = boost::out_edges(u, *_the_graph); r.first != r.second;)
154  delete_edge(*(r.first++), true);
155  else boost::clear_vertex(u, *_the_graph);
156  boost::remove_vertex(u, *_the_graph);
157 
158  // step 1: remove u from the matching
159  delete_matching(u);
160 
161  // step 2: update indices
162  if(update_indices) update_vertex_indices();
163  }
164 
166  const VertexProperty& operator[](const Vertex& u) const
167  {
168  return (*_the_graph)[u];
169  }
171  VertexProperty& operator[](const Vertex& u)
172  {
173  return (*_the_graph)[u];
174  }
176  const EdgeProperty& operator[](const Edge& e) const
177  {
178  return (*_the_graph)[e];
179  }
181  EdgeProperty& operator[](const Edge& e)
182  {
183  return (*_the_graph)[e];
184  }
186  const EdgeProperty& operator[](const VertexPair<Graph>& uv) const
187  {
188  std::pair<Edge, bool> e = boost::edge(uv.first, uv.second, *_the_graph);
189  if(e.second)
190  return (*_the_graph)[e.first];
191  else
192  throw except::invalid_assumption("edge does not exist");
193  }
195  EdgeProperty& operator[](const VertexPair<Graph>& uv)
196  {
197  std::pair<Edge, bool> e = boost::edge(uv.first, uv.second, *_the_graph);
198  if(e.second)
199  return (*_the_graph)[e.first];
200  else
201  throw except::invalid_assumption("edge does not exist");
202  }
204  const GraphProperty& get_graph_property() const
205  {
206  return (*_the_graph)[boost::graph_bundle];
207  }
208 
210  Vertex source(const Edge& e) const
211  {
212  return boost::source(e, *_the_graph);
213  }
215  Vertex target(const Edge& e) const
216  {
217  return boost::target(e, *_the_graph);
218  }
219 
222  {
223  return infos;
224  }
225 
227  const Graph& get_graph() const
228  {
229  return *_the_graph;
230  }
232  const Matching<Graph>& get_matching() const
233  {
234  return matched;
235  }
237  const Vertex& matched_with(const Vertex& v) const
238  {
239  return matched.at(v);
240  }
242 
243  const bool is_matching_edge(const VertexPair<Graph>& uv) const
244  {
245  return (uv.first == matched_with(uv.second));
246  }
248  const Edge incident_matching_edge(const Vertex& v) const
249  {
250  assert(matched.find(v) != matched.cend());
251  return boost::edge(v, matched.at(v), *_the_graph).first;
252  }
254  const unsigned degree(const Vertex& v) const
255  {
256  return boost::degree(v, *_the_graph);
257  }
258 
260  bool adjacent(const Vertex& u, const Vertex& v) const
261  {
262  return boost::edge(u, v, *_the_graph).second;
263  }
265  void get_neighbors(const Vertex& u, VertexSet& nh) const
266  {
267  for(auto r = boost::adjacent_vertices(u, *_the_graph); r.first != r.second; ++r.first)
268  nh.emplace(*r.first);
269  }
270 
272  unsigned get_max_multiplicity() const
273  {
274  unsigned result = 0;
275  for(auto r = boost::edges(*_the_graph); r.first != r.second; ++r.first)
276  result = std::max(result, operator[](*r.first).multiplicity);
277  return result;
278  }
279 
281  std::pair<Edge, int> get_max_non_contig_length() const
282  {
283  Edge _max_e;
284  int _max = -1;
285  for(EdgeIterRange<Graph> r = boost::edges(*_the_graph); r.first != r.second; ++r.first){
286  const Edge& e = *r.first;
287  const ScafEdgeProperty& e_info = (*_the_graph)[e];
288  if(!e_info.is_matching_edge())
289  if(e_info.length > _max){
290  _max = e_info.length;
291  _max_e = e;
292  }
293  }// for each edge e
294  return std::pair<Edge, int>(_max_e, _max);
295  }
296 
297 
299 
300  void delete_edge(const Edge& e, const bool update_infos = true)
301  {
302  const Vertex& u = boost::source(e, *_the_graph);
303  const Vertex& v = boost::target(e, *_the_graph);
304 
305  // update the infos with what we know about the to-be-deleted edge
306  if(update_infos) {
307  infos.delete_edge(VertexPair<Graph>(u, v));
308  } else {
309  infos.invalidate_all();
310  }
311  boost::remove_edge(e, *_the_graph);
312  DEBUG5(std::cout<<"deleted edge "<<(*_the_graph)[u].name<<"-"<<(*_the_graph)[v].name<<std::endl);
313  }// function
314 
316  bool delete_edge(const Vertex& u, const Vertex& v)
317  {
318  const std::pair<Edge, bool> e_pair = find_edge(u, v);
319  if(e_pair.second){
320  delete_edge(e_pair.first);
321  return true;
322  } else return false;
323  }
325  bool delete_edge(const VertexPair<Graph>& uv)
326  {
327  return delete_edge(uv.first, uv.second);
328  }
329 
331 
332  Vertex const * find_vertex_by_name(const VertexName& name) const
333  {
334  for(VertexIterRange<Graph> r = boost::vertices(*_the_graph); r.first != r.second; ++r.first)
335  if((*_the_graph)[*r.first].name == name)
336  return &(*r.first);
337  return NULL;
338  }
339 
341 
342  Edge const * find_edge_by_name(const EdgeName& name) const
343  {
344  // step 1: find the first vertex
345  DEBUG5(std::cout<<"finding ("<<name.first<<","<<name.second<<")"<<std::endl);
346  Vertex const * u = find_vertex_by_name(name.first);
347  if(u){
348  // step 2: find the second vertex among the ones adjacent with the first vertex & delete the edge
349  for(OEdgeIterRange<Graph> er = boost::out_edges(*u, *_the_graph); er.first != er.second; ++er.first){
350  const Edge& e = *er.first;
351  const Vertex& v = boost::target(e, *_the_graph);
352  if((*_the_graph)[v].name == name.second)
353  return &e;
354  }// for all incident edges of u
355  }// if u exists
356  // if either the first vertex or the edge has not been found, return failure
357  return NULL;
358  }
359 
361  const Vertex add_vertex(const VertexProperty& p, const bool update_infos = true)
362  {
363  const Vertex u = boost::add_vertex(p, *_the_graph);
364  if(update_infos) infos.add_vertex(u);
365  return u;
366  }
368 
369  const Vertex add_vertex(const std::string name, const bool update_infos = true, const unsigned index = UINT_MAX)
370  {
371  VertexProperty vp;
372  vp.index = (index != UINT_MAX ? index : boost::num_vertices(*_the_graph));
373  vp.name = name;
374  return add_vertex(vp, update_infos);
375  }
377 
378  const Vertex add_vertex(const Vertex& u, const bool update_infos = true)
379  {
380  return add_vertex(operator[](u).name, update_infos);
381  }
382 
384 
385  std::pair<Edge, bool> add_edge(const Vertex& u,
386  const Vertex& v,
387  const EdgeProperty& ep = EdgeProperty(),
388  const bool update_infos = true)
389  {
390  std::pair<Edge, bool> e = boost::add_edge(u, v, *_the_graph);
391  if(e.second) {
392  (*_the_graph)[e.first] = ep;
393  if(update_infos) infos.add_edge(u, v);
394  }
395  return e;
396  }
397 
399 
400  std::pair<Edge, bool> add_matching_edge(const Vertex& u,
401  const Vertex& v,
402  const EdgeProperty& ep = EdgeProperty(),
403  const bool update_infos = true)
404  {
405  std::pair<Edge, bool> e = add_edge(u, v, ep, update_infos);
406  if(e.second) {
407  // recall that an edge is considered matching edge if it has no weight
408  if(ep.weight != NO_WEIGHT) (*_the_graph)[e.first].weight = NO_WEIGHT;
409 #ifdef NDEBUG
410  matched.emplace(u, v);
411  matched.emplace(v, u);
412 #else
413  assert(matched.emplace(u, v).second);
414  assert(matched.emplace(v, u).second);
415 #endif
416  }
417  return e;
418  }
419 
421  EdgeName get_edge_name(const VertexPair<Graph>& uv) const
422  {
423  return EdgeName((*_the_graph)[uv.first].name, (*_the_graph)[uv.second].name);
424  }
425 
427  EdgeName get_edge_name(const Edge& e) const
428  {
429  const Vertex& u = boost::source(e, *_the_graph);
430  const Vertex& v = boost::target(e, *_the_graph);
431  return EdgeName((*_the_graph)[u].name, (*_the_graph)[v].name);
432  }
433 
435  bool is_bridge(const ScafVertex& u, const ScafVertex& v)
436  {
437  return infos.bridges.is_bridge(u, v);
438  }
439 
441  bool is_bridge_const(const ScafVertex& u, const ScafVertex& v) const
442  {
443  return infos.bridges.is_bridge_const(u, v);
444  }
445 
447  bool is_on_alternating_cycle(const ScafVertex& u, const ScafVertex& v) const
448  {
449  // first, if uv is not on any cycle, then it's also not on any alternating cycles
450  if(infos.bridges.is_valid())
451  if(infos.bridges.is_bridge_const(u, v)) return false;
452  // otherwise, check whether there is an alternating u-v-path starting & ending with a non-matching edge
453  return edge_on_alternating_cycle(u, v, *_the_graph, matched);
454  }
455 
457  unsigned weight() const
458  {
459  unsigned accu = 0;
460  // iterate through the edges, summing their weight
461  for(ScafEdgeIterRange er = boost::edges(*_the_graph); er.first != er.second; ++er.first)
462  accu += (*_the_graph)[*er.first].weight;
463  return accu;
464  }
465 
467  template<class Predicate = TruePredicate<Edge> >
469  {
470  return Predicated_EdgeIter<Graph, Predicate, EdgeIter<Graph> >(*_the_graph, boost::edges(*_the_graph), pred);
471  }
472 
475  {
476  return get_edges(MatchingPredicate<Graph>(*_the_graph, false));
477  }
478 
481  {
482  return get_edges(MatchingPredicate<Graph>(*_the_graph, true));
483  }
484 
486  template<class Predicate = TruePredicate<Edge> >
488  {
489  return Predicated_EdgeIter<Graph, Predicate>(*_the_graph, boost::out_edges(u, *_the_graph), pred);
490  }
491 
494  {
495  return get_incident(u, MatchingPredicate<Graph>(*_the_graph, true));
496  }
497 
499  Graph* const split_off_component()
500  {
501  if(infos.comps.get_num() > 1){
502  // prepare tools: new ScaffoldGraph & translation maps
503  ScafMatching translate, translate_back;
504  // Step 1: split off a component
505  Graph* const h = scaffold::split_off_component<Graph>(*_the_graph, &translate, &translate_back);
506 
507  // update indices and infos
508  setup_vertex_indices(*h);
509  setup_vertex_indices(*_the_graph);
510 
511  // Step 2: construct the new matching
512  parse_matching_from_graph();
513 
514  infos.read_from_split_off_component(infos, translate);
515  return h;
516  } else return NULL;
517  } // function
518 
519 
522  {
523  ScafMatching translate;
524  // merge g into ourself
525  copy_and_init_matching(g, &translate, false);
526  update_vertex_indices();
527  // update infos
528  infos.update_disjoint_union(g.infos, translate);
529  }
530 
531 
532 
535  {
536  std::cout << boost::num_vertices(*_the_graph) << " vertices, "
537  << boost::num_edges(*_the_graph)<<" edges, "
538  << " insert size: "<<get_graph_property().insert_size
539  << " std deviation: "<<get_graph_property().standard_deviation;
540  }
541 
543 
545  {
546  std::cout << "removing contig edges..."<<std::endl;
547  for(const VertexPair<Graph>& c: matched) delete_edge(c);
548  matched.clear();
549  }
550 
551  };
552 
553 }// namespace
554 
555 #endif
std::pair< Edge, int > get_max_non_contig_length() const
return a non-contig edge of maximum length in the graph
Definition: scaffold_graph.hpp:281
Predicated_EdgeIter< Graph, MatchingPredicate< Graph > > get_incident_non_matching(const Vertex &u) const
convenience function to get all incident non-matching edges of u
Definition: scaffold_graph.hpp:493
an edge predicate that is true iff the given edge is (not) a matching edge
Definition: predicates.hpp:66
void delete_edge(const VertexPair< Graph > &uv)
react to deletion of edge uv
Definition: graph_infos.hpp:662
ScaffoldGraph()
constructor initializing an empty graph
Definition: scaffold_graph.hpp:88
const Vertex & matched_with(const Vertex &v) const
get a const reference to the vertex matched with v
Definition: scaffold_graph.hpp:237
const EdgeProperty & operator[](const VertexPair< Graph > &uv) const
get a const reference to the edge properties of uv, throwing invalid_assumption if uv does not exist ...
Definition: scaffold_graph.hpp:186
void read_from_split_off_component(const GraphInfos< Graph > &infos, const Matching< Graph > &translate)
react to splitting off this connected component g from a graph h
Definition: graph_infos.hpp:688
bool delete_edge(const VertexPair< Graph > &uv)
convenience function to delete pairs of vertices
Definition: scaffold_graph.hpp:325
Graph *const split_off_component()
if _the_graph is disconnected, split off & return a connected compoenent, otherwise return NULL ...
Definition: scaffold_graph.hpp:499
void read_from_infos(const GraphInfos< Graph > &infos, const Matching< Graph > &translate)
update the infos from the graph h of which g has just been copied
Definition: graph_infos.hpp:677
bool adjacent(const Vertex &u, const Vertex &v) const
return whether u & v are adjacent
Definition: scaffold_graph.hpp:260
Vertex const * find_vertex_by_name(const VertexName &name) const
find a vertex given its name
Definition: scaffold_graph.hpp:332
void delete_vertex(const Vertex &u, const bool update_indices=true, const bool update_infos=true)
remove a vertex and all its incident edges
Definition: scaffold_graph.hpp:149
const Edge incident_matching_edge(const Vertex &v) const
return the matching edge that is incident with v
Definition: scaffold_graph.hpp:248
unsigned weight() const
return the total weight of the graph
Definition: scaffold_graph.hpp:457
VertexProperty & operator[](const Vertex &u)
get a reference to the vertex properties of u
Definition: scaffold_graph.hpp:171
Definition: read_adj_list.hpp:22
const VertexProperty & operator[](const Vertex &u) const
get a const reference to the vertex properties of u
Definition: scaffold_graph.hpp:166
Vertex target(const Edge &e) const
get a copy of the target vertex of e
Definition: scaffold_graph.hpp:215
prototype predicate
Definition: predicates.hpp:14
void remove_contigs()
remove all contig edges from the graph
Definition: scaffold_graph.hpp:544
const bool is_matching_edge(const VertexPair< Graph > &uv) const
return whether the given VertexPair is matched
Definition: scaffold_graph.hpp:243
Graph *const _the_graph
the underlying boost graph
Definition: scaffold_graph.hpp:30
void parse_matching_from_graph()
compute the matching by parsing the properties of all edges
Definition: scaffold_graph.hpp:64
const GraphProperty & get_graph_property() const
return a const reference to the graph properties
Definition: scaffold_graph.hpp:204
const Vertex add_vertex(const std::string name, const bool update_infos=true, const unsigned index=UINT_MAX)
add a new vertex and return it; use the given name & index
Definition: scaffold_graph.hpp:369
void add_edge(const Vertex< Graph > &u, const Vertex< Graph > &v)
react to addition of edge uv
Definition: graph_infos.hpp:654
const unsigned degree(const Vertex &v) const
return the degree of v
Definition: scaffold_graph.hpp:254
void copy_and_init_matching(const ScaffoldGraph &g, Matching< Graph > *const translate, const bool update_infos)
outsource common constructor work: copy a given graph, construct a matching from the translate map...
Definition: scaffold_graph.hpp:47
ScaffoldGraph(const ScaffoldGraph &g, Matching< Graph > *const translate, const bool update_infos=true)
constructor initializing a copy of the given graph g and returning the translate map in translate; up...
Definition: scaffold_graph.hpp:112
ScaffoldGraph(const Graph &g)
constructor initializing a copy of the given graph g
Definition: scaffold_graph.hpp:93
Predicated_EdgeIter< Graph, Predicate > get_incident(const Vertex &u, const Predicate &pred=Predicate()) const
get incident edges of u satisfying a predicate
Definition: scaffold_graph.hpp:487
Predicated_EdgeIter< Graph, MatchingPredicate< Graph >, EdgeIter< Graph > > get_matching_edges() const
convenience fuction to get all matching edges
Definition: scaffold_graph.hpp:474
void clear_vertex(const Vertex &u)
remove all non-matching edges incident with u
Definition: scaffold_graph.hpp:140
const Vertex add_vertex(const VertexProperty &p, const bool update_infos=true)
add a new vertex and return it
Definition: scaffold_graph.hpp:361
std::pair< Edge, bool > find_edge(const Vertex &u, const Vertex &v) const
find an edge in _the_graph, given its endpoints
Definition: scaffold_graph.hpp:134
an exception for the case that some assumption that is made is not true
Definition: exceptions.hpp:30
EdgeName get_edge_name(const Edge &e) const
get a copy of the name of an edge
Definition: scaffold_graph.hpp:427
the main graph class
Definition: scaffold_graph.hpp:25
void disjoint_union(const ScaffoldGraph &g)
merge g into our graph
Definition: scaffold_graph.hpp:521
ScaffoldGraph(Graph *const g)
constructor initializing using the given graph pointer; no copy is performed
Definition: scaffold_graph.hpp:103
EdgeProperty & operator[](const Edge &e)
get a reference to the edge properties of e
Definition: scaffold_graph.hpp:181
an edge iterator that skips over all edges for which the predicate evaluates to false ...
Definition: adv_edge_iters.hpp:19
void delete_matching(const Vertex &u)
remove the indication that uv is a matching edge
Definition: scaffold_graph.hpp:81
~ScaffoldGraph()
destructor deleting _the_graph
Definition: scaffold_graph.hpp:118
void get_neighbors(const Vertex &u, VertexSet &nh) const
put all neighbors of u into nh
Definition: scaffold_graph.hpp:265
const VertexIndexMap get_index_map() const
get an index map to use in various boost algorithms
Definition: scaffold_graph.hpp:127
bool delete_edge(const Vertex &u, const Vertex &v)
delete an edge e and update infos if requested; return whether the edge had existed before or not ...
Definition: scaffold_graph.hpp:316
Matching< Graph > matched
a perfect matching in _the_graph
Definition: scaffold_graph.hpp:31
std::pair< Edge, bool > add_matching_edge(const Vertex &u, const Vertex &v, const EdgeProperty &ep=EdgeProperty(), const bool update_infos=true)
add a matching edge unless the edge already exists; return the edge and whether an insertion took pla...
Definition: scaffold_graph.hpp:400
const Graph & get_graph() const
get a const reference to the underlying graph
Definition: scaffold_graph.hpp:227
void update_vertex_indices(const unsigned first_index=0)
recompute vertex indices; useful after deleting vertices or uniting scaffold graphs ...
Definition: scaffold_graph.hpp:121
EdgeName get_edge_name(const VertexPair< Graph > &uv) const
get a copy of the name of the edge uv; independent of its presence
Definition: scaffold_graph.hpp:421
bool is_on_alternating_cycle(const ScafVertex &u, const ScafVertex &v) const
return whether the given edge is on an alternating cycle
Definition: scaffold_graph.hpp:447
Definition: scaffolding_typedefs.hpp:86
void invalidate_all()
invalidate all infos
Definition: graph_infos.hpp:628
Vertex source(const Edge &e) const
get a copy of the source vertex of e
Definition: scaffold_graph.hpp:210
void delete_edge(const Edge &e, const bool update_infos=true)
delete an edge e and update infos if requested
Definition: scaffold_graph.hpp:300
void add_vertex(const Vertex< Graph > &u)
react to addition of vertex u
Definition: graph_infos.hpp:647
bool is_bridge_const(const ScafVertex &u, const ScafVertex &v) const
return whether the given vertex pair constitutes a bridge without updating the infos ...
Definition: scaffold_graph.hpp:441
bool is_bridge(const ScafVertex &u, const ScafVertex &v)
return whether the given vertex pair constitutes a bridge, updating infos if necessary ...
Definition: scaffold_graph.hpp:435
std::pair< Edge, bool > add_edge(const Vertex &u, const Vertex &v, const EdgeProperty &ep=EdgeProperty(), const bool update_infos=true)
add a new edge unless it is already there; return it and whether an insertion took place ...
Definition: scaffold_graph.hpp:385
Edge const * find_edge_by_name(const EdgeName &name) const
delete edge by name
Definition: scaffold_graph.hpp:342
Predicated_EdgeIter< Graph, MatchingPredicate< Graph >, EdgeIter< Graph > > get_non_matching_edges() const
convenience fuction to get all non-matching edges
Definition: scaffold_graph.hpp:480
unsigned get_max_multiplicity() const
compute the maximum multiplicity occuring in g
Definition: scaffold_graph.hpp:272
void update_disjoint_union(const GraphInfos< Graph > &infos, const Matching< Graph > &translate)
react to forming a disjoint union with g with another graph h, given the infos of h and a translate m...
Definition: graph_infos.hpp:699
GraphInfos< Graph > infos
a set of graph properties of the underlying graph
Definition: scaffold_graph.hpp:33
EdgeProperty & operator[](const VertexPair< Graph > &uv)
get a reference to the edge properties of uv, throwing invalid_assumption if uv does not exist ...
Definition: scaffold_graph.hpp:195
const Matching< Graph > & get_matching() const
get a const reference to the perfect matching in _the_graph
Definition: scaffold_graph.hpp:232
const GraphInfos< Graph > & get_infos() const
get a const reference to the graph infos
Definition: scaffold_graph.hpp:221
an accumulator class for different graph properties
Definition: graph_infos.hpp:604
const EdgeProperty & operator[](const Edge &e) const
get a const reference to the edge properties of e
Definition: scaffold_graph.hpp:176
const Vertex add_vertex(const Vertex &u, const bool update_infos=true)
add a new vertex and return it; copy the name from vertex u
Definition: scaffold_graph.hpp:378
void print_statistics()
print various statistics
Definition: scaffold_graph.hpp:534
Predicated_EdgeIter< Graph, Predicate, EdgeIter< Graph > > get_edges(const Predicate &pred=Predicate()) const
get all edges satisfying a predicate
Definition: scaffold_graph.hpp:468