connected_components called on empty filtered graph
Open
algorithm
beginner friendly
priority: high
- Dominant language
- C++
- Stars
- 392
- Forks
- 239
- Avg merge
- 1d 11m
- Merged PRs (30d)
- 20
Description
The connected_components function returns `(std::numeric_limits::max)() + 1` when called on a filtered graph with all vertices filtered out.
An example of this problem can be found here:
https://godbolt.org/z/vWsG8j
If the line
```cpp
if (num_vertices(g) == 0) return 0;
```
was replaced with
```cpp
typedef typename boost::graph_traits::vertex_iterator vi;
std::pair verts = vertices(g);
if (verts.first == verts.second)
return 0;
```
the function would work as expected.
Contributor guide
Assessment
This issue has not been assessed yet.