JuliaGraphs / GraphPlot.jl

Graph visualization for Julia.
http://JuliaGraphs.github.io/GraphPlot.jl/
Other
200 stars 62 forks source link

Cannot plot a graph before command print() #173

Closed lucasmsoares96 closed 2 years ago

lucasmsoares96 commented 2 years ago

When trying to plot a graph like the one below, nothing is plotted.

using GraphPlot
using Graphs
using SimpleWeightedGraphs
graph = [
    00 01 05 07 09 00
    01 00 06 04 03 00
    05 06 00 05 00 10
    07 04 05 00 08 03
    09 03 00 08 00 00
    00 00 10 03 00 00
]
w = SimpleWeightedGraph(graph)
arestas = edges(w)
pesos = [p.weight for p ∈ arestas]

gplot(w, edgelabel=pesos, nodelabel=1:nv(w), edgelabeldistx=0.5, edgelabeldisty=0.5)
println("")

But I put the command print("") before the gplot it works fine.

arestas = edges(w)
pesos = [p.weight for p ∈ arestas]

println("")
gplot(w, edgelabel=pesos, nodelabel=1:nv(w), edgelabeldistx=0.5, edgelabeldisty=0.5)
SimonDanisch commented 2 years ago

Very likely, that's because the display system only picks up the last value returned. try an explicit display(gplot(...)) if you want other lines after the plotting command.

lucasmsoares96 commented 2 years ago

Worked perfectly! Thank you!