From 30ef8f84ff1856838bdd045f5dfe0d00997e8d56 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 2 Dec 2004 16:32:05 +0000 Subject: [PATCH] Graphs with zero vertices have zero connected components [SVN r26403] --- include/boost/graph/connected_components.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/graph/connected_components.hpp b/include/boost/graph/connected_components.hpp index 2f7d1b3a..98f9ce42 100644 --- a/include/boost/graph/connected_components.hpp +++ b/include/boost/graph/connected_components.hpp @@ -76,6 +76,8 @@ namespace boost { connected_components(const Graph& g, ComponentMap c, const bgl_named_params& params) { + if (num_vertices(g) == 0) return 0; + typedef typename graph_traits::vertex_descriptor Vertex; function_requires< WritablePropertyMapConcept >(); typedef typename boost::graph_traits::directed_category directed; @@ -93,6 +95,8 @@ namespace boost { inline typename property_traits::value_type connected_components(const Graph& g, ComponentMap c) { + if (num_vertices(g) == 0) return 0; + typedef typename graph_traits::vertex_descriptor Vertex; function_requires< WritablePropertyMapConcept >(); typedef typename boost::graph_traits::directed_category directed;