Opened 8 years ago

Last modified 8 years ago

#10222 new Bugs

root map not correctly computed by strong_components

Reported by: Alex <alxlaus@…> Owned by: Jeremiah Willcock
Milestone: To Be Determined Component: graph
Version: Boost 1.56.0 Severity: Problem
Keywords: Cc: alxlaus@…

Description

I think in boost::graph strong_components does not compute the root map as claimed in the documentation, i.e., that it maps each vertex to the root of the corresponding scc.

For a counter-example consider the following graph (attached as a MWE):

a <-> b <-> c

Suppose the algorithm starts with node a. The protocol of the algorithm is as follows, the first column being the discovery time, the second being the content of the root map, and * indicating uninitialized values:

1) a -> (0, a), b -> (*, *), c -> (*, *) discovered a

2) a -> (0, a), b -> (1, b), c -> (*, *) discovered b

3) a -> (0, a), b -> (1, b), c -> (2, c) discovered c

4) a -> (0, a), b -> (1, b), c -> (1, b) finished c

5) a -> (0, a), b -> (0, b), c -> (1, b) finished b

6) a -> (0, a), b -> (0, a), c -> (1, b) finished a

The value of the root map for c is 1, correct would be 0.

The output of the example is as follows:
The example graph:
a --> b
b --> a c
c --> b

Vertex a is in component 0 and has root 0
Vertex b is in component 0 and has root 0
Vertex c is in component 0 and has root 1

Attachments (2)

rootmap_bug.cpp (1.4 KB ) - added by Alex <alxlaus@…> 8 years ago.
MWE
rootmap_bug.2.cpp (1.6 KB ) - added by Alex <alxlaus@…> 8 years ago.

Download all attachments as: .zip

Change History (4)

by Alex <alxlaus@…>, 8 years ago

Attachment: rootmap_bug.cpp added

MWE

by Alex <alxlaus@…>, 8 years ago

Attachment: rootmap_bug.2.cpp added

comment:1 by Alex <alxlaus@…>, 8 years ago

Cc: alxlaus@… added

comment:2 by Alex <alxlaus@…>, 8 years ago

I created a patch and a pull request on github.

Note: See TracTickets for help on using tickets.