Skip to content
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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

adithyaov
Copy link
Contributor

Added shortest path algorithm for a general labeled graph.

-- | A generic Dijkstra algorithm that relaxes the list of edges
-- based on the 'Dioid'.
--
-- If the 'Dioid' is 'Distance' (negative 'Dioid') the relaxation
Copy link
Owner

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?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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.

Copy link
Contributor Author

@adithyaov adithyaov Aug 5, 2019

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.

Copy link
Owner

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.

@adithyaov adithyaov changed the title Dijkstra for Labelled.AdjacencyMap.Algorithm Shortest Path Algorithms for Labelled.AdjacencyMap.Algorithm Aug 7, 2019
@adithyaov adithyaov changed the title Shortest Path Algorithms for Labelled.AdjacencyMap.Algorithm Optimum Path Algorithms for Labelled.AdjacencyMap.Algorithm Aug 8, 2019
@snowleopard
Copy link
Owner

@adithyaov I guess this PR is blocked by #232, right?

@adithyaov
Copy link
Contributor Author

adithyaov commented Sep 10, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants