Plotting weighted graphs

Is it possible to plot a SimpleWeightedGraphs.SimpleWeightedDiGraph?
Using GraphPlot I get an error.

It would be very helpful if you provide more information about your situation.
For example: Which kind of data do you want to plot? Where do you get your weights from? What have you done so far? Which error do you get? Can you provide a MWE to reproduce the error?

To answer your general question: yes, it is possible to plot a SimpleWeightedDiGraph. Have you had a look at the general examples of SimpleWeightedGraphs.jl ?

1 Like

The weights are a lose representation of the geographic distance of the nodes. But I don’t see why this would be important.

using LightGraphs, SimpleWeightedGraphs, GraphPlot

g = SimpleWeightedGraph(3)  
add_edge!(g, 1, 2, 0.5)
add_edge!(g, 2, 3, 0.8)
add_edge!(g, 1, 3, 2.0)

gplot(g)

ERROR: LoadError: MethodError: no method matching _src_index(::SimpleWeightedEdge{Int64,Float64}, ::SimpleWeightedGraph{Int64,Float64})
Closest candidates are:
_src_index(::LightGraphs.SimpleGraphs.SimpleEdge, ::AbstractGraph)

However, using

loc_x, loc_y = spring_layout(g)

and drawing it myself works.

Following the instructions for GraphPlot, I’ve not been able to plot it as well. There seems to be no method for SimpleWeightedGraphs.

Maybe consider asking for such an extension in the issues section of the GraphPlot github repo. I’ve found this related issue on the SimpleWeightedGraphs repo.