aysylu / loom

Graph library for Clojure. Mailing list https://groups.google.com/forum/#!forum/loom-clj
http://aysy.lu/loom/
887 stars 108 forks source link

core.matrix support? #28

Closed mikera closed 10 years ago

mikera commented 10 years ago

I'm currently using core.matrix matrices to represent graphs, and interested in finding out if I would also be able to use these matrices in loom in order to take advantage of the various algorithms. Is there a recommended strategy to incorporate additional graph implementations using matrices?

As far as I can see, it seems like it would be possible to extend the loom protocols to core.matrix matrices without too much difficulty. But I don't want to start hacking on that unless I can confirm that this is a sensible direction. Would you accept a PR that enabled something like this?

gdevanla commented 10 years ago

@mikera Currently most of the algorithms are implemented with adjacency list, though this fact is abstracted away in the protocols. By representing we graphs as adjacency matrices we also might want to take advantage of the structure when it be efficient. Alternatively, if an instance of the graph is implemented as an adjacency matrix, it would makes sense to use some of the operations provided by core.matrix rather than have loom handle it.

In addition, may be we should consider making this dependency on core.matrix optional? I am also eager to to see loom extended to support operations on matrix representation of graphs.

Also, as part of some of the algorithms I have been adding, I would love to have core.matrix incorporated. That would help implement PageRank and Spectral analysis algorithms with fast matrix operations.

mikera commented 10 years ago

I think it should be possible to have an optional loom.matrix namespace that depends on core.matrix but doesn't have it as an explicit dependency in the project.clj. That way you don't have to have core.matrix as a required dependency, but can still have the functionality available if people want it (they would need to add core.matrix as a dependency manually of course...)

Alternatively, a separate repo / library which adds the matrix based functionality would be a possibility that has both loom and core.matrix as dependencies.

I've done a couple of demos with matrix representations of graphs, e.g. a quick pagerank demo:

https://github.com/mikera/core.matrix/blob/develop/src/test/clojure/clojure/core/matrix/demo/pagerank.clj

aysylu commented 10 years ago

@mikera, I think your idea for making a separate loom.matrix library is excellent. That's what we've been doing for titanium and gorilla-repl integration.

This is very exciting, and I'm looking forward to seeing Loom represented in core.matrix!

aysylu commented 10 years ago

Please reopen the issue if there's anything else.