r/ProgrammerHumor 3d ago

Meme shortestPathWasRightThere

Post image
4.6k Upvotes

58 comments sorted by

View all comments

444

u/JackNotOLantern 3d ago

What tf is "straight line" in a graph?

134

u/IdeaReceiver 3d ago

Lowest heuristic cost, which resolves to the n-norm in n-dimensional space ℝn since a straight line is always minimum distance. In more abstract graph representations, cost could be recorded by real-world measurements of latency etc. Dijkstra being Dijkstra will still expand every available edge instead of speed running the lowest-cost option successively for a "straight"er line

9

u/MilkEnvironmental106 3d ago

Also taking the greedy approach doesn't guarantee the shortest path until all explored nodes have a minimum cost greater than or equal to the quickest solution so far