stingergraph / StingerGraphs.jl

Julialang bindings to the STINGER graph database
http://www.stingergraph.com
Other
5 stars 3 forks source link

edge weight inserted in one direction only #41

Closed edward-kao closed 6 years ago

edward-kao commented 6 years ago

I noticed that when an edge is inserted, somehow the edge weight is only returned in one direction but not the other. For example:

g1 = Stinger(StingerGraphs.StingerConfig(100, 1004, 1, 1, 110^6, 0, 0, 0)) insert_edge!(g1, 0, 1, 2, 3, 0)

foralledges(g1, 1) do edge, src, etype direction, neighbor = edgeparse(edge) println(direction, " ", neighbor," ", edge.weight) end

produces "2 2 3" as expected, but

foralledges(g1, 2) do edge, src, etype direction, neighbor = edgeparse(edge) println(direction, " ", neighbor," ", edge.weight) end

produces "1 1 0", with weight being 0.

ehein6 commented 6 years ago

This is a stinger bug. I can see from the source code that it only sets edge properties on the out-edge. Maybe someone will claim that this was intentional, but we should definitely open this as an issue against stinger.

ehein6 commented 6 years ago

Thinking a bit more about the design, I can see why this was not implemented.

When we insert an edge from A to B, there is an out-edge stored at A and an in-edge stored at B. When two vertices are connected in both directions, (A->B and B->A), stinger saves space by storing a single edge entry on both sides and marking it as bidirectional. Since there is only one location on either side, there's only room for the outgoing edge's properties. A consequence of this optimization is that edge properties cannot be accessed during traversal of in-edges, unless the edges were inserted in pairs to create an undirected graph. In this case the properties on both sides are the same anyways.

edward-kao commented 6 years ago

Got it. So properties like edge weights can only be accessed on out-going edges. Thank you for the clarification.