Thanks for the quick and helpful reply!
I tried the branch and the edge removal example works fine now.
however, when I try to get degrees:
g = SimpleWeightedDiGraph([1, 2, 3], [2, 3, 1], [1.0, 6.0, 4.0])
outdegree(g)
I now get the following error:
<strong>MethodError: no method matching length(::Base.Iterators.Filter{Base.var"#58#59"{typeof(iszero)},SubArray{Int64,1,Array{Int64,1},Tuple{UnitRange{Int64}},true}})</strong>
<strong>Closest candidates are:
length(!Matched::Core.SimpleVector) at essentials.jl:593
length(!Matched::Base.MethodList) at reflection.jl:849
length(!Matched::Core.MethodTable) at reflection.jl:923
...</strong>
in top-level scope at [untitled:15](#)
in outdegree at [LightGraphs\UPjU9\src\core.jl:97](#)
in outdegree at [LightGraphs\UPjU9\src\core.jl:97](#)
in collect at [base\array.jl:622](#)
in iterate at [base\generator.jl:47](#)
in at [base\none](#)
in outdegree at [LightGraphs\UPjU9\src\core.jl:96](#)
This seems to be due to the type change of outneighbors
. Calling length on the .itr
field of neighbors does the job:
onb = outneighbors(g, 1)
length(onb.itr)
Also, i noticed that when i convert a SimpleWeightedDiGraph to a SimpleDiGraph, the edge directions seem to revert:
[println(e) for e in edges(g)]
Edge 1 => 2 with weight 1.0
Edge 2 => 3 with weight 6.0
Edge 3 => 1 with weight 4.0
[println(e) for e in edges(SimpleDiGraph(g))]
Edge 1 => 3
Edge 2 => 1
Edge 3 => 2
Not sure if this is expected behavior or if maybe I’m not supposed to do it like that, though.