st_connected.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. .. Copyright (C) 2004-2009 The Trustees of Indiana University.
  2. Use, modification and distribution is subject to the Boost Software
  3. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. http://www.boost.org/LICENSE_1_0.txt)
  5. ===========================
  6. |Logo| s-t Connectivity
  7. ===========================
  8. ::
  9. namespace graph { namespace distributed {
  10. template<typename DistributedGraph, typename ColorMap>
  11. inline bool
  12. st_connected(const DistributedGraph& g,
  13. typename graph_traits<DistributedGraph>::vertex_descriptor s,
  14. typename graph_traits<DistributedGraph>::vertex_descriptor t,
  15. ColorMap color)
  16. template<typename DistributedGraph>
  17. inline bool
  18. st_connected(const DistributedGraph& g,
  19. typename graph_traits<DistributedGraph>::vertex_descriptor s,
  20. typename graph_traits<DistributedGraph>::vertex_descriptor t)
  21. template<typename DistributedGraph, typename ColorMap, typename OwnerMap>
  22. bool
  23. st_connected(const DistributedGraph& g,
  24. typename graph_traits<DistributedGraph>::vertex_descriptor s,
  25. typename graph_traits<DistributedGraph>::vertex_descriptor t,
  26. ColorMap color, OwnerMap owner)
  27. } }
  28. The ``st_connected()`` function determines whether there exists a path
  29. from ``s`` to ``t`` in a graph ``g``. If a path exists the function
  30. returns ``true``, otherwise it returns ``false``.
  31. This algorithm is currently *level-synchronized*, meaning that all
  32. vertices in a given level of the search tree will be processed
  33. (potentially in parallel) before any vertices from a successive level
  34. in the tree are processed. This is not necessary for the correctness
  35. of the algorithm but rather is an implementation detail. This
  36. algorithm could be rewritten fully-asynchronously using triggers which
  37. would remove the level-synchronized behavior.
  38. .. contents::
  39. Where Defined
  40. -------------
  41. <``boost/graph/distributed/st_connected.hpp``>
  42. Parameters
  43. ----------
  44. IN: ``const DistributedGraph& g``
  45. The graph type must be a model of `Distributed Graph`_. The graph
  46. type must also model the `Incidence Graph`_.
  47. IN: ``vertex_descriptor s``
  48. IN: ``vertex_descriptor t``
  49. UTIL/OUT: ``color_map(ColorMap color)``
  50. The color map must be a `Distributed Property Map`_ with the same
  51. process group as the graph ``g`` whose colors must monotonically
  52. darken (white -> gray/green -> black). The default value is a
  53. distributed ``two_bit_color_map``.
  54. IN: ``OwnerMap owner``
  55. The owner map must map from vertices to the process that owns them
  56. as described in the `GlobalDescriptor`_ concept.
  57. OUT: ``bool``
  58. The algorithm returns ``true`` if a path from ``s`` to ``t`` is
  59. found, and false otherwise.
  60. Complexity
  61. ----------
  62. This algorithm performs *O(V + E)* work in *d/2 + 1* BSP supersteps,
  63. where *d* is the shortest distance from ``s`` to ``t``. Over all
  64. supersteps, *O(E)* messages of constant size will be transmitted.
  65. Algorithm Description
  66. ---------------------
  67. The algorithm consists of two simultaneous breadth-first traversals
  68. from ``s`` and ``t`` respectively. The algorithm utilizes a single
  69. queue for both traversals with the traversal from ``s`` being denoted
  70. by a ``gray`` entry in the color map and the traversal from ``t``
  71. being denoted by a ``green`` entry. The traversal method is similar
  72. to breadth-first search except that no visitor event points are
  73. called. When any process detects a collision in the two traversals
  74. (by attempting to set a ``gray`` vertex to ``green`` or vice-versa),
  75. it signals all processes to terminate on the next superstep and all
  76. processes return ``true``. If the queues on all processes are empty
  77. and no collision is detected then all processes terminate and return
  78. ``false``.
  79. -----------------------------------------------------------------------------
  80. Copyright (C) 2009 The Trustees of Indiana University.
  81. Authors: Nick Edmonds and Andrew Lumsdaine
  82. .. |Logo| image:: pbgl-logo.png
  83. :align: middle
  84. :alt: Parallel BGL
  85. :target: http://www.osl.iu.edu/research/pbgl
  86. .. _Distributed Graph: DistributedGraph.html
  87. .. _Incidence Graph: http://www.boost.org/libs/graph/doc/IncidenceGraph.html
  88. .. _Distributed Property Map: distributed_property_map.html
  89. .. _GlobalDescriptor: GlobalDescriptor.html