PageRenderTime 26ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/package/boost_1_58_0/libs/graph/doc/strong_components.html

https://gitlab.com/cdeclare/intcrypt
HTML | 201 lines | 157 code | 37 blank | 7 comment | 0 complexity | 806db75e930e98f8413a5f42c5458c05 MD5 | raw file
  1. <HTML>
  2. <!--
  3. Copyright (c) Jeremy Siek 2000
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <Head>
  9. <Title>Boost Graph Library: Strongly Connected Components</Title>
  10. <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
  11. ALINK="#ff0000">
  12. <IMG SRC="../../../boost.png"
  13. ALT="C++ Boost" width="277" height="86">
  14. <BR Clear>
  15. <H1>
  16. <A NAME="sec:connected-components"></A><A NAME="sec:strongly-connected-components"></A>
  17. <img src="figs/python.gif" alt="(Python)"/>
  18. <TT>strong_components</TT>
  19. </H1>
  20. <PRE>
  21. <i>// named parameter version</i>
  22. template &lt;class Graph, class ComponentMap, class P, class T, class R&gt;
  23. typename property_traits&lt;ComponentMap&gt;::value_type
  24. strong_components(Graph& g, ComponentMap comp,
  25. const bgl_named_params&lt;P, T, R&gt;&amp; params = <i>all defaults</i>)
  26. <i>// there is not a non-named parameter version of this function</i>
  27. </PRE>
  28. <P>
  29. The <TT>strong_components()</TT> functions compute the strongly
  30. connected components of a directed graph using Tarjan's algorithm
  31. based on DFS&nbsp;[<A
  32. HREF="bibliography.html#tarjan72:dfs_and_linear_algo">41</A>].
  33. </p>
  34. <P>
  35. The output of the algorithm is recorded in the component property
  36. map <TT>comp</TT>, which will contain numbers giving the component ID
  37. assigned to each vertex. The number of components is the return value
  38. of the function.
  39. </p>
  40. <H3>Where Defined</H3>
  41. <P>
  42. <a href="../../../boost/graph/strong_components.hpp"><TT>boost/graph/strong_components.hpp</TT></a>
  43. <P>
  44. <H3>Definitions</H3>
  45. <P>
  46. A <a name="def:strongly-connected-component"><b><I>strongly connected
  47. component</I></b></a> of a directed graph <i>G=(V,E)</i> is a maximal
  48. set of vertices <i>U</i> which is in <i>V</i> such that for every pair
  49. of vertices <i>u</i> and <i>v</i> in <i>U</i>, we have both a path
  50. from <i>u</i> to <i>v</i> and path from <i>v</i> to <i>u</i>. That is
  51. to say that <i>u</i> and <i>v</i> are reachable from each other.
  52. <P>
  53. <h3>Parameters</h3>
  54. IN: <tt>const Graph&amp; g</tt>
  55. <blockquote>
  56. A directed graph. The graph type must be a model of <a
  57. href="VertexListGraph.html">Vertex List Graph</a> and <a
  58. href="IncidenceGraph.html">Incidence Graph</a>.<br>
  59. <b>Python</b>: The parameter is named <tt>graph</tt>.
  60. </blockquote>
  61. OUT: <tt>ComponentMap c</tt>
  62. <blockquote>
  63. The algorithm computes how many connected components are in the graph,
  64. and assigning each component an integer label. The algorithm then
  65. records which component each vertex in the graph belongs to by
  66. recording the component number in the component property map. The
  67. <tt>ComponentMap</tt> type must be a model of <a
  68. href="../../property_map/doc/WritablePropertyMap.html">Writable Property
  69. Map</a>. The value type shouch be an integer type, preferably the same
  70. as the <tt>vertices_size_type</tt> of the graph. The key type must be
  71. the graph's vertex descriptor type.<br>
  72. <b>Python</b>: Must be an <tt>vertex_int_map</tt> for the graph.<br>
  73. <b>Python default</b>: <tt>graph.get_vertex_int_map("component")</tt>
  74. </blockquote>
  75. <h3>Named Parameters</h3>
  76. UTIL: <tt>root_map(RootMap r_map)</tt>
  77. <blockquote>
  78. This is used by the algorithm to record the candidate root vertex for
  79. each vertex. By the end of the algorithm, there is a single root vertex
  80. for each component and <tt>get(r_map, v)</tt> returns the root
  81. vertex for whichever component vertex <tt>v</tt> is a member.
  82. The <TT>RootMap</TT> must be a <a
  83. href="../../property_map/doc/ReadWritePropertyMap.html">
  84. Read/Write Property Map</a>, where the key type and the value type are
  85. the vertex descriptor type of the graph.<br>
  86. <b>Default:</b> an <a
  87. href="../../property_map/doc/iterator_property_map.html">
  88. <tt>iterator_property_map</tt></a> created from a
  89. <tt>std::vector</tt> of vertex descriptors of size
  90. <tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
  91. map.<br>
  92. <b>Python</b>: Unsupported parameter.
  93. </blockquote>
  94. UTIL: <tt>discover_time_map(TimeMap t_map)</tt>
  95. <blockquote>
  96. This is used by the algorithm to keep track of the DFS ordering
  97. of the vertices. The <TT>TimeMap</TT> must be a model
  98. of <a href="../../property_map/doc/ReadWritePropertyMap.html"> Read/Write
  99. Property Map</a> and its value type must be an integer type. The key
  100. type must be the vertex descriptor type of the graph.<br>
  101. <b>Default:</b>an <a
  102. href="../../property_map/doc/iterator_property_map.html">
  103. <tt>iterator_property_map</tt></a> created from a
  104. <tt>std::vector</tt> of integers with size
  105. <tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
  106. map.<br>
  107. <b>Python</b>: Unsupported parameter.
  108. </blockquote>
  109. UTIL: <tt>color_map(ColorMap c_map)</tt>
  110. <blockquote>
  111. This is used by the algorithm to keep track of its progress through
  112. the graph. The type <tt>ColorMap</tt> must be a model of <a
  113. href="../../property_map/doc/ReadWritePropertyMap.html">Read/Write
  114. Property Map</a> and its key type must be the graph's vertex
  115. descriptor type and the value type of the color map must model
  116. <a href="./ColorValue.html">ColorValue</a>.<br>
  117. <b>Default:</b> an <a
  118. href="../../property_map/doc/iterator_property_map.html">
  119. <tt>iterator_property_map</tt></a> created from a
  120. <tt>std::vector</tt> of <tt>default_color_type</tt> of size
  121. <tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
  122. map.<br>
  123. <b>Python</b>: Unsupported parameter.
  124. </blockquote>
  125. IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
  126. <blockquote>
  127. This maps each vertex to an integer in the range <tt>[0,
  128. num_vertices(g))</tt>. This parameter is only necessary when a
  129. default is used for one of the other named parameters. The type
  130. <tt>VertexIndexMap</tt> must be a model of <a
  131. href="../../property_map/doc/ReadablePropertyMap.html">Readable Property
  132. Map</a>. The value type of the map must be an integer type. The
  133. vertex descriptor type of the graph needs to be usable as the key
  134. type of the map.<br>
  135. <b>Default:</b> <tt>get(vertex_index, g)</tt>
  136. Note: if you use this default, make sure your graph has
  137. an internal <tt>vertex_index</tt> property. For example,
  138. <tt>adjacenty_list</tt> with <tt>VertexList=listS</tt> does
  139. not have an internal <tt>vertex_index</tt> property.
  140. <br>
  141. <b>Python</b>: Unsupported parameter.
  142. </blockquote>
  143. <H3>Complexity</H3>
  144. <P>
  145. The time complexity for the strongly connected components algorithm is
  146. <i>O(V + E)</i>.
  147. <P>
  148. <h3>See Also</h3>
  149. <a href="./connected_components.html"><tt>connected_components()</tt></a>
  150. and <a href="./incremental_components.html"><tt>incremental_components()</tt></a>
  151. <H3>Example</H3>
  152. <P>
  153. See <a
  154. href="../example/strong_components.cpp"><tt>examples/strong_components.cpp</tt></a>.
  155. <br>
  156. <HR>
  157. <TABLE>
  158. <TR valign=top>
  159. <TD nowrap>Copyright &copy; 2000-2001</TD><TD>
  160. <A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
  161. </TD></TR></TABLE>
  162. </BODY>
  163. </HTML>