[BGL] Best way to abort an algorithm from within a visitor?
Is there a way to abort an algorithm while it's processing? Can I throw an exception out of a visitor method? I have a case where I need the algorithm to crunch on a large graph until some condition dependent on property data is reached. If and when the condition is met, I would like to skip the processing of the remaining vertices/edges and save the cycles. Does using exceptions sound like a reasonable approach? - Thanks Chris P.S. Thanks for the help with properties and property maps the other day. I cleaned up my code and eventually tracked the source of my considerable confusion to a bug in an operator= defined on the object that I'm using as an internal property. This bug manifested itself by re-initializing previously set data seemingly at random >8|-~ Arg... My bad.
On Wed, Sep 18, 2002 at 11:42:14AM -0400, Chris Russell wrote:
Is there a way to abort an algorithm while it's processing? Can I throw an exception out of a visitor method? I have a case where I need the algorithm to crunch on a large graph until some condition dependent on property data is reached. If and when the condition is met, I would like to skip the processing of the remaining vertices/edges and save the cycles. Does using exceptions sound like a reasonable approach?
I use that technique to abort the Dijkstra shortest path search when I find my goal node. It works fine, as far as I can tell, but I'd be interested to learn if there is a better way. -S
Thanks Steve. I guess one possible issue would be that the vertex/edge
properties used by the algorithm to maintain state during processing would
be left in some intermediate state. Not an issue if the graph is built
expressly for the purpose of running the algorithm, collecting the answer,
and is subsequently discarded. I'm guessing that most of the algorithms
initialize the properties they rely on to a known state before starting but
I haven't got that far yet.
"Steve M. Robbins"
On Wed, Sep 18, 2002 at 11:42:14AM -0400, Chris Russell wrote:
Is there a way to abort an algorithm while it's processing? Can I throw an exception out of a visitor method? I have a case where I need the algorithm to crunch on a large graph until some condition dependent on property data is reached. If and when the condition is met, I would like to skip the processing of the remaining vertices/edges and save the cycles. Does using exceptions sound like a reasonable approach?
I use that technique to abort the Dijkstra shortest path search when I find my goal node. It works fine, as far as I can tell, but I'd be interested to learn if there is a better way.
-S
participants (2)
-
Chris Russell
-
Steve M. Robbins