Closed edward-kao closed 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.
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.
Got it. So properties like edge weights can only be accessed on out-going edges. Thank you for the clarification.
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.