bitwalker / libgraph

A graph data structure library for Elixir projects
MIT License
524 stars 75 forks source link

get_shortest_path doesn't work correctly on undirected graphs #37

Open liveforeverx opened 4 years ago

liveforeverx commented 4 years ago

Hi!

I found an example, where get_shortest_path didn't works, where it looks like it should:

g = Graph.new(type: :undirected) |> Graph.add_vertices([1, 2, 3]) |> Graph.add_edge(1, 3) |> Graph.add_edge(3, 2)
Graph.get_shortest_path(g, 1, 2) # => nil

I think, that get_shortest_path should raise on undirected graphs or calculate path correctly.

slemonide commented 4 years ago

This seems to be a general problem, see issue #11 .

bitwalker commented 4 years ago

The pathfinding has not been implemented for undirected graphs yet, but if anyone is interested in lending a hand there, I'd love to get support fleshed out so that we can get it addressed. I'm happy to lend a hand in review or with suggestions on how to approach it for anyone not sure where to start.

Minh-Khang commented 3 years ago

The pathfinding has not been implemented for undirected graphs yet, but if anyone is interested in lending a hand there, I'd love to get support fleshed out so that we can get it addressed. I'm happy to lend a hand in review or with suggestions on how to approach it for anyone not sure where to start.

Hello, I made a implementation for finding shortest path on undirected graphs. Could you review it ?