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

LabelledAdjacencyMap? #109

Closed
o1lo01ol1o opened this issue Aug 13, 2018 · 6 comments
Closed

LabelledAdjacencyMap? #109

o1lo01ol1o opened this issue Aug 13, 2018 · 6 comments

Comments

@o1lo01ol1o
Copy link
Contributor

I have a case where I need to model a graph (of labeled edges) via an adjacency map representation (I need, among other things, to sort the graphs topologically and compute the cycles via scc). It looks like the Diode (Set e) would take care of the labeling issue (my labels function only as edge identifiers) but I'm not sure what the best representation would be for the adjacency map itself given that I also need a King-Launchbury representation if I'm to avoid writing the sorts myself. Could anyone advise?

@snowleopard
Copy link
Owner

Hi @o1lo01ol1o!

I think the implementation will be pretty similar to Algebra.Graph.AdjacencyMap but instead of

Map a (Set a)

the labelled version will use

Map a (Map a e)

as the underlying data structure (with edge labels of type e).

If you don't want to use dioids for labelling, then here is an alternative:

Map a (Set (a, e))

Now instead of collapsing parallel edges using one of dioid's operations, you explicitly store each edge separately.

The former seems a bit more general, since one can always pick e = Set e' and obtain the latter.

Would you like to give it a try?

@o1lo01ol1o
Copy link
Contributor Author

Hi, thanks for the reply. I ended up with something similar to the latter in the interm. However, I I'll try to re-tailor my implementation and create a PR.

@snowleopard
Copy link
Owner

Thanks!

By the way, I think I was wrong in my previous comment when I said that one of the encodings is more general than the other -- they are actually equivalent in terms of generality. But one may be easier/faster to work with than the other.

@o1lo01ol1o
Copy link
Contributor Author

See #113

@snowleopard
Copy link
Owner

snowleopard commented Oct 6, 2018

After merging #113, we still need to do the following:

  • Add conversions between labelled and unlabelled adjacency maps
  • Improve documentation
  • Add tests

@snowleopard
Copy link
Owner

I think we can close this issue. See the module here:

https://hackage.haskell.org/package/algebraic-graphs/docs/Algebra-Graph-Labelled-AdjacencyMap.html

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

No branches or pull requests

2 participants