Message Boards Message Boards

GROUPS:

Break out of a DepthFirstScan (DFS) when a condition is fullfiled?

Posted 6 months ago
707 Views
|
2 Replies
|
0 Total Likes
|

There is a graph g. I'd like to DepthFirstScan it:

DepthFirstScan[g, 5, {"VisitedVertex" -> (G[#1, #2] &)}];

where G[x,y] := is some function that makes a change to the graph when a condition is fulfilled.

Then I'd like to stop the scan of the graph.

Can I stop the DFS by some control in G[x,y]?

2 Replies
Posted 6 months ago

Hi Dan,

I have not tested this, and it is probably not the best way.

In G add Throw["Done"] when the condition is satisfied and then Catch[DepthFirstScan[...]]

Posted 6 months ago

Thanks Rohit, Certainly I'll give it a try... Thanks again.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract