# Graph Visualization NetworkLayout Error: 'layout' not defined

**URL:** <https://discourse.julialang.org/t/graph-visualization-networklayout-error-layout-not-defined/5154>\
**Category:** Visualization\
**Tags:** lightgraphs\
**Created:** [July 31, 2017, 6:21pm UTC](https://discourse.julialang.org/t/graph-visualization-networklayout-error-layout-not-defined/5154 "2017-07-31T18:21:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeB2012](https://avatars.discourse-cdn.com/v4/letter/m/858c86/32.png) [@MikeB2012](https://discourse.julialang.org/u/MikeB2012)\
**Post date:** [July 31, 2017, 6:21pm UTC](https://discourse.julialang.org/t/graph-visualization-networklayout-error-layout-not-defined/5154/1 "2017-07-31T18:21:41Z")

</div>

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(R) 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.

---

<div class="post-metadata">

**Author:** ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Post date:** [July 31, 2017, 8:31pm UTC](https://discourse.julialang.org/t/graph-visualization-networklayout-error-layout-not-defined/5154/2 "2017-07-31T20:31:07Z")

</div>

Didn’t [https://github.com/JuliaGraphs/NetworkLayout.jl/issues/15#issuecomment-319147716](https://github.com/JuliaGraphs/NetworkLayout.jl/issues/15#issuecomment-319147716) _et seq._ resolve this?

---

<div class="post-metadata">

**Author:** ![MikeB2012](https://avatars.discourse-cdn.com/v4/letter/m/858c86/32.png) [@MikeB2012](https://discourse.julialang.org/u/MikeB2012)\
**Post date:** [August 1, 2017, 3:43am UTC](https://discourse.julialang.org/t/graph-visualization-networklayout-error-layout-not-defined/5154/3 "2017-08-01T03:43:33Z")

</div>

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 … 🙂

---

<div class="post-metadata">

**Author:** ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Post date:** [August 1, 2017, 4:49pm UTC](https://discourse.julialang.org/t/graph-visualization-networklayout-error-layout-not-defined/5154/4 "2017-08-01T16:49:28Z")

</div>

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

```julia
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](http://juliagraphs.github.io/LightGraphs.jl/latest/integration.html) for a WheelGraph example.

---

<div class="post-metadata">

**Author:** ![MikeB2012](https://avatars.discourse-cdn.com/v4/letter/m/858c86/32.png) [@MikeB2012](https://discourse.julialang.org/u/MikeB2012)\
**Post date:** [August 2, 2017, 2:34am UTC](https://discourse.julialang.org/t/graph-visualization-networklayout-error-layout-not-defined/5154/5 "2017-08-02T02:34:29Z")

</div>

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.
