GraphPlot.jl icon indicating copy to clipboard operation
GraphPlot.jl copied to clipboard

Layout problems with directed graph containing many disconnected components

Open timholy opened this issue 6 years ago • 2 comments

I'm attaching some files that show the result of rendering with GraphPlot (gets it wrong) and with TikzGraph (gets it right).

The data are here: https://drive.google.com/file/d/12CfjV7kv2r7EAmSQoudfMog7p9r-OAr1/view?usp=sharing

Save that to /tmp/backedges.jld2 or something similar. Then you can create the graph with

julia> using FileIO

julia> backedges = load("/tmp/backedges.jld2", "backedges");

julia> using LightGraphs

julia> g = SimpleDiGraph(length(backedges))
{652, 0} directed simple Int64 graph

julia> for (i, deps) in enumerate(backedges)
           for src in deps
               add_edge!(g, src, i)
           end
       end

and then plot g.

backedges.pdf backedges2.pdf

With GraphPlot you can see the edges don't connect to nodes on both ends.

timholy avatar Jan 31 '19 13:01 timholy

That is very ugly. I have't checked it yet, but is is possible, that what like unconnected lines, are actually the arrowheads of the lines, that are not resized properly?

simonschoelly avatar Jan 31 '19 13:01 simonschoelly

As I suspected, the problem is, that the arrowhead size is not scaled nicely. If you do something like gplot(g, arrowlengthfrac=0.01)it looks much nicer.

This does not mean of course, that we shouldn't fix the arrowhead size.

simonschoelly avatar Jan 31 '19 14:01 simonschoelly