twitter / cassovary

Cassovary is a simple big graph processing library for the JVM
http://twitter.com/cassovary
Apache License 2.0
1.05k stars 150 forks source link

Clarify support for Undirected Graphs #140

Open plofgren opened 9 years ago

plofgren commented 9 years ago

I have an application where I needed an undirected graph. I actually didn't realize until today that "Mutual" in StoredGraphDir meant undirected and was starting to write my own UndirectedGraph wrapper class when I noticed it. How should we make this more clear? For example I could add a comment to StoredGraphDir along the lines of Mutual, // In a mutual graph, the outbound and inbound neighbors of each node are equal, and space is typically saved by only storing the outbound neighbors of each node and/or add to the documentation of DirectedGraph that it actually also supports undirected graphs. Or should there be an UndirectedGraph wrapper in Cassovary? @pankajgupta

pankajgupta commented 9 years ago

Let's make this more explicit by adding a wrapper.

On Thu, Jan 29, 2015 at 2:05 PM, Peter Lofgren notifications@github.com wrote:

I have an application where I needed an undirected graph. I actually didn't realize until today that "Mutual" in StoredGraphDir meant undirected and was starting to write my own UndirectedGraph wrapper class when I noticed it. How should we make this more clear? For example I could add a comment to StoredGraphDir along the lines of Mutual, // In a mutual graph, the outbound and inbound neighbors of each node are equal, and space is typically saved by only storing the outbound neighbors of each node and/or add to the documentation of DirectedGraph that it actually also supports undirected graphs. Or should there be an UndirectedGraph wrapper in Cassovary? @pankajgupta https://github.com/pankajgupta

— Reply to this email directly or view it on GitHub https://github.com/twitter/cassovary/issues/140.

Alireza-Farahani commented 5 years ago

I'm using version 7.1.0 and can't find anything explicitly for undirected graphs. What's the correct way of working with undirected graphs? A simple graph like 1 2 when loaded by this code:

    val graphReader = ListOfEdgesGraphReader.forIntIds(
      dir, prefix,
      graphDir = StoredGraphDir.Mutual 
    )
    val graph = graphReader.toArrayBasedDirectedGraph()
    println(graph)

prints

Node count: 2
Edge count: 2
Nodes:
NodeId => 1
InboundNodes[1] =>2|
OutboundNodes[1] =>2|

NodeId => 2
InboundNodes[0] =>
OutboundNodes[0] =>

which I think is confusing.