Accessing edges in non-sorted fashion Graphs.jl?

g = DiGraph(3);
add_edge!(g, 2, 1)
add_edge!(g, 1, 2)
add_edge!(g, 3, 2)

julia> collect(edges(g))
3-element Vector{LightGraphs.SimpleGraphs.SimpleEdge{Int64}}:
 Edge 1 => 2
 Edge 2 => 1
 Edge 3 => 2

edges collected here are obtained in sorted fashion. But How do we obtain the edges in the order we pushed or added ?

1 Like

You need to keep track of that yourself. The internal representation of a SimpleDiGraph is, well, too simple to represent such information.

Did you find a solution with that ?

Sorry I missed that topic. I had the same question once, and the only workaround I found was to implement a custom graph type that stores edges in arrival order. If this is still relevant I can help you do that

I did find solution for this. But dont remember at the moment. I will try to recollect in my old codes over next weekend