GraphPlot: calling gplot() inside function does often not work (in Atom)

Dear community,

I observe a strange behavior when plotting graphs with GraphPlot. In most cases it refuses to plot the input graph if I call gplot() via a function. However, sometimes (in rare cases) it works. Calling gplot() from the global scope works fine. Here is a minimal example:

using LightGraphs
using GraphPlot

function myPlotFunction( g::SimpleDiGraph )
    gplot( g )
    return nothing
end

g = SimpleDiGraph( 5 )
add_edge!(g, 1, 2)
add_edge!(g, 3, 4)

# THIS DOES NOT PLOT 
myPlotFunction( g )

# THIS PLOTS AS EXPECTED
gplot( g )

Do you have any suggestions how to fix that? Does anyone else observe this? I am on Ubuntu 18.04, Julia 1.1.0.

Thanks in advance.

I removed return nothing from the function and it seems to generate correctly.

1 Like

Great thanks,… that is probably the reason why it “often” did not work for me. I terminate void functions with “return nothing” in most cases.