[Lemon-commits] [lemon_svn] alpar: r2350 - hugo/trunk/lemon
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:51:59 CET 2006
Author: alpar
Date: Wed Nov 16 14:26:04 2005
New Revision: 2350
Modified:
hugo/trunk/lemon/topology.h
Log:
Empty graph is (strongly) connected.
Modified: hugo/trunk/lemon/topology.h
==============================================================================
--- hugo/trunk/lemon/topology.h (original)
+++ hugo/trunk/lemon/topology.h Wed Nov 16 14:26:04 2005
@@ -48,12 +48,12 @@
/// Check that the given undirected graph connected.
/// \param graph The undirected graph.
/// \return %True when there is path between any two nodes in the graph.
- /// \warning The empty graph is not connected.
+ /// \note By definition, the empty graph is connected.
template <typename UndirGraph>
bool connected(const UndirGraph& graph) {
checkConcept<concept::UndirGraph, UndirGraph>();
typedef typename UndirGraph::NodeIt NodeIt;
- if (NodeIt(graph) == INVALID) return false;
+ if (NodeIt(graph) == INVALID) return true;
Dfs<UndirGraph> dfs(graph);
dfs.run(NodeIt(graph));
for (NodeIt it(graph); it != INVALID; ++it) {
@@ -72,6 +72,8 @@
///
/// \param graph The graph. It should be undirected.
/// \return The number of components
+ /// \note By definition, the empty graph consists
+ /// of zero connected components.
template <typename UndirGraph>
int countConnectedComponents(const UndirGraph &graph) {
checkConcept<concept::UndirGraph, UndirGraph>();
@@ -237,11 +239,11 @@
/// \return %False when the graph is not strongly connected.
/// \see connected
///
- /// \warning Empty graph is not strongly connected.
+ /// \note By definition, the empty graph is strongly connected.
template <typename Graph>
bool stronglyConnected(const Graph& graph) {
checkConcept<concept::StaticGraph, Graph>();
- if (NodeIt(graph) == INVALID) return false;
+ if (NodeIt(graph) == INVALID) return true;
typedef typename Graph::Node Node;
typedef typename Graph::NodeIt NodeIt;
@@ -293,6 +295,8 @@
///
/// \param graph The graph.
/// \return The number of components
+ /// \note By definition, the empty graph has zero
+ /// strongly connected components.
template <typename Graph>
int countStronglyConnectedComponents(const Graph& graph) {
checkConcept<concept::StaticGraph, Graph>();
@@ -356,10 +360,6 @@
/// \image latex strongly_connected_components.eps "Strongly connected components" width=\textwidth
///
/// \param graph The graph.
- /// \param compMap A writable node map. The values will be set from 0 to
- /// the number of the connected components minus one. Each values of the map
- /// will be set exactly once, the values of a certain component will be
- /// set continuously.
/// \retval compMap A writable node map. The values will be set from 0 to
/// the number of the strongly connected components minus one. Each values
/// of the map will be set exactly once, the values of a certain component
More information about the Lemon-commits
mailing list