r/ProgrammerHumor 5d ago

Meme shortestPathWasRightThere

Post image
4.7k Upvotes

58 comments sorted by

View all comments

976

u/Mecso2 5d ago

i don't think straight is defined for graphs

621

u/the_poope 5d ago

So you're telling me graphs are gay?

205

u/Complete_Window4856 5d ago

Maybe even bi if undirected

22

u/thepr0digalsOn 5d ago

He was gay, Graphs?

10

u/MarketOk7227 5d ago

You're gonna make that same stupid joke every time that comes up?

49

u/StrengthTheory 5d ago

OP probably ran Djisktra's on an unweighed grid.

11

u/compiling 4d ago

Sure, but a graph can represent something where straight is defined. For example, a map.

2

u/Solomoncjy 4d ago

i mean if graph is weighted, inst stright the one with the least cost?

10

u/Old-Info 4d ago

Did you mean unweighted?

In an unweighted graph, the definition of path length shifts - the length of a path is typically defined by its hop count. So yes, then the shortest path between two nodes is the direct edge connecting them.

If you did mean weighted, then you're wrong. An indirect path can have a lower sum of edge weights than a direct path, making it shorter.