2 #ifndef ANDRES_GRAPH_CUT_VERTICES_HXX
3 #define ANDRES_GRAPH_CUT_VERTICES_HXX
7 #include "subgraph.hxx"
26 template<
typename GRAPH,
typename ARRAY>
33 template<
typename GRAPH,
typename ARRAY>
41 template<
typename GRAPH,
typename SUBGRAPH,
typename ARRAY>
49 template<
typename GRAPH,
typename SUBGRAPH,
typename ARRAY>
58 template<
typename GRAPH,
typename SUBGRAPH,
typename ARRAY>
67 template<
typename GRAPH,
typename SUBGRAPH,
typename ARRAY>
77 template<
typename GRAPH>
79 depth_(graph.numberOfVertices()),
80 min_successor_depth_(graph.numberOfVertices()),
81 next_out_arc_(graph.numberOfVertices()),
82 parent_(graph.numberOfVertices()),
83 visited_(graph.numberOfVertices())
96 template<
typename GRAPH,
typename ARRAY>
118 template<
typename GRAPH,
typename ARRAY>
122 ARRAY& is_cut_vertex,
140 template<
typename GRAPH,
typename SUBGRAPH,
typename ARRAY>
144 const SUBGRAPH& subgraph_mask,
164 template<
typename GRAPH,
typename SUBGRAPH,
typename ARRAY>
168 const SUBGRAPH& subgraph_mask,
169 ARRAY& is_cut_vertex,
175 for (std::size_t i = 0; i < graph.numberOfVertices(); ++i)
176 if (buffer.
parent_[i] == -2 && subgraph_mask.vertex(i))
192 template<
typename GRAPH,
typename SUBGRAPH,
typename ARRAY>
196 const SUBGRAPH& subgraph_mask,
197 std::size_t starting_vertex,
202 findCutVertices(graph, subgraph_mask, starting_vertex, is_cut_vertex, buffer);
218 template<
typename GRAPH,
typename SUBGRAPH,
typename ARRAY>
222 const SUBGRAPH& subgraph_mask,
223 std::size_t starting_vertex,
224 ARRAY& is_cut_vertex,
230 std::stack<std::size_t> S;
232 S.push(starting_vertex);
233 buffer.
depth_[starting_vertex] = 0;
234 buffer.
parent_[starting_vertex] = -1;
244 is_cut_vertex[v] = 0;
253 is_cut_vertex[v] = 1;
259 while (buffer.
next_out_arc_[v] != graph.verticesFromVertexEnd(v))
261 typename GRAPH::EdgeIterator e = graph.edgesFromVertexBegin(v) + (buffer.
next_out_arc_[v] - graph.verticesFromVertexBegin(v));
265 !subgraph_mask.edge(*e)
291 std::size_t root_child_count = 0;
292 for (
auto to = graph.verticesFromVertexBegin(starting_vertex); to != graph.verticesFromVertexEnd(starting_vertex); ++to)
293 if(buffer.
parent_[*to] == starting_vertex)
296 if(root_child_count >= 2)
297 is_cut_vertex[starting_vertex] = 1;