|
|
|
|
|
by mcv
2703 days ago
|
|
> DFS or IDFS can generally use space proportional to the diameter of the graph, which is far smaller. Maybe, but for "find the closest friend with property X" basic DFS is completely useless. It's likely to give you some distant rando with property X. Fast, sure, but not useful if you're looking for a friend. Besides, if you have cycles in your graph, DFS also needs to keep track of which nodes you've already visited, or it's never going to end. Or use iterative deepening, which you probably want to use anyway to prevent ending up with some distant rando. Slower than BFS but consumes less memory. > "find the ten shortest friend paths to (a unique but unknown) someone with property X, where those paths share no nodes". Ah, but that's a completely different problem. |
|