-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimum Path Algorithms for Labelled.AdjacencyMap.Algorithm #225
base: main
Are you sure you want to change the base?
Conversation
-- | A generic Dijkstra algorithm that relaxes the list of edges | ||
-- based on the 'Dioid'. | ||
-- | ||
-- If the 'Dioid' is 'Distance' (negative 'Dioid') the relaxation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are "negative" and "positive" dioids common terms? What is their precise definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you just use ShortestDistance
and WidestPath
from Algebra.Graph.Label
?
https://hackage.haskell.org/package/algebraic-graphs-0.4/docs/Algebra-Graph-Label.html#t:ShortestPath
https://hackage.haskell.org/package/algebraic-graphs-0.4/docs/Algebra-Graph-Label.html#t:WidestPath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are "negative" and "positive" dioids common terms? What is their precise definition?
I apologize, I actually was talking about the order of the underlying semi-ring.
If 1 > 0
, it would be a positive semi-ring. These definitions assume that there is a partial order defined on the set of elements which I believe I did not mention.
Couldn't you just use ShortestDistance and WidestPath from Algebra.Graph.Label
This is not a generic algorithm but a Dijkstra algorithm. Dijkstra requires a priority heap depending on the order of the semi-ring. Even if one would use ShortestDistance
the order of relaxation is decided by the heap.
Using ShortestDistance
with a max-heap or WidestPath
with a min-heap would result in improper results. The type of heap is decided using the order of the semi-ring.
A generic single source shortest path algorithm does not require a priority heap but has a higher runtime complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@snowleopard I think one cannot define the order of the relaxation (min-heap vs max-heap) based on the type of Semiring. I believe we should take into account how +
and *
function as well.
I'm trying to find some good papers to read which describe a generic single source shortest path with the time complexity of Dijkstra. Please let me know if you know any good books/papers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These definitions assume that there is a partial order defined on the set of elements which I believe I did not mention.
Right. And I guess you are using Ord
as this partial order?
Perhaps, you could use the following partial order defined for any idempotent semiring?
po x y = (x + y == y)
This is the order I use for algebraic graphs: isSubgraphOf x y = (x + y == y)
.
Please let me know if you know any good books/papers.
I think you already identified some very good papers on this topic. Not sure there is anything I can add to your list.
…rtest-path-labelled
@adithyaov I guess this PR is blocked by #232, right? |
@snowleopard Yes. I'll address #232 and this as soon as possible. I need to write the tests and improve the docs in this PR I believe. |
Added shortest path algorithm for a general labeled graph.