문제

the depth-first algorithm implemented in the boost library visits each vertex just one time.

Is there any work around to deactivate this option. I want that the vertexes can be visited whenever there is a branch in any vertex.

any suggestion...

EDIT: The graph is acyclic.

도움이 되었습니까?

해결책

If you want to enumerate all paths in an acyclic graph, then I don't think you can easily modify depth-first search to do that. There are algorithms specifically designed for this purpose, in particular: Rubin, F.; , "Enumerating all simple paths in a graph," Circuits and Systems, IEEE Transactions on , vol.25, no.8, pp. 641- 642, Aug 1978.

If you know the Floyd-Warshall algorithm, you can easily modify it to compute a list of paths in each element of the matrix, instead of min distance, which will do the job. The above article uses some bit operations to make this run a bit faster.

다른 팁

want that the vertexes can be visited whenever there is a branch in any vertex.

What do you propose that an iterator do when it reaches a branch at a vertex?

Depth first search is just one answer this question. Here are some others.

But you have to choose something. It's not a matter of turning off DFS.

I think that is impossible by design. Because if your graph contains cycles (and you have them there, when you say, that the vertex can be visited more than once), the algorithm will end up in endless loop.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top