boyer_myrvold_impl.hpp 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813
  1. //=======================================================================
  2. // Copyright (c) Aaron Windsor 2007
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See
  5. // accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //=======================================================================
  8. #ifndef __BOYER_MYRVOLD_IMPL_HPP__
  9. #define __BOYER_MYRVOLD_IMPL_HPP__
  10. #include <vector>
  11. #include <list>
  12. #include <boost/next_prior.hpp>
  13. #include <boost/config.hpp> //for std::min macros
  14. #include <boost/shared_ptr.hpp>
  15. #include <boost/tuple/tuple.hpp>
  16. #include <boost/property_map/property_map.hpp>
  17. #include <boost/graph/graph_traits.hpp>
  18. #include <boost/graph/depth_first_search.hpp>
  19. #include <boost/graph/planar_detail/face_handles.hpp>
  20. #include <boost/graph/planar_detail/face_iterators.hpp>
  21. #include <boost/graph/planar_detail/bucket_sort.hpp>
  22. namespace boost
  23. {
  24. namespace detail
  25. {
  26. enum bm_case_t
  27. {
  28. BM_NO_CASE_CHOSEN,
  29. BM_CASE_A,
  30. BM_CASE_B,
  31. BM_CASE_C,
  32. BM_CASE_D,
  33. BM_CASE_E
  34. };
  35. }
  36. template < typename LowPointMap, typename DFSParentMap, typename DFSNumberMap,
  37. typename LeastAncestorMap, typename DFSParentEdgeMap, typename SizeType >
  38. struct planar_dfs_visitor : public dfs_visitor<>
  39. {
  40. planar_dfs_visitor(LowPointMap lpm, DFSParentMap dfs_p, DFSNumberMap dfs_n,
  41. LeastAncestorMap lam, DFSParentEdgeMap dfs_edge)
  42. : low(lpm)
  43. , parent(dfs_p)
  44. , df_number(dfs_n)
  45. , least_ancestor(lam)
  46. , df_edge(dfs_edge)
  47. , count(0)
  48. {
  49. }
  50. template < typename Vertex, typename Graph >
  51. void start_vertex(const Vertex& u, Graph&)
  52. {
  53. put(parent, u, u);
  54. put(least_ancestor, u, count);
  55. }
  56. template < typename Vertex, typename Graph >
  57. void discover_vertex(const Vertex& u, Graph&)
  58. {
  59. put(low, u, count);
  60. put(df_number, u, count);
  61. ++count;
  62. }
  63. template < typename Edge, typename Graph >
  64. void tree_edge(const Edge& e, Graph& g)
  65. {
  66. typedef typename graph_traits< Graph >::vertex_descriptor vertex_t;
  67. vertex_t s(source(e, g));
  68. vertex_t t(target(e, g));
  69. put(parent, t, s);
  70. put(df_edge, t, e);
  71. put(least_ancestor, t, get(df_number, s));
  72. }
  73. template < typename Edge, typename Graph >
  74. void back_edge(const Edge& e, Graph& g)
  75. {
  76. typedef typename graph_traits< Graph >::vertex_descriptor vertex_t;
  77. typedef typename graph_traits< Graph >::vertices_size_type v_size_t;
  78. vertex_t s(source(e, g));
  79. vertex_t t(target(e, g));
  80. BOOST_USING_STD_MIN();
  81. if (t != get(parent, s))
  82. {
  83. v_size_t s_low_df_number = get(low, s);
  84. v_size_t t_df_number = get(df_number, t);
  85. v_size_t s_least_ancestor_df_number = get(least_ancestor, s);
  86. put(low, s,
  87. min BOOST_PREVENT_MACRO_SUBSTITUTION(
  88. s_low_df_number, t_df_number));
  89. put(least_ancestor, s,
  90. min BOOST_PREVENT_MACRO_SUBSTITUTION(
  91. s_least_ancestor_df_number, t_df_number));
  92. }
  93. }
  94. template < typename Vertex, typename Graph >
  95. void finish_vertex(const Vertex& u, Graph&)
  96. {
  97. typedef typename graph_traits< Graph >::vertices_size_type v_size_t;
  98. Vertex u_parent = get(parent, u);
  99. v_size_t u_parent_lowpoint = get(low, u_parent);
  100. v_size_t u_lowpoint = get(low, u);
  101. BOOST_USING_STD_MIN();
  102. if (u_parent != u)
  103. {
  104. put(low, u_parent,
  105. min BOOST_PREVENT_MACRO_SUBSTITUTION(
  106. u_lowpoint, u_parent_lowpoint));
  107. }
  108. }
  109. LowPointMap low;
  110. DFSParentMap parent;
  111. DFSNumberMap df_number;
  112. LeastAncestorMap least_ancestor;
  113. DFSParentEdgeMap df_edge;
  114. SizeType count;
  115. };
  116. template < typename Graph, typename VertexIndexMap,
  117. typename StoreOldHandlesPolicy = graph::detail::store_old_handles,
  118. typename StoreEmbeddingPolicy = graph::detail::recursive_lazy_list >
  119. class boyer_myrvold_impl
  120. {
  121. typedef typename graph_traits< Graph >::vertices_size_type v_size_t;
  122. typedef typename graph_traits< Graph >::vertex_descriptor vertex_t;
  123. typedef typename graph_traits< Graph >::edge_descriptor edge_t;
  124. typedef typename graph_traits< Graph >::vertex_iterator vertex_iterator_t;
  125. typedef typename graph_traits< Graph >::edge_iterator edge_iterator_t;
  126. typedef
  127. typename graph_traits< Graph >::out_edge_iterator out_edge_iterator_t;
  128. typedef graph::detail::face_handle< Graph, StoreOldHandlesPolicy,
  129. StoreEmbeddingPolicy >
  130. face_handle_t;
  131. typedef std::vector< vertex_t > vertex_vector_t;
  132. typedef std::vector< edge_t > edge_vector_t;
  133. typedef std::list< vertex_t > vertex_list_t;
  134. typedef std::list< face_handle_t > face_handle_list_t;
  135. typedef boost::shared_ptr< face_handle_list_t > face_handle_list_ptr_t;
  136. typedef boost::shared_ptr< vertex_list_t > vertex_list_ptr_t;
  137. typedef boost::tuple< vertex_t, bool, bool > merge_stack_frame_t;
  138. typedef std::vector< merge_stack_frame_t > merge_stack_t;
  139. template < typename T > struct map_vertex_to_
  140. {
  141. typedef iterator_property_map< typename std::vector< T >::iterator,
  142. VertexIndexMap >
  143. type;
  144. };
  145. typedef typename map_vertex_to_< v_size_t >::type vertex_to_v_size_map_t;
  146. typedef typename map_vertex_to_< vertex_t >::type vertex_to_vertex_map_t;
  147. typedef typename map_vertex_to_< edge_t >::type vertex_to_edge_map_t;
  148. typedef typename map_vertex_to_< vertex_list_ptr_t >::type
  149. vertex_to_vertex_list_ptr_map_t;
  150. typedef typename map_vertex_to_< edge_vector_t >::type
  151. vertex_to_edge_vector_map_t;
  152. typedef typename map_vertex_to_< bool >::type vertex_to_bool_map_t;
  153. typedef typename map_vertex_to_< face_handle_t >::type
  154. vertex_to_face_handle_map_t;
  155. typedef typename map_vertex_to_< face_handle_list_ptr_t >::type
  156. vertex_to_face_handle_list_ptr_map_t;
  157. typedef typename map_vertex_to_< typename vertex_list_t::iterator >::type
  158. vertex_to_separated_node_map_t;
  159. template < typename BicompSideToTraverse = single_side,
  160. typename VisitorType = lead_visitor, typename Time = current_iteration >
  161. struct face_vertex_iterator
  162. {
  163. typedef face_iterator< Graph, vertex_to_face_handle_map_t, vertex_t,
  164. BicompSideToTraverse, VisitorType, Time >
  165. type;
  166. };
  167. template < typename BicompSideToTraverse = single_side,
  168. typename Time = current_iteration >
  169. struct face_edge_iterator
  170. {
  171. typedef face_iterator< Graph, vertex_to_face_handle_map_t, edge_t,
  172. BicompSideToTraverse, lead_visitor, Time >
  173. type;
  174. };
  175. public:
  176. boyer_myrvold_impl(const Graph& arg_g, VertexIndexMap arg_vm)
  177. : g(arg_g)
  178. , vm(arg_vm)
  179. ,
  180. low_point_vector(num_vertices(g))
  181. , dfs_parent_vector(num_vertices(g))
  182. , dfs_number_vector(num_vertices(g))
  183. , least_ancestor_vector(num_vertices(g))
  184. , pertinent_roots_vector(num_vertices(g))
  185. , backedge_flag_vector(num_vertices(g), num_vertices(g) + 1)
  186. , visited_vector(num_vertices(g), num_vertices(g) + 1)
  187. , face_handles_vector(num_vertices(g))
  188. , dfs_child_handles_vector(num_vertices(g))
  189. , separated_dfs_child_list_vector(num_vertices(g))
  190. , separated_node_in_parent_list_vector(num_vertices(g))
  191. , canonical_dfs_child_vector(num_vertices(g))
  192. , flipped_vector(num_vertices(g), false)
  193. , backedges_vector(num_vertices(g))
  194. , dfs_parent_edge_vector(num_vertices(g))
  195. ,
  196. vertices_by_dfs_num(num_vertices(g))
  197. ,
  198. low_point(low_point_vector.begin(), vm)
  199. , dfs_parent(dfs_parent_vector.begin(), vm)
  200. , dfs_number(dfs_number_vector.begin(), vm)
  201. , least_ancestor(least_ancestor_vector.begin(), vm)
  202. , pertinent_roots(pertinent_roots_vector.begin(), vm)
  203. , backedge_flag(backedge_flag_vector.begin(), vm)
  204. , visited(visited_vector.begin(), vm)
  205. , face_handles(face_handles_vector.begin(), vm)
  206. , dfs_child_handles(dfs_child_handles_vector.begin(), vm)
  207. , separated_dfs_child_list(separated_dfs_child_list_vector.begin(), vm)
  208. , separated_node_in_parent_list(
  209. separated_node_in_parent_list_vector.begin(), vm)
  210. , canonical_dfs_child(canonical_dfs_child_vector.begin(), vm)
  211. , flipped(flipped_vector.begin(), vm)
  212. , backedges(backedges_vector.begin(), vm)
  213. , dfs_parent_edge(dfs_parent_edge_vector.begin(), vm)
  214. {
  215. planar_dfs_visitor< vertex_to_v_size_map_t, vertex_to_vertex_map_t,
  216. vertex_to_v_size_map_t, vertex_to_v_size_map_t,
  217. vertex_to_edge_map_t, v_size_t >
  218. vis(low_point, dfs_parent, dfs_number, least_ancestor,
  219. dfs_parent_edge);
  220. // Perform a depth-first search to find each vertex's low point, least
  221. // ancestor, and dfs tree information
  222. depth_first_search(g, visitor(vis).vertex_index_map(vm));
  223. // Sort vertices by their lowpoint - need this later in the constructor
  224. vertex_vector_t vertices_by_lowpoint(num_vertices(g));
  225. std::copy(vertices(g).first, vertices(g).second,
  226. vertices_by_lowpoint.begin());
  227. bucket_sort(vertices_by_lowpoint.begin(), vertices_by_lowpoint.end(),
  228. low_point, num_vertices(g));
  229. // Sort vertices by their dfs number - need this to iterate by reverse
  230. // DFS number in the main loop.
  231. std::copy(
  232. vertices(g).first, vertices(g).second, vertices_by_dfs_num.begin());
  233. bucket_sort(vertices_by_dfs_num.begin(), vertices_by_dfs_num.end(),
  234. dfs_number, num_vertices(g));
  235. // Initialize face handles. A face handle is an abstraction that serves
  236. // two uses in our implementation - it allows us to efficiently move
  237. // along the outer face of embedded bicomps in a partially embedded
  238. // graph, and it provides storage for the planar embedding. Face
  239. // handles are implemented by a sequence of edges and are associated
  240. // with a particular vertex - the sequence of edges represents the
  241. // current embedding of edges around that vertex, and the first and
  242. // last edges in the sequence represent the pair of edges on the outer
  243. // face that are adjacent to the associated vertex. This lets us embed
  244. // edges in the graph by just pushing them on the front or back of the
  245. // sequence of edges held by the face handles.
  246. //
  247. // Our algorithm starts with a DFS tree of edges (where every vertex is
  248. // an articulation point and every edge is a singleton bicomp) and
  249. // repeatedly merges bicomps by embedding additional edges. Note that
  250. // any bicomp at any point in the algorithm can be associated with a
  251. // unique edge connecting the vertex of that bicomp with the lowest DFS
  252. // number (which we refer to as the "root" of the bicomp) with its DFS
  253. // child in the bicomp: the existence of two such edges would contradict
  254. // the properties of a DFS tree. We refer to the DFS child of the root
  255. // of a bicomp as the "canonical DFS child" of the bicomp. Note that a
  256. // vertex can be the root of more than one bicomp.
  257. //
  258. // We move around the external faces of a bicomp using a few property
  259. // maps, which we'll initialize presently:
  260. //
  261. // - face_handles: maps a vertex to a face handle that can be used to
  262. // move "up" a bicomp. For a vertex that isn't an articulation point,
  263. // this holds the face handles that can be used to move around that
  264. // vertex's unique bicomp. For a vertex that is an articulation point,
  265. // this holds the face handles associated with the unique bicomp that
  266. // the vertex is NOT the root of. These handles can therefore be used
  267. // to move from any point on the outer face of the tree of bicomps
  268. // around the current outer face towards the root of the DFS tree.
  269. //
  270. // - dfs_child_handles: these are used to hold face handles for
  271. // vertices that are articulation points - dfs_child_handles[v] holds
  272. // the face handles corresponding to vertex u in the bicomp with root
  273. // u and canonical DFS child v.
  274. //
  275. // - canonical_dfs_child: this property map allows one to determine the
  276. // canonical DFS child of a bicomp while traversing the outer face.
  277. // This property map is only valid when applied to one of the two
  278. // vertices adjacent to the root of the bicomp on the outer face. To
  279. // be more precise, if v is the canonical DFS child of a bicomp,
  280. // canonical_dfs_child[dfs_child_handles[v].first_vertex()] == v and
  281. // canonical_dfs_child[dfs_child_handles[v].second_vertex()] == v.
  282. //
  283. // - pertinent_roots: given a vertex v, pertinent_roots[v] contains a
  284. // list of face handles pointing to the top of bicomps that need to
  285. // be visited by the current walkdown traversal (since they lead to
  286. // backedges that need to be embedded). These lists are populated by
  287. // the walkup and consumed by the walkdown.
  288. vertex_iterator_t vi, vi_end;
  289. for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
  290. {
  291. vertex_t v(*vi);
  292. vertex_t parent = dfs_parent[v];
  293. if (parent != v)
  294. {
  295. edge_t parent_edge = dfs_parent_edge[v];
  296. add_to_embedded_edges(parent_edge, StoreOldHandlesPolicy());
  297. face_handles[v] = face_handle_t(v, parent_edge, g);
  298. dfs_child_handles[v] = face_handle_t(parent, parent_edge, g);
  299. }
  300. else
  301. {
  302. face_handles[v] = face_handle_t(v);
  303. dfs_child_handles[v] = face_handle_t(parent);
  304. }
  305. canonical_dfs_child[v] = v;
  306. pertinent_roots[v] = face_handle_list_ptr_t(new face_handle_list_t);
  307. separated_dfs_child_list[v] = vertex_list_ptr_t(new vertex_list_t);
  308. }
  309. // We need to create a list of not-yet-merged depth-first children for
  310. // each vertex that will be updated as bicomps get merged. We sort each
  311. // list by ascending lowpoint, which allows the externally_active
  312. // function to run in constant time, and we keep a pointer to each
  313. // vertex's representation in its parent's list, which allows merging
  314. // in constant time.
  315. for (typename vertex_vector_t::iterator itr
  316. = vertices_by_lowpoint.begin();
  317. itr != vertices_by_lowpoint.end(); ++itr)
  318. {
  319. vertex_t v(*itr);
  320. vertex_t parent(dfs_parent[v]);
  321. if (v != parent)
  322. {
  323. separated_node_in_parent_list[v]
  324. = separated_dfs_child_list[parent]->insert(
  325. separated_dfs_child_list[parent]->end(), v);
  326. }
  327. }
  328. // The merge stack holds path information during a walkdown iteration
  329. merge_stack.reserve(num_vertices(g));
  330. }
  331. bool is_planar()
  332. {
  333. // This is the main algorithm: starting with a DFS tree of embedded
  334. // edges (which, since it's a tree, is planar), iterate through all
  335. // vertices by reverse DFS number, attempting to embed all backedges
  336. // connecting the current vertex to vertices with higher DFS numbers.
  337. //
  338. // The walkup is a procedure that examines all such backedges and sets
  339. // up the required data structures so that they can be searched by the
  340. // walkdown in linear time. The walkdown does the actual work of
  341. // embedding edges and flipping bicomps, and can identify when it has
  342. // come across a kuratowski subgraph.
  343. //
  344. // store_old_face_handles caches face handles from the previous
  345. // iteration - this is used only for the kuratowski subgraph isolation,
  346. // and is therefore dispatched based on the StoreOldHandlesPolicy.
  347. //
  348. // clean_up_embedding does some clean-up and fills in values that have
  349. // to be computed lazily during the actual execution of the algorithm
  350. // (for instance, whether or not a bicomp is flipped in the final
  351. // embedding). It's dispatched on the the StoreEmbeddingPolicy, since
  352. // it's not needed if an embedding isn't desired.
  353. typename vertex_vector_t::reverse_iterator vi, vi_end;
  354. vi_end = vertices_by_dfs_num.rend();
  355. for (vi = vertices_by_dfs_num.rbegin(); vi != vi_end; ++vi)
  356. {
  357. store_old_face_handles(StoreOldHandlesPolicy());
  358. vertex_t v(*vi);
  359. walkup(v);
  360. if (!walkdown(v))
  361. return false;
  362. }
  363. clean_up_embedding(StoreEmbeddingPolicy());
  364. return true;
  365. }
  366. private:
  367. void walkup(vertex_t v)
  368. {
  369. // The point of the walkup is to follow all backedges from v to
  370. // vertices with higher DFS numbers, and update pertinent_roots
  371. // for the bicomp roots on the path from backedge endpoints up
  372. // to v. This will set the stage for the walkdown to efficiently
  373. // traverse the graph of bicomps down from v.
  374. typedef
  375. typename face_vertex_iterator< both_sides >::type walkup_iterator_t;
  376. out_edge_iterator_t oi, oi_end;
  377. for (boost::tie(oi, oi_end) = out_edges(v, g); oi != oi_end; ++oi)
  378. {
  379. edge_t e(*oi);
  380. vertex_t e_source(source(e, g));
  381. vertex_t e_target(target(e, g));
  382. if (e_source == e_target)
  383. {
  384. self_loops.push_back(e);
  385. continue;
  386. }
  387. vertex_t w(e_source == v ? e_target : e_source);
  388. // continue if not a back edge or already embedded
  389. if (dfs_number[w] < dfs_number[v] || e == dfs_parent_edge[w])
  390. continue;
  391. backedges[w].push_back(e);
  392. v_size_t timestamp = dfs_number[v];
  393. backedge_flag[w] = timestamp;
  394. walkup_iterator_t walkup_itr(w, face_handles);
  395. walkup_iterator_t walkup_end;
  396. vertex_t lead_vertex = w;
  397. while (true)
  398. {
  399. // Move to the root of the current bicomp or the first visited
  400. // vertex on the bicomp by going up each side in parallel
  401. while (walkup_itr != walkup_end
  402. && visited[*walkup_itr] != timestamp)
  403. {
  404. lead_vertex = *walkup_itr;
  405. visited[lead_vertex] = timestamp;
  406. ++walkup_itr;
  407. }
  408. // If we've found the root of a bicomp through a path we haven't
  409. // seen before, update pertinent_roots with a handle to the
  410. // current bicomp. Otherwise, we've just seen a path we've been
  411. // up before, so break out of the main while loop.
  412. if (walkup_itr == walkup_end)
  413. {
  414. vertex_t dfs_child = canonical_dfs_child[lead_vertex];
  415. vertex_t parent = dfs_parent[dfs_child];
  416. visited[dfs_child_handles[dfs_child].first_vertex()]
  417. = timestamp;
  418. visited[dfs_child_handles[dfs_child].second_vertex()]
  419. = timestamp;
  420. if (low_point[dfs_child] < dfs_number[v]
  421. || least_ancestor[dfs_child] < dfs_number[v])
  422. {
  423. pertinent_roots[parent]->push_back(
  424. dfs_child_handles[dfs_child]);
  425. }
  426. else
  427. {
  428. pertinent_roots[parent]->push_front(
  429. dfs_child_handles[dfs_child]);
  430. }
  431. if (parent != v && visited[parent] != timestamp)
  432. {
  433. walkup_itr = walkup_iterator_t(parent, face_handles);
  434. lead_vertex = parent;
  435. }
  436. else
  437. break;
  438. }
  439. else
  440. break;
  441. }
  442. }
  443. }
  444. bool walkdown(vertex_t v)
  445. {
  446. // This procedure is where all of the action is - pertinent_roots
  447. // has already been set up by the walkup, so we just need to move
  448. // down bicomps from v until we find vertices that have been
  449. // labeled as backedge endpoints. Once we find such a vertex, we
  450. // embed the corresponding edge and glue together the bicomps on
  451. // the path connecting the two vertices in the edge. This may
  452. // involve flipping bicomps along the way.
  453. vertex_t w; // the other endpoint of the edge we're embedding
  454. while (!pertinent_roots[v]->empty())
  455. {
  456. face_handle_t root_face_handle = pertinent_roots[v]->front();
  457. face_handle_t curr_face_handle = root_face_handle;
  458. pertinent_roots[v]->pop_front();
  459. merge_stack.clear();
  460. while (true)
  461. {
  462. typename face_vertex_iterator<>::type first_face_itr,
  463. second_face_itr, face_end;
  464. vertex_t first_side_vertex
  465. = graph_traits< Graph >::null_vertex();
  466. vertex_t second_side_vertex
  467. = graph_traits< Graph >::null_vertex();
  468. vertex_t first_tail, second_tail;
  469. first_tail = second_tail = curr_face_handle.get_anchor();
  470. first_face_itr = typename face_vertex_iterator<>::type(
  471. curr_face_handle, face_handles, first_side());
  472. second_face_itr = typename face_vertex_iterator<>::type(
  473. curr_face_handle, face_handles, second_side());
  474. for (; first_face_itr != face_end; ++first_face_itr)
  475. {
  476. vertex_t face_vertex(*first_face_itr);
  477. if (pertinent(face_vertex, v)
  478. || externally_active(face_vertex, v))
  479. {
  480. first_side_vertex = face_vertex;
  481. second_side_vertex = face_vertex;
  482. break;
  483. }
  484. first_tail = face_vertex;
  485. }
  486. if (first_side_vertex == graph_traits< Graph >::null_vertex()
  487. || first_side_vertex == curr_face_handle.get_anchor())
  488. break;
  489. for (; second_face_itr != face_end; ++second_face_itr)
  490. {
  491. vertex_t face_vertex(*second_face_itr);
  492. if (pertinent(face_vertex, v)
  493. || externally_active(face_vertex, v))
  494. {
  495. second_side_vertex = face_vertex;
  496. break;
  497. }
  498. second_tail = face_vertex;
  499. }
  500. vertex_t chosen;
  501. bool chose_first_upper_path;
  502. if (internally_active(first_side_vertex, v))
  503. {
  504. chosen = first_side_vertex;
  505. chose_first_upper_path = true;
  506. }
  507. else if (internally_active(second_side_vertex, v))
  508. {
  509. chosen = second_side_vertex;
  510. chose_first_upper_path = false;
  511. }
  512. else if (pertinent(first_side_vertex, v))
  513. {
  514. chosen = first_side_vertex;
  515. chose_first_upper_path = true;
  516. }
  517. else if (pertinent(second_side_vertex, v))
  518. {
  519. chosen = second_side_vertex;
  520. chose_first_upper_path = false;
  521. }
  522. else
  523. {
  524. // If there's a pertinent vertex on the lower face
  525. // between the first_face_itr and the second_face_itr,
  526. // this graph isn't planar.
  527. for (; *first_face_itr != second_side_vertex;
  528. ++first_face_itr)
  529. {
  530. vertex_t p(*first_face_itr);
  531. if (pertinent(p, v))
  532. {
  533. // Found a Kuratowski subgraph
  534. kuratowski_v = v;
  535. kuratowski_x = first_side_vertex;
  536. kuratowski_y = second_side_vertex;
  537. return false;
  538. }
  539. }
  540. // Otherwise, the fact that we didn't find a pertinent
  541. // vertex on this face is fine - we should set the
  542. // short-circuit edges and break out of this loop to
  543. // start looking at a different pertinent root.
  544. if (first_side_vertex == second_side_vertex)
  545. {
  546. if (first_tail != v)
  547. {
  548. vertex_t first
  549. = face_handles[first_tail].first_vertex();
  550. vertex_t second
  551. = face_handles[first_tail].second_vertex();
  552. boost::tie(first_side_vertex, first_tail)
  553. = make_tuple(first_tail,
  554. first == first_side_vertex ? second
  555. : first);
  556. }
  557. else if (second_tail != v)
  558. {
  559. vertex_t first
  560. = face_handles[second_tail].first_vertex();
  561. vertex_t second
  562. = face_handles[second_tail].second_vertex();
  563. boost::tie(second_side_vertex, second_tail)
  564. = make_tuple(second_tail,
  565. first == second_side_vertex ? second
  566. : first);
  567. }
  568. else
  569. break;
  570. }
  571. canonical_dfs_child[first_side_vertex]
  572. = canonical_dfs_child[root_face_handle.first_vertex()];
  573. canonical_dfs_child[second_side_vertex]
  574. = canonical_dfs_child[root_face_handle.second_vertex()];
  575. root_face_handle.set_first_vertex(first_side_vertex);
  576. root_face_handle.set_second_vertex(second_side_vertex);
  577. if (face_handles[first_side_vertex].first_vertex()
  578. == first_tail)
  579. face_handles[first_side_vertex].set_first_vertex(v);
  580. else
  581. face_handles[first_side_vertex].set_second_vertex(v);
  582. if (face_handles[second_side_vertex].first_vertex()
  583. == second_tail)
  584. face_handles[second_side_vertex].set_first_vertex(v);
  585. else
  586. face_handles[second_side_vertex].set_second_vertex(v);
  587. break;
  588. }
  589. // When we unwind the stack, we need to know which direction
  590. // we came down from on the top face handle
  591. bool chose_first_lower_path
  592. = (chose_first_upper_path
  593. && face_handles[chosen].first_vertex() == first_tail)
  594. || (!chose_first_upper_path
  595. && face_handles[chosen].first_vertex() == second_tail);
  596. // If there's a backedge at the chosen vertex, embed it now
  597. if (backedge_flag[chosen] == dfs_number[v])
  598. {
  599. w = chosen;
  600. backedge_flag[chosen] = num_vertices(g) + 1;
  601. add_to_merge_points(chosen, StoreOldHandlesPolicy());
  602. typename edge_vector_t::iterator ei, ei_end;
  603. ei_end = backedges[chosen].end();
  604. for (ei = backedges[chosen].begin(); ei != ei_end; ++ei)
  605. {
  606. edge_t e(*ei);
  607. add_to_embedded_edges(e, StoreOldHandlesPolicy());
  608. if (chose_first_lower_path)
  609. face_handles[chosen].push_first(e, g);
  610. else
  611. face_handles[chosen].push_second(e, g);
  612. }
  613. }
  614. else
  615. {
  616. merge_stack.push_back(make_tuple(chosen,
  617. chose_first_upper_path, chose_first_lower_path));
  618. curr_face_handle = *pertinent_roots[chosen]->begin();
  619. continue;
  620. }
  621. // Unwind the merge stack to the root, merging all bicomps
  622. bool bottom_path_follows_first;
  623. bool top_path_follows_first;
  624. bool next_bottom_follows_first = chose_first_upper_path;
  625. vertex_t merge_point = chosen;
  626. while (!merge_stack.empty())
  627. {
  628. bottom_path_follows_first = next_bottom_follows_first;
  629. boost::tie(merge_point, next_bottom_follows_first,
  630. top_path_follows_first)
  631. = merge_stack.back();
  632. merge_stack.pop_back();
  633. face_handle_t top_handle(face_handles[merge_point]);
  634. face_handle_t bottom_handle(
  635. *pertinent_roots[merge_point]->begin());
  636. vertex_t bottom_dfs_child = canonical_dfs_child
  637. [pertinent_roots[merge_point]->begin()->first_vertex()];
  638. remove_vertex_from_separated_dfs_child_list(
  639. canonical_dfs_child[pertinent_roots[merge_point]
  640. ->begin()
  641. ->first_vertex()]);
  642. pertinent_roots[merge_point]->pop_front();
  643. add_to_merge_points(
  644. top_handle.get_anchor(), StoreOldHandlesPolicy());
  645. if (top_path_follows_first && bottom_path_follows_first)
  646. {
  647. bottom_handle.flip();
  648. top_handle.glue_first_to_second(bottom_handle);
  649. }
  650. else if (!top_path_follows_first
  651. && bottom_path_follows_first)
  652. {
  653. flipped[bottom_dfs_child] = true;
  654. top_handle.glue_second_to_first(bottom_handle);
  655. }
  656. else if (top_path_follows_first
  657. && !bottom_path_follows_first)
  658. {
  659. flipped[bottom_dfs_child] = true;
  660. top_handle.glue_first_to_second(bottom_handle);
  661. }
  662. else //! top_path_follows_first &&
  663. //! !bottom_path_follows_first
  664. {
  665. bottom_handle.flip();
  666. top_handle.glue_second_to_first(bottom_handle);
  667. }
  668. }
  669. // Finally, embed all edges (v,w) at their upper end points
  670. canonical_dfs_child[w]
  671. = canonical_dfs_child[root_face_handle.first_vertex()];
  672. add_to_merge_points(
  673. root_face_handle.get_anchor(), StoreOldHandlesPolicy());
  674. typename edge_vector_t::iterator ei, ei_end;
  675. ei_end = backedges[chosen].end();
  676. for (ei = backedges[chosen].begin(); ei != ei_end; ++ei)
  677. {
  678. if (next_bottom_follows_first)
  679. root_face_handle.push_first(*ei, g);
  680. else
  681. root_face_handle.push_second(*ei, g);
  682. }
  683. backedges[chosen].clear();
  684. curr_face_handle = root_face_handle;
  685. } // while(true)
  686. } // while(!pertinent_roots[v]->empty())
  687. return true;
  688. }
  689. void store_old_face_handles(graph::detail::no_old_handles) {}
  690. void store_old_face_handles(graph::detail::store_old_handles)
  691. {
  692. for (typename std::vector< vertex_t >::iterator mp_itr
  693. = current_merge_points.begin();
  694. mp_itr != current_merge_points.end(); ++mp_itr)
  695. {
  696. face_handles[*mp_itr].store_old_face_handles();
  697. }
  698. current_merge_points.clear();
  699. }
  700. void add_to_merge_points(vertex_t, graph::detail::no_old_handles) {}
  701. void add_to_merge_points(vertex_t v, graph::detail::store_old_handles)
  702. {
  703. current_merge_points.push_back(v);
  704. }
  705. void add_to_embedded_edges(edge_t, graph::detail::no_old_handles) {}
  706. void add_to_embedded_edges(edge_t e, graph::detail::store_old_handles)
  707. {
  708. embedded_edges.push_back(e);
  709. }
  710. void clean_up_embedding(graph::detail::no_embedding) {}
  711. void clean_up_embedding(graph::detail::store_embedding)
  712. {
  713. // If the graph isn't biconnected, we'll still have entries
  714. // in the separated_dfs_child_list for some vertices. Since
  715. // these represent articulation points, we can obtain a
  716. // planar embedding no matter what order we embed them in.
  717. vertex_iterator_t xi, xi_end;
  718. for (boost::tie(xi, xi_end) = vertices(g); xi != xi_end; ++xi)
  719. {
  720. if (!separated_dfs_child_list[*xi]->empty())
  721. {
  722. typename vertex_list_t::iterator yi, yi_end;
  723. yi_end = separated_dfs_child_list[*xi]->end();
  724. for (yi = separated_dfs_child_list[*xi]->begin(); yi != yi_end;
  725. ++yi)
  726. {
  727. dfs_child_handles[*yi].flip();
  728. face_handles[*xi].glue_first_to_second(
  729. dfs_child_handles[*yi]);
  730. }
  731. }
  732. }
  733. // Up until this point, we've flipped bicomps lazily by setting
  734. // flipped[v] to true if the bicomp rooted at v was flipped (the
  735. // lazy aspect of this flip is that all descendents of that vertex
  736. // need to have their orientations reversed as well). Now, we
  737. // traverse the DFS tree by DFS number and perform the actual
  738. // flipping as needed
  739. typedef typename vertex_vector_t::iterator vertex_vector_itr_t;
  740. vertex_vector_itr_t vi_end = vertices_by_dfs_num.end();
  741. for (vertex_vector_itr_t vi = vertices_by_dfs_num.begin(); vi != vi_end;
  742. ++vi)
  743. {
  744. vertex_t v(*vi);
  745. bool v_flipped = flipped[v];
  746. bool p_flipped = flipped[dfs_parent[v]];
  747. if (v_flipped && !p_flipped)
  748. {
  749. face_handles[v].flip();
  750. }
  751. else if (p_flipped && !v_flipped)
  752. {
  753. face_handles[v].flip();
  754. flipped[v] = true;
  755. }
  756. else
  757. {
  758. flipped[v] = false;
  759. }
  760. }
  761. // If there are any self-loops in the graph, they were flagged
  762. // during the walkup, and we should add them to the embedding now.
  763. // Adding a self loop anywhere in the embedding could never
  764. // invalidate the embedding, but they would complicate the traversal
  765. // if they were added during the walkup/walkdown.
  766. typename edge_vector_t::iterator ei, ei_end;
  767. ei_end = self_loops.end();
  768. for (ei = self_loops.begin(); ei != ei_end; ++ei)
  769. {
  770. edge_t e(*ei);
  771. face_handles[source(e, g)].push_second(e, g);
  772. }
  773. }
  774. bool pertinent(vertex_t w, vertex_t v)
  775. {
  776. // w is pertinent with respect to v if there is a backedge (v,w) or if
  777. // w is the root of a bicomp that contains a pertinent vertex.
  778. return backedge_flag[w] == dfs_number[v]
  779. || !pertinent_roots[w]->empty();
  780. }
  781. bool externally_active(vertex_t w, vertex_t v)
  782. {
  783. // Let a be any proper depth-first search ancestor of v. w is externally
  784. // active with respect to v if there exists a backedge (a,w) or a
  785. // backedge (a,w_0) for some w_0 in a descendent bicomp of w.
  786. v_size_t dfs_number_of_v = dfs_number[v];
  787. return (least_ancestor[w] < dfs_number_of_v)
  788. || (!separated_dfs_child_list[w]->empty()
  789. && low_point[separated_dfs_child_list[w]->front()]
  790. < dfs_number_of_v);
  791. }
  792. bool internally_active(vertex_t w, vertex_t v)
  793. {
  794. return pertinent(w, v) && !externally_active(w, v);
  795. }
  796. void remove_vertex_from_separated_dfs_child_list(vertex_t v)
  797. {
  798. typename vertex_list_t::iterator to_delete
  799. = separated_node_in_parent_list[v];
  800. garbage.splice(garbage.end(), *separated_dfs_child_list[dfs_parent[v]],
  801. to_delete, boost::next(to_delete));
  802. }
  803. // End of the implementation of the basic Boyer-Myrvold Algorithm. The rest
  804. // of the code below implements the isolation of a Kuratowski subgraph in
  805. // the case that the input graph is not planar. This is by far the most
  806. // complicated part of the implementation.
  807. public:
  808. template < typename EdgeToBoolPropertyMap, typename EdgeContainer >
  809. vertex_t kuratowski_walkup(vertex_t v, EdgeToBoolPropertyMap forbidden_edge,
  810. EdgeToBoolPropertyMap goal_edge, EdgeToBoolPropertyMap is_embedded,
  811. EdgeContainer& path_edges)
  812. {
  813. vertex_t current_endpoint;
  814. bool seen_goal_edge = false;
  815. out_edge_iterator_t oi, oi_end;
  816. for (boost::tie(oi, oi_end) = out_edges(v, g); oi != oi_end; ++oi)
  817. forbidden_edge[*oi] = true;
  818. for (boost::tie(oi, oi_end) = out_edges(v, g); oi != oi_end; ++oi)
  819. {
  820. path_edges.clear();
  821. edge_t e(*oi);
  822. current_endpoint
  823. = target(*oi, g) == v ? source(*oi, g) : target(*oi, g);
  824. if (dfs_number[current_endpoint] < dfs_number[v] || is_embedded[e]
  825. || v == current_endpoint // self-loop
  826. )
  827. {
  828. // Not a backedge
  829. continue;
  830. }
  831. path_edges.push_back(e);
  832. if (goal_edge[e])
  833. {
  834. return current_endpoint;
  835. }
  836. typedef typename face_edge_iterator<>::type walkup_itr_t;
  837. walkup_itr_t walkup_itr(
  838. current_endpoint, face_handles, first_side());
  839. walkup_itr_t walkup_end;
  840. seen_goal_edge = false;
  841. while (true)
  842. {
  843. if (walkup_itr != walkup_end && forbidden_edge[*walkup_itr])
  844. break;
  845. while (walkup_itr != walkup_end && !goal_edge[*walkup_itr]
  846. && !forbidden_edge[*walkup_itr])
  847. {
  848. edge_t f(*walkup_itr);
  849. forbidden_edge[f] = true;
  850. path_edges.push_back(f);
  851. current_endpoint = source(f, g) == current_endpoint
  852. ? target(f, g)
  853. : source(f, g);
  854. ++walkup_itr;
  855. }
  856. if (walkup_itr != walkup_end && goal_edge[*walkup_itr])
  857. {
  858. path_edges.push_back(*walkup_itr);
  859. seen_goal_edge = true;
  860. break;
  861. }
  862. walkup_itr = walkup_itr_t(
  863. current_endpoint, face_handles, first_side());
  864. }
  865. if (seen_goal_edge)
  866. break;
  867. }
  868. if (seen_goal_edge)
  869. return current_endpoint;
  870. else
  871. return graph_traits< Graph >::null_vertex();
  872. }
  873. template < typename OutputIterator, typename EdgeIndexMap >
  874. void extract_kuratowski_subgraph(OutputIterator o_itr, EdgeIndexMap em)
  875. {
  876. // If the main algorithm has failed to embed one of the back-edges from
  877. // a vertex v, we can use the current state of the algorithm to isolate
  878. // a Kuratowksi subgraph. The isolation process breaks down into five
  879. // cases, A - E. The general configuration of all five cases is shown in
  880. // figure 1. There is a vertex v from which the planar
  881. // v embedding process could not proceed. This means that
  882. // | there exists some bicomp containing three vertices
  883. // ----- x,y, and z as shown such that x and y are externally
  884. // | | active with respect to v (which means that there are
  885. // x y two vertices x_0 and y_0 such that (1) both x_0 and
  886. // | | y_0 are proper depth-first search ancestors of v and
  887. // --z-- (2) there are two disjoint paths, one connecting x
  888. // and x_0 and one connecting y and y_0, both
  889. // consisting
  890. // fig. 1 entirely of unembedded edges). Furthermore, there
  891. // exists a vertex z_0 such that z is a depth-first
  892. // search ancestor of z_0 and (v,z_0) is an unembedded back-edge from v.
  893. // x,y and z all exist on the same bicomp, which consists entirely of
  894. // embedded edges. The five subcases break down as follows, and are
  895. // handled by the algorithm logically in the order A-E: First, if v is
  896. // not on the same bicomp as x,y, and z, a K_3_3 can be isolated - this
  897. // is case A. So, we'll assume that v is on the same bicomp as x,y, and
  898. // z. If z_0 is on a different bicomp than x,y, and z, a K_3_3 can also
  899. // be isolated - this is a case B - so we'll assume from now on that v
  900. // is on the same bicomp as x, y, and z=z_0. In this case, one can use
  901. // properties of the Boyer-Myrvold algorithm to show the existence of an
  902. // "x-y path" connecting some vertex on the "left side" of the x,y,z
  903. // bicomp with some vertex on the "right side" of the bicomp (where the
  904. // left and right are split by a line drawn through v and z.If either of
  905. // the endpoints of the x-y path is above x or y on the bicomp, a K_3_3
  906. // can be isolated - this is a case C. Otherwise, both endpoints are at
  907. // or below x and y on the bicomp. If there is a vertex alpha on the x-y
  908. // path such that alpha is not x or y and there's a path from alpha to v
  909. // that's disjoint from any of the edges on the bicomp and the x-y path,
  910. // a K_3_3 can be isolated - this is a case D. Otherwise, properties of
  911. // the Boyer-Myrvold algorithm can be used to show that another vertex
  912. // w exists on the lower half of the bicomp such that w is externally
  913. // active with respect to v. w can then be used to isolate a K_5 - this
  914. // is the configuration of case E.
  915. vertex_iterator_t vi, vi_end;
  916. edge_iterator_t ei, ei_end;
  917. out_edge_iterator_t oei, oei_end;
  918. typename std::vector< edge_t >::iterator xi, xi_end;
  919. // Clear the short-circuit edges - these are needed for the planar
  920. // testing/embedding algorithm to run in linear time, but they'll
  921. // complicate the kuratowski subgraph isolation
  922. for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
  923. {
  924. face_handles[*vi].reset_vertex_cache();
  925. dfs_child_handles[*vi].reset_vertex_cache();
  926. }
  927. vertex_t v = kuratowski_v;
  928. vertex_t x = kuratowski_x;
  929. vertex_t y = kuratowski_y;
  930. typedef iterator_property_map< typename std::vector< bool >::iterator,
  931. EdgeIndexMap >
  932. edge_to_bool_map_t;
  933. std::vector< bool > is_in_subgraph_vector(num_edges(g), false);
  934. edge_to_bool_map_t is_in_subgraph(is_in_subgraph_vector.begin(), em);
  935. std::vector< bool > is_embedded_vector(num_edges(g), false);
  936. edge_to_bool_map_t is_embedded(is_embedded_vector.begin(), em);
  937. typename std::vector< edge_t >::iterator embedded_itr, embedded_end;
  938. embedded_end = embedded_edges.end();
  939. for (embedded_itr = embedded_edges.begin();
  940. embedded_itr != embedded_end; ++embedded_itr)
  941. is_embedded[*embedded_itr] = true;
  942. // upper_face_vertex is true for x,y, and all vertices above x and y in
  943. // the bicomp
  944. std::vector< bool > upper_face_vertex_vector(num_vertices(g), false);
  945. vertex_to_bool_map_t upper_face_vertex(
  946. upper_face_vertex_vector.begin(), vm);
  947. std::vector< bool > lower_face_vertex_vector(num_vertices(g), false);
  948. vertex_to_bool_map_t lower_face_vertex(
  949. lower_face_vertex_vector.begin(), vm);
  950. // These next few variable declarations are all things that we need
  951. // to find.
  952. vertex_t z = graph_traits< Graph >::null_vertex();
  953. vertex_t bicomp_root;
  954. vertex_t w = graph_traits< Graph >::null_vertex();
  955. face_handle_t w_handle;
  956. face_handle_t v_dfchild_handle;
  957. vertex_t first_x_y_path_endpoint = graph_traits< Graph >::null_vertex();
  958. vertex_t second_x_y_path_endpoint
  959. = graph_traits< Graph >::null_vertex();
  960. vertex_t w_ancestor = v;
  961. detail::bm_case_t chosen_case = detail::BM_NO_CASE_CHOSEN;
  962. std::vector< edge_t > x_external_path;
  963. std::vector< edge_t > y_external_path;
  964. std::vector< edge_t > case_d_edges;
  965. std::vector< edge_t > z_v_path;
  966. std::vector< edge_t > w_path;
  967. // first, use a walkup to find a path from V that starts with a
  968. // backedge from V, then goes up until it hits either X or Y
  969. //(but doesn't find X or Y as the root of a bicomp)
  970. typename face_vertex_iterator<>::type x_upper_itr(
  971. x, face_handles, first_side());
  972. typename face_vertex_iterator<>::type x_lower_itr(
  973. x, face_handles, second_side());
  974. typename face_vertex_iterator<>::type face_itr, face_end;
  975. // Don't know which path from x is the upper or lower path -
  976. // we'll find out here
  977. for (face_itr = x_upper_itr; face_itr != face_end; ++face_itr)
  978. {
  979. if (*face_itr == y)
  980. {
  981. std::swap(x_upper_itr, x_lower_itr);
  982. break;
  983. }
  984. }
  985. upper_face_vertex[x] = true;
  986. vertex_t current_vertex = x;
  987. vertex_t previous_vertex;
  988. for (face_itr = x_upper_itr; face_itr != face_end; ++face_itr)
  989. {
  990. previous_vertex = current_vertex;
  991. current_vertex = *face_itr;
  992. upper_face_vertex[current_vertex] = true;
  993. }
  994. v_dfchild_handle
  995. = dfs_child_handles[canonical_dfs_child[previous_vertex]];
  996. for (face_itr = x_lower_itr; *face_itr != y; ++face_itr)
  997. {
  998. vertex_t current_vertex(*face_itr);
  999. lower_face_vertex[current_vertex] = true;
  1000. typename face_handle_list_t::iterator roots_itr, roots_end;
  1001. if (w == graph_traits< Graph >::null_vertex()) // haven't found a w
  1002. // yet
  1003. {
  1004. roots_end = pertinent_roots[current_vertex]->end();
  1005. for (roots_itr = pertinent_roots[current_vertex]->begin();
  1006. roots_itr != roots_end; ++roots_itr)
  1007. {
  1008. if (low_point
  1009. [canonical_dfs_child[roots_itr->first_vertex()]]
  1010. < dfs_number[v])
  1011. {
  1012. w = current_vertex;
  1013. w_handle = *roots_itr;
  1014. break;
  1015. }
  1016. }
  1017. }
  1018. }
  1019. for (; face_itr != face_end; ++face_itr)
  1020. {
  1021. vertex_t current_vertex(*face_itr);
  1022. upper_face_vertex[current_vertex] = true;
  1023. bicomp_root = current_vertex;
  1024. }
  1025. typedef typename face_edge_iterator<>::type walkup_itr_t;
  1026. std::vector< bool > outer_face_edge_vector(num_edges(g), false);
  1027. edge_to_bool_map_t outer_face_edge(outer_face_edge_vector.begin(), em);
  1028. walkup_itr_t walkup_end;
  1029. for (walkup_itr_t walkup_itr(x, face_handles, first_side());
  1030. walkup_itr != walkup_end; ++walkup_itr)
  1031. {
  1032. outer_face_edge[*walkup_itr] = true;
  1033. is_in_subgraph[*walkup_itr] = true;
  1034. }
  1035. for (walkup_itr_t walkup_itr(x, face_handles, second_side());
  1036. walkup_itr != walkup_end; ++walkup_itr)
  1037. {
  1038. outer_face_edge[*walkup_itr] = true;
  1039. is_in_subgraph[*walkup_itr] = true;
  1040. }
  1041. std::vector< bool > forbidden_edge_vector(num_edges(g), false);
  1042. edge_to_bool_map_t forbidden_edge(forbidden_edge_vector.begin(), em);
  1043. std::vector< bool > goal_edge_vector(num_edges(g), false);
  1044. edge_to_bool_map_t goal_edge(goal_edge_vector.begin(), em);
  1045. // Find external path to x and to y
  1046. for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
  1047. {
  1048. edge_t e(*ei);
  1049. goal_edge[e] = !outer_face_edge[e]
  1050. && (source(e, g) == x || target(e, g) == x);
  1051. forbidden_edge[*ei] = outer_face_edge[*ei];
  1052. }
  1053. vertex_t x_ancestor = v;
  1054. vertex_t x_endpoint = graph_traits< Graph >::null_vertex();
  1055. while (x_endpoint == graph_traits< Graph >::null_vertex())
  1056. {
  1057. x_ancestor = dfs_parent[x_ancestor];
  1058. x_endpoint = kuratowski_walkup(x_ancestor, forbidden_edge,
  1059. goal_edge, is_embedded, x_external_path);
  1060. }
  1061. for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
  1062. {
  1063. edge_t e(*ei);
  1064. goal_edge[e] = !outer_face_edge[e]
  1065. && (source(e, g) == y || target(e, g) == y);
  1066. forbidden_edge[*ei] = outer_face_edge[*ei];
  1067. }
  1068. vertex_t y_ancestor = v;
  1069. vertex_t y_endpoint = graph_traits< Graph >::null_vertex();
  1070. while (y_endpoint == graph_traits< Graph >::null_vertex())
  1071. {
  1072. y_ancestor = dfs_parent[y_ancestor];
  1073. y_endpoint = kuratowski_walkup(y_ancestor, forbidden_edge,
  1074. goal_edge, is_embedded, y_external_path);
  1075. }
  1076. vertex_t parent, child;
  1077. // If v isn't on the same bicomp as x and y, it's a case A
  1078. if (bicomp_root != v)
  1079. {
  1080. chosen_case = detail::BM_CASE_A;
  1081. for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
  1082. if (lower_face_vertex[*vi])
  1083. for (boost::tie(oei, oei_end) = out_edges(*vi, g);
  1084. oei != oei_end; ++oei)
  1085. if (!outer_face_edge[*oei])
  1086. goal_edge[*oei] = true;
  1087. for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
  1088. forbidden_edge[*ei] = outer_face_edge[*ei];
  1089. z = kuratowski_walkup(
  1090. v, forbidden_edge, goal_edge, is_embedded, z_v_path);
  1091. }
  1092. else if (w != graph_traits< Graph >::null_vertex())
  1093. {
  1094. chosen_case = detail::BM_CASE_B;
  1095. for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
  1096. {
  1097. edge_t e(*ei);
  1098. goal_edge[e] = false;
  1099. forbidden_edge[e] = outer_face_edge[e];
  1100. }
  1101. goal_edge[w_handle.first_edge()] = true;
  1102. goal_edge[w_handle.second_edge()] = true;
  1103. z = kuratowski_walkup(
  1104. v, forbidden_edge, goal_edge, is_embedded, z_v_path);
  1105. for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
  1106. {
  1107. forbidden_edge[*ei] = outer_face_edge[*ei];
  1108. }
  1109. typename std::vector< edge_t >::iterator pi, pi_end;
  1110. pi_end = z_v_path.end();
  1111. for (pi = z_v_path.begin(); pi != pi_end; ++pi)
  1112. {
  1113. goal_edge[*pi] = true;
  1114. }
  1115. w_ancestor = v;
  1116. vertex_t w_endpoint = graph_traits< Graph >::null_vertex();
  1117. while (w_endpoint == graph_traits< Graph >::null_vertex())
  1118. {
  1119. w_ancestor = dfs_parent[w_ancestor];
  1120. w_endpoint = kuratowski_walkup(
  1121. w_ancestor, forbidden_edge, goal_edge, is_embedded, w_path);
  1122. }
  1123. // We really want both the w walkup and the z walkup to finish on
  1124. // exactly the same edge, but for convenience (since we don't have
  1125. // control over which side of a bicomp a walkup moves up) we've
  1126. // defined the walkup to either end at w_handle.first_edge() or
  1127. // w_handle.second_edge(). If both walkups ended at different edges,
  1128. // we'll do a little surgery on the w walkup path to make it follow
  1129. // the other side of the final bicomp.
  1130. if ((w_path.back() == w_handle.first_edge()
  1131. && z_v_path.back() == w_handle.second_edge())
  1132. || (w_path.back() == w_handle.second_edge()
  1133. && z_v_path.back() == w_handle.first_edge()))
  1134. {
  1135. walkup_itr_t wi, wi_end;
  1136. edge_t final_edge = w_path.back();
  1137. vertex_t anchor = source(final_edge, g) == w_handle.get_anchor()
  1138. ? target(final_edge, g)
  1139. : source(final_edge, g);
  1140. if (face_handles[anchor].first_edge() == final_edge)
  1141. wi = walkup_itr_t(anchor, face_handles, second_side());
  1142. else
  1143. wi = walkup_itr_t(anchor, face_handles, first_side());
  1144. w_path.pop_back();
  1145. for (; wi != wi_end; ++wi)
  1146. {
  1147. edge_t e(*wi);
  1148. if (w_path.back() == e)
  1149. w_path.pop_back();
  1150. else
  1151. w_path.push_back(e);
  1152. }
  1153. }
  1154. }
  1155. else
  1156. {
  1157. // We need to find a valid z, since the x-y path re-defines the
  1158. // lower face, and the z we found earlier may now be on the upper
  1159. // face.
  1160. chosen_case = detail::BM_CASE_E;
  1161. // The z we've used so far is just an externally active vertex on
  1162. // the lower face path, but may not be the z we need for a case C,
  1163. // D, or E subgraph. the z we need now is any externally active
  1164. // vertex on the lower face path with both old_face_handles edges on
  1165. // the outer face. Since we know an x-y path exists, such a z must
  1166. // also exist.
  1167. // TODO: find this z in the first place.
  1168. // find the new z
  1169. for (face_itr = x_lower_itr; *face_itr != y; ++face_itr)
  1170. {
  1171. vertex_t possible_z(*face_itr);
  1172. if (pertinent(possible_z, v)
  1173. && outer_face_edge[face_handles[possible_z]
  1174. .old_first_edge()]
  1175. && outer_face_edge[face_handles[possible_z]
  1176. .old_second_edge()])
  1177. {
  1178. z = possible_z;
  1179. break;
  1180. }
  1181. }
  1182. // find x-y path, and a w if one exists.
  1183. if (externally_active(z, v))
  1184. w = z;
  1185. typedef typename face_edge_iterator< single_side,
  1186. previous_iteration >::type old_face_iterator_t;
  1187. old_face_iterator_t first_old_face_itr(
  1188. z, face_handles, first_side());
  1189. old_face_iterator_t second_old_face_itr(
  1190. z, face_handles, second_side());
  1191. old_face_iterator_t old_face_itr, old_face_end;
  1192. std::vector< old_face_iterator_t > old_face_iterators;
  1193. old_face_iterators.push_back(first_old_face_itr);
  1194. old_face_iterators.push_back(second_old_face_itr);
  1195. std::vector< bool > x_y_path_vertex_vector(num_vertices(g), false);
  1196. vertex_to_bool_map_t x_y_path_vertex(
  1197. x_y_path_vertex_vector.begin(), vm);
  1198. typename std::vector< old_face_iterator_t >::iterator of_itr,
  1199. of_itr_end;
  1200. of_itr_end = old_face_iterators.end();
  1201. for (of_itr = old_face_iterators.begin(); of_itr != of_itr_end;
  1202. ++of_itr)
  1203. {
  1204. old_face_itr = *of_itr;
  1205. vertex_t previous_vertex;
  1206. bool seen_x_or_y = false;
  1207. vertex_t current_vertex = z;
  1208. for (; old_face_itr != old_face_end; ++old_face_itr)
  1209. {
  1210. edge_t e(*old_face_itr);
  1211. previous_vertex = current_vertex;
  1212. current_vertex = source(e, g) == current_vertex
  1213. ? target(e, g)
  1214. : source(e, g);
  1215. if (current_vertex == x || current_vertex == y)
  1216. seen_x_or_y = true;
  1217. if (w == graph_traits< Graph >::null_vertex()
  1218. && externally_active(current_vertex, v)
  1219. && outer_face_edge[e]
  1220. && outer_face_edge[*boost::next(old_face_itr)]
  1221. && !seen_x_or_y)
  1222. {
  1223. w = current_vertex;
  1224. }
  1225. if (!outer_face_edge[e])
  1226. {
  1227. if (!upper_face_vertex[current_vertex]
  1228. && !lower_face_vertex[current_vertex])
  1229. {
  1230. x_y_path_vertex[current_vertex] = true;
  1231. }
  1232. is_in_subgraph[e] = true;
  1233. if (upper_face_vertex[source(e, g)]
  1234. || lower_face_vertex[source(e, g)])
  1235. {
  1236. if (first_x_y_path_endpoint
  1237. == graph_traits< Graph >::null_vertex())
  1238. first_x_y_path_endpoint = source(e, g);
  1239. else
  1240. second_x_y_path_endpoint = source(e, g);
  1241. }
  1242. if (upper_face_vertex[target(e, g)]
  1243. || lower_face_vertex[target(e, g)])
  1244. {
  1245. if (first_x_y_path_endpoint
  1246. == graph_traits< Graph >::null_vertex())
  1247. first_x_y_path_endpoint = target(e, g);
  1248. else
  1249. second_x_y_path_endpoint = target(e, g);
  1250. }
  1251. }
  1252. else if (previous_vertex == x || previous_vertex == y)
  1253. {
  1254. chosen_case = detail::BM_CASE_C;
  1255. }
  1256. }
  1257. }
  1258. // Look for a case D - one of v's embedded edges will connect to the
  1259. // x-y path along an inner face path.
  1260. // First, get a list of all of v's embedded child edges
  1261. out_edge_iterator_t v_edge_itr, v_edge_end;
  1262. for (boost::tie(v_edge_itr, v_edge_end) = out_edges(v, g);
  1263. v_edge_itr != v_edge_end; ++v_edge_itr)
  1264. {
  1265. edge_t embedded_edge(*v_edge_itr);
  1266. if (!is_embedded[embedded_edge]
  1267. || embedded_edge == dfs_parent_edge[v])
  1268. continue;
  1269. case_d_edges.push_back(embedded_edge);
  1270. vertex_t current_vertex = source(embedded_edge, g) == v
  1271. ? target(embedded_edge, g)
  1272. : source(embedded_edge, g);
  1273. typename face_edge_iterator<>::type internal_face_itr,
  1274. internal_face_end;
  1275. if (face_handles[current_vertex].first_vertex() == v)
  1276. {
  1277. internal_face_itr = typename face_edge_iterator<>::type(
  1278. current_vertex, face_handles, second_side());
  1279. }
  1280. else
  1281. {
  1282. internal_face_itr = typename face_edge_iterator<>::type(
  1283. current_vertex, face_handles, first_side());
  1284. }
  1285. while (internal_face_itr != internal_face_end
  1286. && !outer_face_edge[*internal_face_itr]
  1287. && !x_y_path_vertex[current_vertex])
  1288. {
  1289. edge_t e(*internal_face_itr);
  1290. case_d_edges.push_back(e);
  1291. current_vertex = source(e, g) == current_vertex
  1292. ? target(e, g)
  1293. : source(e, g);
  1294. ++internal_face_itr;
  1295. }
  1296. if (x_y_path_vertex[current_vertex])
  1297. {
  1298. chosen_case = detail::BM_CASE_D;
  1299. break;
  1300. }
  1301. else
  1302. {
  1303. case_d_edges.clear();
  1304. }
  1305. }
  1306. }
  1307. if (chosen_case != detail::BM_CASE_B
  1308. && chosen_case != detail::BM_CASE_A)
  1309. {
  1310. // Finding z and w.
  1311. for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
  1312. {
  1313. edge_t e(*ei);
  1314. goal_edge[e] = !outer_face_edge[e]
  1315. && (source(e, g) == z || target(e, g) == z);
  1316. forbidden_edge[e] = outer_face_edge[e];
  1317. }
  1318. kuratowski_walkup(
  1319. v, forbidden_edge, goal_edge, is_embedded, z_v_path);
  1320. if (chosen_case == detail::BM_CASE_E)
  1321. {
  1322. for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
  1323. {
  1324. forbidden_edge[*ei] = outer_face_edge[*ei];
  1325. goal_edge[*ei] = !outer_face_edge[*ei]
  1326. && (source(*ei, g) == w || target(*ei, g) == w);
  1327. }
  1328. for (boost::tie(oei, oei_end) = out_edges(w, g); oei != oei_end;
  1329. ++oei)
  1330. {
  1331. if (!outer_face_edge[*oei])
  1332. goal_edge[*oei] = true;
  1333. }
  1334. typename std::vector< edge_t >::iterator pi, pi_end;
  1335. pi_end = z_v_path.end();
  1336. for (pi = z_v_path.begin(); pi != pi_end; ++pi)
  1337. {
  1338. goal_edge[*pi] = true;
  1339. }
  1340. w_ancestor = v;
  1341. vertex_t w_endpoint = graph_traits< Graph >::null_vertex();
  1342. while (w_endpoint == graph_traits< Graph >::null_vertex())
  1343. {
  1344. w_ancestor = dfs_parent[w_ancestor];
  1345. w_endpoint = kuratowski_walkup(w_ancestor, forbidden_edge,
  1346. goal_edge, is_embedded, w_path);
  1347. }
  1348. }
  1349. }
  1350. // We're done isolating the Kuratowski subgraph at this point -
  1351. // but there's still some cleaning up to do.
  1352. // Update is_in_subgraph with the paths we just found
  1353. xi_end = x_external_path.end();
  1354. for (xi = x_external_path.begin(); xi != xi_end; ++xi)
  1355. is_in_subgraph[*xi] = true;
  1356. xi_end = y_external_path.end();
  1357. for (xi = y_external_path.begin(); xi != xi_end; ++xi)
  1358. is_in_subgraph[*xi] = true;
  1359. xi_end = z_v_path.end();
  1360. for (xi = z_v_path.begin(); xi != xi_end; ++xi)
  1361. is_in_subgraph[*xi] = true;
  1362. xi_end = case_d_edges.end();
  1363. for (xi = case_d_edges.begin(); xi != xi_end; ++xi)
  1364. is_in_subgraph[*xi] = true;
  1365. xi_end = w_path.end();
  1366. for (xi = w_path.begin(); xi != xi_end; ++xi)
  1367. is_in_subgraph[*xi] = true;
  1368. child = bicomp_root;
  1369. parent = dfs_parent[child];
  1370. while (child != parent)
  1371. {
  1372. is_in_subgraph[dfs_parent_edge[child]] = true;
  1373. boost::tie(parent, child)
  1374. = std::make_pair(dfs_parent[parent], parent);
  1375. }
  1376. // At this point, we've already isolated the Kuratowski subgraph and
  1377. // collected all of the edges that compose it in the is_in_subgraph
  1378. // property map. But we want the verification of such a subgraph to be
  1379. // a deterministic process, and we can simplify the function
  1380. // is_kuratowski_subgraph by cleaning up some edges here.
  1381. if (chosen_case == detail::BM_CASE_B)
  1382. {
  1383. is_in_subgraph[dfs_parent_edge[v]] = false;
  1384. }
  1385. else if (chosen_case == detail::BM_CASE_C)
  1386. {
  1387. // In a case C subgraph, at least one of the x-y path endpoints
  1388. // (call it alpha) is above either x or y on the outer face. The
  1389. // other endpoint may be attached at x or y OR above OR below. In
  1390. // any of these three cases, we can form a K_3_3 by removing the
  1391. // edge attached to v on the outer face that is NOT on the path to
  1392. // alpha.
  1393. typename face_vertex_iterator< single_side, follow_visitor >::type
  1394. face_itr,
  1395. face_end;
  1396. if (face_handles[v_dfchild_handle.first_vertex()].first_edge()
  1397. == v_dfchild_handle.first_edge())
  1398. {
  1399. face_itr = typename face_vertex_iterator< single_side,
  1400. follow_visitor >::type(v_dfchild_handle.first_vertex(),
  1401. face_handles, second_side());
  1402. }
  1403. else
  1404. {
  1405. face_itr = typename face_vertex_iterator< single_side,
  1406. follow_visitor >::type(v_dfchild_handle.first_vertex(),
  1407. face_handles, first_side());
  1408. }
  1409. for (; true; ++face_itr)
  1410. {
  1411. vertex_t current_vertex(*face_itr);
  1412. if (current_vertex == x || current_vertex == y)
  1413. {
  1414. is_in_subgraph[v_dfchild_handle.first_edge()] = false;
  1415. break;
  1416. }
  1417. else if (current_vertex == first_x_y_path_endpoint
  1418. || current_vertex == second_x_y_path_endpoint)
  1419. {
  1420. is_in_subgraph[v_dfchild_handle.second_edge()] = false;
  1421. break;
  1422. }
  1423. }
  1424. }
  1425. else if (chosen_case == detail::BM_CASE_D)
  1426. {
  1427. // Need to remove both of the edges adjacent to v on the outer face.
  1428. // remove the connecting edges from v to bicomp, then
  1429. // is_kuratowski_subgraph will shrink vertices of degree 1
  1430. // automatically...
  1431. is_in_subgraph[v_dfchild_handle.first_edge()] = false;
  1432. is_in_subgraph[v_dfchild_handle.second_edge()] = false;
  1433. }
  1434. else if (chosen_case == detail::BM_CASE_E)
  1435. {
  1436. // Similarly to case C, if the endpoints of the x-y path are both
  1437. // below x and y, we should remove an edge to allow the subgraph to
  1438. // contract to a K_3_3.
  1439. if ((first_x_y_path_endpoint != x && first_x_y_path_endpoint != y)
  1440. || (second_x_y_path_endpoint != x
  1441. && second_x_y_path_endpoint != y))
  1442. {
  1443. is_in_subgraph[dfs_parent_edge[v]] = false;
  1444. vertex_t deletion_endpoint, other_endpoint;
  1445. if (lower_face_vertex[first_x_y_path_endpoint])
  1446. {
  1447. deletion_endpoint = second_x_y_path_endpoint;
  1448. other_endpoint = first_x_y_path_endpoint;
  1449. }
  1450. else
  1451. {
  1452. deletion_endpoint = first_x_y_path_endpoint;
  1453. other_endpoint = second_x_y_path_endpoint;
  1454. }
  1455. typename face_edge_iterator<>::type face_itr, face_end;
  1456. bool found_other_endpoint = false;
  1457. for (face_itr = typename face_edge_iterator<>::type(
  1458. deletion_endpoint, face_handles, first_side());
  1459. face_itr != face_end; ++face_itr)
  1460. {
  1461. edge_t e(*face_itr);
  1462. if (source(e, g) == other_endpoint
  1463. || target(e, g) == other_endpoint)
  1464. {
  1465. found_other_endpoint = true;
  1466. break;
  1467. }
  1468. }
  1469. if (found_other_endpoint)
  1470. {
  1471. is_in_subgraph[face_handles[deletion_endpoint].first_edge()]
  1472. = false;
  1473. }
  1474. else
  1475. {
  1476. is_in_subgraph[face_handles[deletion_endpoint]
  1477. .second_edge()]
  1478. = false;
  1479. }
  1480. }
  1481. }
  1482. for (boost::tie(ei, ei_end) = edges(g); ei != ei_end; ++ei)
  1483. if (is_in_subgraph[*ei])
  1484. *o_itr = *ei;
  1485. }
  1486. template < typename EdgePermutation >
  1487. void make_edge_permutation(EdgePermutation perm)
  1488. {
  1489. vertex_iterator_t vi, vi_end;
  1490. for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi)
  1491. {
  1492. vertex_t v(*vi);
  1493. perm[v].clear();
  1494. face_handles[v].get_list(std::back_inserter(perm[v]));
  1495. }
  1496. }
  1497. private:
  1498. const Graph& g;
  1499. VertexIndexMap vm;
  1500. vertex_t kuratowski_v;
  1501. vertex_t kuratowski_x;
  1502. vertex_t kuratowski_y;
  1503. vertex_list_t garbage; // we delete items from linked lists by
  1504. // splicing them into garbage
  1505. // only need these two for kuratowski subgraph isolation
  1506. std::vector< vertex_t > current_merge_points;
  1507. std::vector< edge_t > embedded_edges;
  1508. // property map storage
  1509. std::vector< v_size_t > low_point_vector;
  1510. std::vector< vertex_t > dfs_parent_vector;
  1511. std::vector< v_size_t > dfs_number_vector;
  1512. std::vector< v_size_t > least_ancestor_vector;
  1513. std::vector< face_handle_list_ptr_t > pertinent_roots_vector;
  1514. std::vector< v_size_t > backedge_flag_vector;
  1515. std::vector< v_size_t > visited_vector;
  1516. std::vector< face_handle_t > face_handles_vector;
  1517. std::vector< face_handle_t > dfs_child_handles_vector;
  1518. std::vector< vertex_list_ptr_t > separated_dfs_child_list_vector;
  1519. std::vector< typename vertex_list_t::iterator >
  1520. separated_node_in_parent_list_vector;
  1521. std::vector< vertex_t > canonical_dfs_child_vector;
  1522. std::vector< bool > flipped_vector;
  1523. std::vector< edge_vector_t > backedges_vector;
  1524. edge_vector_t self_loops;
  1525. std::vector< edge_t > dfs_parent_edge_vector;
  1526. vertex_vector_t vertices_by_dfs_num;
  1527. // property maps
  1528. vertex_to_v_size_map_t low_point;
  1529. vertex_to_vertex_map_t dfs_parent;
  1530. vertex_to_v_size_map_t dfs_number;
  1531. vertex_to_v_size_map_t least_ancestor;
  1532. vertex_to_face_handle_list_ptr_map_t pertinent_roots;
  1533. vertex_to_v_size_map_t backedge_flag;
  1534. vertex_to_v_size_map_t visited;
  1535. vertex_to_face_handle_map_t face_handles;
  1536. vertex_to_face_handle_map_t dfs_child_handles;
  1537. vertex_to_vertex_list_ptr_map_t separated_dfs_child_list;
  1538. vertex_to_separated_node_map_t separated_node_in_parent_list;
  1539. vertex_to_vertex_map_t canonical_dfs_child;
  1540. vertex_to_bool_map_t flipped;
  1541. vertex_to_edge_vector_map_t backedges;
  1542. vertex_to_edge_map_t dfs_parent_edge; // only need for kuratowski
  1543. merge_stack_t merge_stack;
  1544. };
  1545. } // namespace boost
  1546. #endif //__BOYER_MYRVOLD_IMPL_HPP__