Graph Visualization NetworkLayout Error: 'layout' not defined

lightgraphs

#1

I’m new to Julia and have recently tried to use LightGraphs and NetworkLayout. I’ve run in to some problems trying to run one of the examples. The toy example is from the readme:

using LightGraphs
using NetworkLayout:SFDP
g = WheelGraph(10)
a = adjacency_matrix(g) # generates a sparse adjacency matrix
network = layout(a,Point2f0,tol=0.1,C=1,K=1,iterations=10) # generate 2D layout

The result is an error: ERROR: UndefVarError: layout not defined
I have tried reinstalling Julia, doing Pkg.update(), doing Pkg.checkout(), and removal of the ‘SFDP’ specification. I have tried running from the Julia CLI, from Atom (uber-julia), and from IJulia Notebook. All result in the same error.

Versioning info from Pkg.status() and versioninfo() is:

  • NetworkLayout 0.0.1+ master
  • LightGraphs 0.9.5
    Julia Version 0.6.0
    Commit 903644385b* (2017-06-19 13:05 UTC)
    Platform Info:
    OS: Windows (x86_64-w64-mingw32)
    CPU: Intel® Core™ i5-6300U CPU @ 2.40GHz
    WORD_SIZE: 64
    BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
    LAPACK: libopenblas64_
    LIBM: libopenlibm
    LLVM: libLLVM-3.9.1 (ORCJIT, skylake)

Any thoughts or recommendations are appreciated.


#2

Didn’t https://github.com/JuliaGraphs/NetworkLayout.jl/issues/15#issuecomment-319147716 et seq. resolve this?


#3

Yes, this was posted before things were sorted out. Problem solved thanks to the contributors at JuliaGraphs. The rework of the example at NetworkLayout.jl git that worked is as below.

using LightGraphs
using GeometryTypes
using NetworkLayout:SFDP
using GraphPlot
using GeometryTypes

g = WheelGraph(10)
a = adjacency_matrix(g) # generates a sparse adjacency matrix
network = SFDP.layout(a,Point2f0,tol=0.1,C=1,K=1,iterations=10) # generate 2D layout

Note that GraphPlot is included. ‘gplot(g)’ will return the correct visualization of the WheelGraph. I’ve not had luck plotting ‘network’ in a similar fashion but haven’t read the docs yet so … :slight_smile:


#4

So unless you’re going to be writing your own plotting/vis library, I’m not sure why you would want to use NetworkLayout directly. It should suffice to use

using LightGraphs, GraphPlot
gplot(WheelGraph(10))

As far as “correct visualization”, note that Tikz and other visualization packages will lay out the vertices differently - see here for a WheelGraph example.


#5

Actually what I want to do is go from an adjacency matrix to a visualization of the graph it represents. NetworkLayout seemed to fit. As for ‘correct’ I just meant that it matched what the example said it should produce.