Intersect
Intersect

Reputation: 23

Does Dijkstra works for non-negative or positive weights?

I know why Dijkstra doesn't work for negative weights but is 0 allowed as a weight? I think that if two nodes have a 0 weight then the edge connecting those nodes can be eliminated and nodes be merged as one. Is this right? or I'm missing something?

Upvotes: 1

Views: 800

Answers (1)

codecrazer
codecrazer

Reputation: 535

Yes, if the segment has weight zero, we can delete it, if all the segement between that pair of point are zero, you can delete them all, and merge two point to one!

Hope this post help you!

Upvotes: 1

Related Questions