vf2_sub_graph_iso.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <!--
  4. Copyright (C) Flavio De Lorenzi 2012
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE_1_0.txt or copy at
  7. http://www.boost.org/LICENSE_1_0.txt)
  8. -->
  9. <html>
  10. <head>
  11. <meta http-equiv="content-type" content="text/html; charset=iso-8859-15">
  12. <title>Boost Graph Library: VF2 (Sub)Graph Isomorphism</title>
  13. <style type="text/css">
  14. <!--
  15. body {
  16. color: black;
  17. background-color: white;
  18. }
  19. .comment {
  20. color: #333333;
  21. }
  22. a {
  23. color: blue;
  24. }
  25. a:visited {
  26. color: #551A8B;
  27. }
  28. -->
  29. </style>
  30. </head>
  31. <body>
  32. <p><img src="../../../boost.png" alt="C++ Boost" width="277" height="86"></p>
  33. <h1>
  34. <tt>vf2_subgraph_iso</tt>
  35. </h1>
  36. <pre>
  37. <em class="comment">// All defaults interface</em>
  38. template &lt;typename GraphSmall,
  39. typename GraphLarge,
  40. typename SubGraphIsoMapCallback&gt;
  41. bool vf2_subgraph_iso(const GraphSmall&amp; graph_small,
  42. const GraphLarge&amp; graph_large,
  43. SubGraphIsoMapCallback user_callback)
  44. <em class="comment">// Named parameter version</em>
  45. template &lt;typename GraphSmall,
  46. typename GraphLarge,
  47. typename VertexOrderSmall,
  48. typename SubGraphIsoMapCallback,
  49. typename Param,
  50. typename Tag,
  51. typename Rest&gt;
  52. bool vf2_subgraph_iso(const GraphSmall&amp; graph_small,
  53. const GraphLarge&amp; graph_large,
  54. SubGraphIsoMapCallback user_callback,
  55. const VertexOrderSmall&amp; vertex_order_small,
  56. const bgl_named_params&lt;Param, Tag, Rest&gt;&amp; params)
  57. <em class="comment">// Non-named parameter version</em>
  58. template &lt;typename GraphSmall,
  59. typename GraphLarge,
  60. typename <a href="../../property_map/doc/ReadablePropertyMap.html">IndexMapSmall</a>,
  61. typename <a href="../../property_map/doc/ReadablePropertyMap.html">IndexMapLarge</a>,
  62. typename VertexOrderSmall,
  63. typename <a href="http://www.boost.org/sgi/stl/BinaryFunction.html">EdgeEquivalencePredicate</a>,
  64. typename <a href="http://www.boost.org/sgi/stl/BinaryFunction.html">VertexEquivalencePredicate</a>,
  65. typename SubGraphIsoMapCallback&gt;
  66. bool vf2_subgraph_iso(const GraphSmall&amp; graph_small,
  67. const GraphLarge&amp; graph_large,
  68. SubGraphIsoMapCallback user_callback,
  69. IndexMapSmall index_map_small,
  70. IndexMapLarge index_map_large,
  71. const VertexOrderSmall&amp; vertex_order_small,
  72. EdgeEquivalencePredicate edge_comp,
  73. VertexEquivalencePredicate vertex_comp)
  74. </pre>
  75. <p>
  76. An isomorphism between two graphs <em>G<sub>1</sub>=(V<sub>1</sub>, E<sub>1</sub>)</em>
  77. and <em>G<sub>2</sub>=(V<sub>2</sub>, E<sub>2</sub>)</em> is a
  78. bijective mapping <em>M</em> of the vertices of one graph to vertices of the other
  79. graph that preserves the edge structure of the graphs. <em>M</em> is said to be a
  80. graph-subgraph isomorphism if and only if <em>M</em> is an isomorphism between
  81. <em>G<sub>1</sub></em> and a subgraph of <em>G<sub>2</sub></em>.
  82. An induced subgraph of a graph <em>G = (V, E)</em> is a normal subgraph
  83. <em>G' = (V', E')</em> with the extra condition that all edges of <em>G</em>
  84. which have both endpoints in <em>V'</em> are in <em>E'</em>.
  85. </p>
  86. <p>
  87. This function finds all induced subgraph isomorphisms between
  88. graphs <tt>graph_small</tt> and <tt>graph_large</tt> and outputs them to
  89. <tt>user_callback</tt>. It continues until <tt>user_callback</tt>
  90. returns false or the search space has been fully explored. <tt>vf2_subgraph_iso</tt>
  91. returns true if a graph-subgraph isomorphism exists and false otherwise.
  92. <tt>EdgeEquivalencePredicate</tt> and
  93. <tt>VertexEquivalencePredicate</tt> predicates are used to test whether
  94. edges and vertices are equivalent. To use property maps for equivalence,
  95. see
  96. <tt><a href="./mcgregor_common_subgraphs.html#make_property_map_equivalent">
  97. make_property_map_equivalent</a></tt>
  98. function. By default <tt><a href="./mcgregor_common_subgraphs.html#always_equivalent">
  99. always_equivalent</a></tt> is used, which returns
  100. true for any pair of vertices or edges.
  101. </p>
  102. <p>
  103. The current implementation is based on the <em>VF2</em> algorithm,
  104. introduced by Cordella et al. An in-depth description of the algorithm is
  105. given in [<a href="#cordella2001">1</a>] and [<a href="#cordella2004">2</a>]
  106. and references therein. The original code by P. Foggia and collaborators can
  107. be found at [<a href="#foggia_etal">3</a>]. In brief, the process of
  108. finding a mapping between the two graphs <em>G<sub>1</sub></em> and
  109. <em>G<sub>2</sub></em> determines the isomorphism mapping <em>M</em>,
  110. which associates vertices <em>G<sub>1</sub></em> with vertices of
  111. <em>G<sub>2</sub></em> and vice versa. It can be described by means of a
  112. state space representation which is created by the algorithm
  113. while exploring the search graph in depth-first fashion.
  114. Each state <em>s</em> of the matching process
  115. can be associated with a partial mapping <em>M(s)</em>. At each level,
  116. the algorithm computes the set of the vertex pairs that are candidates to
  117. be added to the current state <em>s</em>. If a pair of vertices
  118. (<em>v, w</em>) is feasible, the mapping is extended and the associated
  119. successor state <em>s'</em> is computed.
  120. The whole procedure is then repeated for state <em>s'</em>.
  121. </p>
  122. <h3>Where Defined</h3>
  123. <p>
  124. <a href="../../../boost/graph/vf2_sub_graph_iso.hpp">
  125. <tt>boost/graph/vf2_sub_graph_iso.hpp</tt></a><br>
  126. All functions are defined in the boost namespace.
  127. </p>
  128. <h3>Parameters</h3>
  129. <p>IN: <tt>const GraphSmall&amp; graph_small</tt></p>
  130. <blockquote>
  131. <p>
  132. The (first) smaller graph (fewer vertices) of the pair to be tested for
  133. isomorphism. The type <tt>GraphSmall</tt> must be a
  134. model of
  135. <a href="./VertexListGraph.html">Vertex List Graph</a>,
  136. <a href="./EdgeListGraph.html">Edge List Graph</a>,
  137. <a href="./BidirectionalGraph.html">Bidirectional Graph</a> and
  138. <a href="./AdjacencyMatrix.html">Adjacency Matrix</a>.
  139. The edge descriptors <tt>graph_traits&lt;GraphSmall&gt;::edge_descriptor</tt>
  140. must be <a href="http://www.boost.org/sgi/stl/LessThanComparable.html">
  141. LessThan Comparable</a>, cf. also the remark <a href="#notes">below</a>.
  142. </p>
  143. </blockquote>
  144. <p>IN: <tt>const GraphLarge&amp; graph_large</tt></p>
  145. <blockquote>
  146. <p>
  147. The (second) larger graph to be tested.
  148. Type <tt>GraphLarge</tt> must be a model of
  149. <a href="./VertexListGraph.html">Vertex List Graph</a>,
  150. <a href="./EdgeListGraph.html">Edge List Graph</a>,
  151. <a href="./BidirectionalGraph.html">Bidirectional Graph</a> and
  152. <a href="./AdjacencyMatrix.html">Adjacency Matrix</a>.
  153. The edge descriptors <tt>graph_traits&lt;GraphLarge&gt;::edge_descriptor</tt>
  154. must be <a href="http://www.boost.org/sgi/stl/LessThanComparable.html">
  155. LessThan Comparable</a>, cf. also the remark <a href="#notes">below</a>.
  156. </p>
  157. </blockquote>
  158. <p>OUT: <tt>SubGraphIsoMapCallback user_callback</tt></p>
  159. <blockquote>
  160. <p>
  161. A function object to be called when a graph-subgraph isomorphism has been discovered. The
  162. <tt>operator()</tt> must have following form:
  163. </p>
  164. <pre>
  165. template &lt;typename CorrespondenceMap1To2,
  166. typename CorrespondenceMap2To1&gt;
  167. bool operator()(CorrespondenceMap1To2 f, CorrespondenceMap2To1 g) const
  168. </pre>
  169. <p>
  170. Both the <tt>CorrespondenceMap1To2</tt>
  171. and <tt>CorresondenceMap2To1</tt> types are models
  172. of <a href="../../property_map/doc/ReadablePropertyMap.html">Readable
  173. Property Map</a> and map equivalent vertices across the two
  174. graphs given to <tt>vf2_subgraph_iso</tt> (or <tt>vf2_graph_iso</tt> or
  175. <tt>vf2_subgraph_mono</tt>). For instance, if <tt>v</tt> is
  176. from <tt>graph_small</tt>, <tt>w</tt> is from <tt>graph_large</tt>,
  177. and the vertices can be considered equivalent,
  178. then <tt>get(f, v)</tt> will be <tt>w</tt> and <tt>get(g, w)</tt>
  179. will be <tt>v</tt>. If any vertex, say <tt>v</tt> in <tt>graph_small</tt>,
  180. does not match a vertex in <tt>graph_large</tt> ,
  181. then <tt>get(f, v)</tt> will be <tt>graph_traits&lt;GraphLarge&gt;::null_vertex()</tt>.
  182. Likewise for any unmatched vertices from <tt>graph_large</tt>,
  183. <tt>get(g, w)</tt> will be <tt>graph_traits&lt;GraphSmall&gt;::null_vertex()</tt>.
  184. Returning false from the callback will abort the search immediately. Otherwise,
  185. the entire search space will be explored. A "default" print callback
  186. is provided as a <a href="#vf2_callback">utility function</a>.
  187. </p>
  188. </blockquote>
  189. <p>IN: <tt>const VertexOrderSmall&amp; vertex_order_small</tt></p>
  190. <blockquote>
  191. <p>
  192. The ordered vertices of the smaller (first) graph <tt>graph_small</tt>.
  193. During the matching process the vertices are examined in the order given by
  194. <tt>vertex_order_small</tt>. Type <tt>VertexOrderSmall</tt> must be a model
  195. of <a href="http://www.boost.org/sgi/stl/Container.html">ContainerConcept</a>
  196. with value type
  197. <tt>graph_traits&lt;GraphSmall&gt;::vertex_descriptor</tt>.
  198. <br>
  199. <b>Default</b> The vertices are ordered by multiplicity of
  200. in/out degrees.
  201. </p>
  202. </blockquote>
  203. <h3>Named Parameters</h3>
  204. <p>IN: <tt>vertex_index1(IndexMapSmall index_map_small)</tt></p>
  205. <blockquote>
  206. <p>
  207. This maps each vertex to an integer in the range <tt>[0, num_vertices(graph_small))</tt>.
  208. Type <tt>IndexMapSmall</tt> must be a model of
  209. <a href="../../property_map/doc/ReadablePropertyMap.html">Readable Property Map</a>.
  210. <br>
  211. <b>Default:</b> <tt>get(vertex_index, graph_small)</tt>
  212. </p>
  213. </blockquote>
  214. <p>IN: <tt>vertex_index2(IndexMapLarge index_map_large)</tt></p>
  215. <blockquote>
  216. <p>
  217. This maps each vertex to an integer in the range <tt>[0, num_vertices(graph_large))</tt>.
  218. Type <tt>IndexMapLarge</tt> must be a model of
  219. <a href="../../property_map/doc/ReadablePropertyMap.html">Readable Property Map</a>.
  220. <br>
  221. <b>Default:</b> <tt>get(vertex_index, graph_large)</tt>
  222. </p>
  223. </blockquote>
  224. <p>IN: <tt>edges_equivalent(EdgeEquivalencePredicate edge_comp)</tt></p>
  225. <blockquote>
  226. <p>
  227. This function object is used to determine if edges between the two graphs
  228. <tt>graph_small</tt> and <tt>graph_large</tt> are equivalent.
  229. Type <tt>EdgeEquivalencePredicate</tt> must be a model of
  230. <a href="http://www.boost.org/sgi/stl/BinaryPredicate.html">Binary
  231. Predicate</a> and have argument types of
  232. <tt>graph_traits&lt;GraphSmall&gt;::edge_descriptor</tt> and
  233. <tt>graph_traits&lt;GraphLarge&gt;::edge_descriptor</tt>.
  234. The edge descriptors must be <a href="http://www.boost.org/sgi/stl/LessThanComparable.html">
  235. LessThan Comparable</a>. A return value of true indicates that the edges are equivalent.
  236. <br>
  237. <b>Default:</b> <tt><a href="./mcgregor_common_subgraphs.html#always_equivalent">
  238. always_equivalent</a></tt>
  239. </p>
  240. </blockquote>
  241. <p>IN: <tt>vertices_equivalent(VertexEquivalencePredicate vertex_comp)</tt></p>
  242. <blockquote>
  243. <p>
  244. This function object is used to determine if vertices between the two graphs
  245. <tt>graph_small</tt> and <tt>graph_large</tt> are equivalent.
  246. Type <tt>VertexEquivalencePredicate</tt> must be a model of
  247. <a href="http://www.boost.org/sgi/stl/BinaryPredicate.html">Binary Predicate</a>
  248. and have argument types of
  249. <tt>graph_traits&lt;GraphSmall&gt;::vertex_descriptor</tt> and
  250. <tt>graph_traits&lt;GraphLarge&gt;::vertex_descriptor</tt>. A return value of true
  251. indicates that the vertices are equivalent.
  252. <br>
  253. <b>Default:</b> <tt><a href="./mcgregor_common_subgraphs.html#always_equivalent">
  254. always_equivalent</a></tt>
  255. </p>
  256. </blockquote>
  257. <h3>Related Functions</h3>
  258. <p>
  259. Non-named parameter, named-parameter and all default parameter versions of
  260. function
  261. </p>
  262. <p><tt>vf2_graph_iso(...)</tt></p>
  263. <p><tt>vf2_subgraph_mono(...)</tt></p>
  264. <p>
  265. for isomorphism and (not necessarily induced) subgraph isomorphism testing,
  266. taking the same parameters as the corresponding functions <tt>vf2_subgraph_iso</tt>
  267. for induced subgraph isomorphism testing.
  268. For <tt>vf2_graph_iso</tt> the algorithm finds all isomorphism mappings between
  269. graphs <tt>graph1</tt> and <tt>graph2</tt> and outputs them to
  270. <tt>user_callback</tt>.
  271. For <tt>vf2_graph_mono</tt> the algorithm finds all mappings of <tt>graph_small</tt>
  272. to subgraphs of <tt>graph_large</tt>.
  273. Note that, as opposed to <tt>vf2_subgraph_iso</tt>,
  274. these subgraphs need not to be induced subgraphs.
  275. </p>
  276. <p>
  277. Both algorithms continues until <tt>user_callback</tt>
  278. returns false or the search space has been fully explored. As before,
  279. <tt>EdgeEquivalencePredicate</tt> and
  280. <tt>VertexEquivalencePredicate</tt> predicates are used to test
  281. whether edges and vertices are equivalent. By default
  282. <tt>always_equivalent</tt> is used.
  283. </p>
  284. <h3>Utility Functions and Structs</h3>
  285. <p>
  286. <tt id="vf2_callback">
  287. template&lt;typename Graph1,
  288. typename Graph2&gt;
  289. struct vf2_print_callback
  290. </tt>
  291. </p>
  292. <blockquote>
  293. <p>
  294. Callback function object that prints out the correspondences between vertices
  295. of <tt>Graph1</tt> and <tt>Graph2</tt>. The constructor takes
  296. the two graphs <em>G<sub>1</sub></em> and <em>G<sub>2</sub></em>.
  297. </p>
  298. </blockquote>
  299. <pre>
  300. template&lt;typename Graph&gt;
  301. std::vector&lt;typename graph_traits&lt;Graph&gt;::vertex_descriptor&gt;
  302. vertex_order_by_mult(const Graph&amp; graph)
  303. </pre>
  304. <blockquote>
  305. <p>
  306. Returns a vector containing the vertices of a graph, sorted
  307. by multiplicity of in/out degrees.
  308. </p>
  309. </blockquote>
  310. <pre>
  311. <em class="comment">// Variant of verify_subgraph_iso with all default parameters</em>
  312. template&lt;typename Graph1,
  313. typename Graph2,
  314. typename CorresponenceMap1To2&gt;
  315. inline bool verify_vf2_subgraph_iso(const Graph1&amp; graph1, const Graph2&amp; graph2,
  316. const CorresponenceMap1To2 f)
  317. <em class="comment">// Verifies a graph (sub)graph isomorphism map</em>
  318. template&lt;typename Graph1,
  319. typename Graph2,
  320. typename CorresponenceMap1To2,
  321. typename EdgeEquivalencePredicate,
  322. typename VertexEquivalencePredicate&gt;
  323. inline bool verify_vf2_subgraph_iso(const Graph1&amp; graph1, const Graph2&amp; graph2,
  324. const CorresponenceMap1To2 f,
  325. EdgeEquivalencePredicate edge_comp,
  326. VertexEquivalencePredicate vertex_comp)
  327. </pre>
  328. <blockquote>
  329. <p>
  330. This function can be used to verify a (sub)graph isomorphism
  331. mapping <em>f</em>. The parameters are analogous to
  332. function <tt>vf2_subgraph_iso</tt> (<tt>vf2_graph_iso</tt>).
  333. </p>
  334. </blockquote>
  335. <h3>Complexity</h3>
  336. <p>
  337. Spatial and time complexity are given in [<a href="#cordella2004">2</a>]. The spatial
  338. complexity of VF2 is of order <em>O(V)</em>, where V is the (maximum) number
  339. of vertices of the two graphs. Time complexity is <em>O(V<sup>2</sup>)</em> in the best case and
  340. <em>O(V!&middot;V)</em> in the worst case.
  341. </p>
  342. <h3>Examples</h3>
  343. <h4>Example 1</h4>
  344. <p>
  345. In the example below, a small graph <tt>graph1</tt> and a larger graph
  346. <tt>graph2</tt> are defined. Here small and large refers to the number of
  347. vertices of the graphs. <tt>vf2_subgraph_iso</tt> computes all the
  348. subgraph isomorphism mappings between the two graphs and outputs them
  349. via <tt>callback</tt>.
  350. </p>
  351. <pre>
  352. typedef adjacency_list&lt;setS, vecS, bidirectionalS&gt; graph_type;
  353. <em class="comment">// Build graph1</em>
  354. int num_vertices1 = 8; graph_type graph1(num_vertices1);
  355. add_edge(0, 6, graph1); add_edge(0, 7, graph1);
  356. add_edge(1, 5, graph1); add_edge(1, 7, graph1);
  357. add_edge(2, 4, graph1); add_edge(2, 5, graph1); add_edge(2, 6, graph1);
  358. add_edge(3, 4, graph1);
  359. <em class="comment">// Build graph2</em>
  360. int num_vertices2 = 9; graph_type graph2(num_vertices2);
  361. add_edge(0, 6, graph2); add_edge(0, 8, graph2);
  362. add_edge(1, 5, graph2); add_edge(1, 7, graph2);
  363. add_edge(2, 4, graph2); add_edge(2, 7, graph2); add_edge(2, 8, graph2);
  364. add_edge(3, 4, graph2); add_edge(3, 5, graph2); add_edge(3, 6, graph2);
  365. <em class="comment">
  366. // Create callback to print mappings</em>
  367. vf2_print_callback&lt;graph_type, graph_type&gt; callback(graph1, graph2);
  368. <em class="comment">
  369. // Print out all subgraph isomorphism mappings between graph1 and graph2.
  370. // Vertices and edges are assumed to be always equivalent.</em>
  371. vf2_subgraph_iso(graph1, graph2, callback);
  372. </pre>
  373. <p>
  374. The complete example can be found under
  375. <a href="../example/vf2_sub_graph_iso_example.cpp"><tt>examples/vf2_sub_graph_iso_example.cpp</tt></a>.
  376. <br>
  377. </p>
  378. <h4>Example 2</h4>
  379. <p>
  380. In this example, the subgraph isomorphism mappings between multi-graphs are computed. The vertices
  381. and edges of the multi-graphs are distinguished using property maps.
  382. </p>
  383. <pre>
  384. <em class="comment">// Define edge and vertex properties</em>
  385. typedef property&lt;edge_name_t, char&gt; edge_property;
  386. typedef property&lt;vertex_name_t, char, property&lt;vertex_index_t, int&gt; &gt; vertex_property;
  387. <em class="comment">// Using a vecS graphs => the index maps are implicit.</em>
  388. typedef adjacency_list&lt;vecS, vecS, bidirectionalS, vertex_property, edge_property&gt; graph_type;
  389. <em class="comment">// Create graph1</em>
  390. graph_type graph1;
  391. <em class="comment">// Add vertices... </em>
  392. add_vertex(vertex_property('a'), graph1);
  393. ...
  394. <em class="comment">//... and edges </em>
  395. add_edge(0, 1, edge_property('b'), graph1);
  396. add_edge(0, 1, edge_property('b'), graph1);
  397. ...
  398. <em class="comment">// Create graph2 </em>
  399. graph_type graph2;
  400. add_vertex(vertex_property('a'), graph2);
  401. ...
  402. add_edge(0, 1, edge_property('a'), graph2);
  403. ...
  404. </pre>
  405. <p>
  406. To distinguish vertices and edges with property maps, binary predicates are created using the
  407. <tt><a href="./mcgregor_common_subgraphs.html#make_property_map_equivalent">
  408. make_property_map_equivalent</a></tt> function:
  409. </p>
  410. <pre>
  411. <em class="comment">// Create the vertex binary predicate</em>
  412. typedef property_map&lt;graph_type, vertex_name_t&gt;::type vertex_name_map_t;
  413. typedef property_map_equivalent&lt;vertex_name_map_t, vertex_name_map_t&gt; vertex_comp_t;
  414. vertex_comp_t vertex_comp =
  415. make_property_map_equivalent(get(vertex_name, graph1), get(vertex_name, graph2));
  416. <em class="comment">// Create the vertex binary predicate</em>
  417. typedef property_map&lt;graph_type, edge_name_t&gt;::type edge_name_map_t;
  418. typedef property_map_equivalent&lt;edge_name_map_t, edge_name_map_t&gt; edge_comp_t;
  419. edge_comp_t edge_comp =
  420. make_property_map_equivalent(get(edge_name, graph1), get(edge_name, graph2));
  421. </pre>
  422. <p>
  423. Finally, a callback function object is created and the subgraph isomorphism mappings are
  424. computed:
  425. </p>
  426. <pre>
  427. <em class="comment">// Create callback</em>
  428. vf2_print_callback&lt;graph_type, graph_type&gt; callback(graph1, graph2);
  429. <em class="comment">
  430. // Print out all subgraph isomorphism mappings between graph1 and graph2.
  431. // Function vertex_order_by_mult is used to compute the order of
  432. // vertices of graph1. This is the order in which the vertices are examined
  433. // during the matching process.</em>
  434. vf2_subgraph_iso(graph1, graph2, callback, vertex_order_by_mult(graph1),
  435. edges_equivalent(edge_comp).vertices_equivalent(vertex_comp));
  436. </pre>
  437. <p>
  438. For the complete example, see
  439. <a href="../example/vf2_sub_graph_iso_multi_example.cpp">
  440. <tt>examples/vf2_sub_graph_iso_multi_example.cpp</tt></a>.
  441. <br>
  442. </p>
  443. <h3 id="notes">Notes</h3>
  444. <p>
  445. If the <tt>EdgeList</tt> allows for parallel edges, e.g. <tt>vecS</tt>, the
  446. algorithm does some bookkeeping of already identified edges. Matched edges
  447. are temporarily stored using <tt>std::set</tt> as container, requiring that
  448. <tt>edge_descriptor</tt> are <a href="http://www.boost.org/sgi/stl/LessThanComparable.html">
  449. LessThan Comparable</a>. In contrast, if instead you enforce the absence of
  450. parallel edges, e.g. by using <tt>setS</tt>, the lookup function falls back
  451. to <tt>edge()</tt> without performing any bookkeeping.
  452. </p>
  453. <h3>Bibliography</h3>
  454. <dl>
  455. <dt><a name="cordella2001">1</a></dt>
  456. <dd>
  457. L.&nbsp;P. Cordella, P. Foggia, C. Sansone, and M. Vento.
  458. <br><em>An improved algorithm for matching large graphs</em>.
  459. <br>In: 3rd IAPR-TC15 Workshop on Graph-based Representations in Pattern Recognition, pp. 149-159, Cuen, 2001.
  460. <p></p>
  461. </dd>
  462. <dt><a name="cordella2004">2</a></dt>
  463. <dd>
  464. L.&nbsp;P. Cordella, P. Foggia, C. Sansone, and M. Vento.
  465. <br><em>A (Sub)Graph Isomorphism Algorithm for Matching Large Graphs</em>.
  466. <br>IEEE Trans. Pattern Anal. Mach. Intell., vol. 26, no. 10, pp. 1367-1372, 2004.
  467. <p></p>
  468. </dd>
  469. <dt><a name="foggia_etal">3</a></dt>
  470. <dd>
  471. <a href="http://www.cs.sunysb.edu/~algorith/implement/vflib/implement.shtml">
  472. <tt>http://www.cs.sunysb.edu/~algorith/implement/vflib/implement.shtml</tt></a>
  473. <p></p>
  474. </dd>
  475. </dl>
  476. <hr>
  477. <p>
  478. Copyright &copy; 2012, Flavio De Lorenzi
  479. (<a href="mailto:fdlorenzi@gmail.com">fdlorenzi@gmail.com</a>) <br />
  480. Copyright &copy; 2013, Jakob Lykke Andersen, University of Southern Denmark
  481. (<a href="mailto:jlandersen@imada.sdu.dk">jlandersen@imada.sdu.dk</a>)
  482. </p>
  483. </body>
  484. </html>