![]() ![]() ![]() The algorithm would take some time, but it might be advantageous when you can just perform a look-up for the shortest path in your critical section. If it is worth it, you might run Floyd-Warshall to solve for the shortest paths between every pair of nodes. Sometimes, the advantage may come from not having to store as much data during the search. Other times, you may be able to structure your graph in a different way that makes dfs faster. With some work, you may be able to find an approach that is better than dfs for your graph. Is there a Maximum Distance beyond which you don't care if there is a path? Think about your graph and your objective.Īre there negative edge weights? negative sum cycles? On a graph with cycles, you would want to mark nodes as visited, so as to not perform infinite loops. ![]() With concurrency, you could have some threads searching from the start to end and others from end to start. You would need to coordinate so they don't repeat work by having a concurrent shared data structure they can all inspect and write to safely. You might consider launching multiple threads on the graph to look along different branches. You might consider using an incremental depth-first search if memory is an issue. About the only thing you can do is a breadth-first search or a depth-first search. On a graph with no constraints, that the program has never seen before (or even part of before), and won't see again. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |