I recently noticed that converting from a SimpleWeightedDiGraph to a SimpleDiGraph inverts the direction of the edges.
using SimpleWeightedGraphs, LightGraphs
# Create lists of sources and destination vertices
sources = [i for i in 1:3]
destinations = [4 for _ in 1:length(sources)]
weights = [1. for _ in 1:length(sources)]
# Construct the weighted and directed graph
g_weighted = SimpleWeightedDiGraph(sources, destinations, weights)
edge_weights = getfield.(collect(edges(g_weighted)), :weight)
# Convert the weighted graph to a simple directed graph
g_directed = SimpleDiGraph(g_weighted)
However:
julia> collect(edges(g_weighted))
3-element Array{SimpleWeightedEdge{Int64,Float64},1}:
Edge 1 => 4 with weight 1.0
Edge 2 => 4 with weight 1.0
Edge 3 => 4 with weight 1.0
Hello everyone,
Thanks for your work on SimpleWeightedGraphs.jl~
I recently noticed that converting from a
SimpleWeightedDiGraph
to aSimpleDiGraph
inverts the direction of the edges.However:
and
Of course this is easily fixed by doing
reverse(g_directed)
, but it is confusing nevertheless.Thanks!