Question

From the boost graph manual for the function remove_vertex

It is assumed that there are no edges to or from vertex u when it is removed. One way to make sure of this is to invoke clear_vertex() beforehand.

What happens if you do call remove_vertex() on a vertex that is connected to other vertices? Does it lead to undefined behavior?

From the quote in the manual it would seem that something bad will happen. If so why does it not throw an exception when called in this way?

Was it helpful?

Solution

Apart from some algorithms and utilities, the Boost Graph Library in general does not throw exceptions, especially when accessing or modifying the structure of a graph. I guess this decision has been made due to performance reasons.

I'd compare this API model to STL. In STL violating a pre-condition leads to undefined behavior rather than to throwing an exception.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top