3 #ifndef TD_SUBGRAPH_HPP
4 #define TD_SUBGRAPH_HPP
9 using namespace filters;
18 typedef filtered_graph<Graph, E_Filter, V_Filter> Subgraph;
21 VertexSet<Graph> introduced_vertices;
22 VertexSet<Graph> forgotten_vertices;
23 EdgeSet<Graph> introduced_edges;
24 V_Filter vertex_filter;
31 introduced_vertices(),
33 introduced_edges(default_buckets, _super_g),
34 vertex_filter(&introduced_vertices),
35 edge_filter(&introduced_edges),
36 g(Subgraph(super_g, edge_filter, vertex_filter))
42 void introduce_vertex(
const Vertex<Graph>& v)
44 introduced_vertices.emplace(v);
47 void forget_vertex(
const Vertex<Subgraph>& u)
50 for(OEdgeIterRange<Subgraph> r = out_edges(u, g); r.first != r.second;){
51 const Vertex<Subgraph>& v = target(*r.first, g);
53 const auto i = forgotten_vertices.find(v);
54 if(i != forgotten_vertices.end()){
56 const OEdgeIter<Subgraph> e = r.first++;
57 introduced_edges.erase(*e);
59 if(degree(v, g) == 0) {
60 forgotten_vertices.erase(i);
61 introduced_vertices.erase(v);
66 if(degree(u, g) == 0) introduced_vertices.erase(u);
67 else forgotten_vertices.emplace(u);
71 void introduce_edge(
const Edge<Graph>& e)
73 introduced_edges.emplace(e);
78 for(
const Vertex<Graph>& v : h.introduced_vertices)
79 if(!
contains(introduced_vertices, v)) introduce_vertex(v);
81 for(
const Vertex<Graph>& v : h.forgotten_vertices)
82 forgotten_vertices.emplace(v);
84 for(
const Edge<Graph>& e : h.introduced_edges){
85 assert(!
contains(introduced_edges, e));
Definition: read_adj_list.hpp:22
filter to work with filtered graphs that is based on a set of vertices, passed to the constructor ...
Definition: filters.hpp:23
Definition: td_subgraph.hpp:13
bool contains(const Set &s, const Element &el)
a more readable containment check
Definition: utils.hpp:171