Empty graph is (strongly) connected.
authoralpar
Wed, 16 Nov 2005 13:26:04 +0000
changeset 18075f2f3d982eba
parent 1806 1530c115580f
child 1808 c499025ca638
Empty graph is (strongly) connected.
lemon/topology.h
     1.1 --- a/lemon/topology.h	Wed Nov 16 13:21:57 2005 +0000
     1.2 +++ b/lemon/topology.h	Wed Nov 16 13:26:04 2005 +0000
     1.3 @@ -48,12 +48,12 @@
     1.4    /// Check that the given undirected graph connected.
     1.5    /// \param graph The undirected graph.
     1.6    /// \return %True when there is path between any two nodes in the graph.
     1.7 -  /// \warning The empty graph is not connected.
     1.8 +  /// \note By definition, the empty graph is connected.
     1.9    template <typename UndirGraph>
    1.10    bool connected(const UndirGraph& graph) {
    1.11      checkConcept<concept::UndirGraph, UndirGraph>();
    1.12      typedef typename UndirGraph::NodeIt NodeIt;
    1.13 -    if (NodeIt(graph) == INVALID) return false;
    1.14 +    if (NodeIt(graph) == INVALID) return true;
    1.15      Dfs<UndirGraph> dfs(graph);
    1.16      dfs.run(NodeIt(graph));
    1.17      for (NodeIt it(graph); it != INVALID; ++it) {
    1.18 @@ -72,6 +72,8 @@
    1.19    ///
    1.20    /// \param graph The graph. It should be undirected.
    1.21    /// \return The number of components
    1.22 +  /// \note By definition, the empty graph consists
    1.23 +  /// of zero connected components.
    1.24    template <typename UndirGraph>
    1.25    int countConnectedComponents(const UndirGraph &graph) {
    1.26      checkConcept<concept::UndirGraph, UndirGraph>();
    1.27 @@ -237,11 +239,11 @@
    1.28    /// \return %False when the graph is not strongly connected.
    1.29    /// \see connected
    1.30    ///
    1.31 -  /// \warning Empty graph is not strongly connected.
    1.32 +  /// \note By definition, the empty graph is strongly connected.
    1.33    template <typename Graph>
    1.34    bool stronglyConnected(const Graph& graph) {
    1.35      checkConcept<concept::StaticGraph, Graph>();
    1.36 -    if (NodeIt(graph) == INVALID) return false;
    1.37 +    if (NodeIt(graph) == INVALID) return true;
    1.38  
    1.39      typedef typename Graph::Node Node;
    1.40      typedef typename Graph::NodeIt NodeIt;
    1.41 @@ -293,6 +295,8 @@
    1.42    ///
    1.43    /// \param graph The graph.
    1.44    /// \return The number of components
    1.45 +  /// \note By definition, the empty graph has zero
    1.46 +  /// strongly connected components.
    1.47    template <typename Graph>
    1.48    int countStronglyConnectedComponents(const Graph& graph) {
    1.49      checkConcept<concept::StaticGraph, Graph>();
    1.50 @@ -356,10 +360,6 @@
    1.51    /// \image latex strongly_connected_components.eps "Strongly connected components" width=\textwidth
    1.52    ///
    1.53    /// \param graph The graph.
    1.54 -  /// \param compMap A writable node map. The values will be set from 0 to
    1.55 -  /// the number of the connected components minus one. Each values of the map
    1.56 -  /// will be set exactly once, the values of a certain component will be
    1.57 -  /// set continuously.
    1.58    /// \retval compMap A writable node map. The values will be set from 0 to
    1.59    /// the number of the strongly connected components minus one. Each values 
    1.60    /// of the map will be set exactly once, the values of a certain component