# Drawing a large network using Julia

**URL:** <https://discourse.julialang.org/t/drawing-a-large-network-using-julia/85793>\
**Category:** General Usage\
**Tags:** question, visualization\
**Created:** [August 15, 2022, 8:44pm UTC](https://discourse.julialang.org/t/drawing-a-large-network-using-julia/85793 "2022-08-15T20:44:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [August 15, 2022, 8:44pm UTC](https://discourse.julialang.org/t/drawing-a-large-network-using-julia/85793/1 "2022-08-15T20:44:04Z")

</div>

Is there a way to draw a network (with nods and edges) in Julia? In particular, I have (say) 5 nodes of type 1 and 10 of type 2. Directed edges exist from each type 1 node to type 2 node, and I would probably show nodes of each type using different colors. For now, they can be located randomly on a 2D plane. Can a code be written using loops or something similar that would save me time to do this in PowerPoint etc.? Also, with a large number of nodes, I would want to automate it. Maybe there is a package that does this already. Any help is appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [August 15, 2022, 10:23pm UTC](https://discourse.julialang.org/t/drawing-a-large-network-using-julia/85793/2 "2022-08-15T22:23:15Z")

</div>

[Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) is a good package for constructing graphs. You can build them in various ways, by adding vertices and edges, from matrices, etc.

For drawing graphs, there are a number of packages that display graphs made with Graphs.jl:

- [TikzGraphs.jl](https://github.com/sisl/TikzGraphs.jl): backend: Tikz/Latex
- [GraphPlot.jl](https://juliagraphs.org/GraphPlot.jl/): backend: Compose.jl
- [SGtSNEpi.jl](https://github.com/fcdimitr/SGtSNEpi.jl): backend: Makie.jl
- [GraphRecipes.jl](https://github.com/JuliaPlots/GraphRecipes.jl): backend: Plots.jl
- [GraphMakie.jl](https://github.com/JuliaPlots/GraphMakie.jl): backend: Makie.jl
- [Karnak.jl](https://github.com/cormullion/Karnak.jl): backend: Luxor.jl

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [August 15, 2022, 11:51pm UTC](https://discourse.julialang.org/t/drawing-a-large-network-using-julia/85793/3 "2022-08-15T23:51:21Z")

</div>

It might make sense to just export the network to one of the usual graph formats, like DOT or GML or GraphML (different from GML).

For example, DOT syntax originated with the venerable Unix (and crossplatform, nowadays) graph drawing tool: GraphViz. GraphViz is useful for 2D noninteractive drawing of graphs:

> **[Graphviz](https://graphviz.org)**
>
> Graph Visualization Software

On the other hand, if you’re dealing with really large graphs you should check out the Graphia program, it accepts most of the standard graph formats (including the ones mentioned above), and it amazingly successfully visualizes _huge_ networks in 3D, with a GUI and various options for customization and graph transformation. Interactively drawn networks with millions of nodes; with panning, zooming, etc. Graphia’s homepage and Github:

> **[Graphia](https://graphia.app)**
>
> Visualisation tool for the creation and analysis of large graphs.

> **[GitHub - graphia-app/graphia: A visualisation tool for the creation and...](https://github.com/graphia-app/graphia)**
>
> A visualisation tool for the creation and analysis of graphs - GitHub - graphia-app/graphia: A visualisation tool for the creation and analysis of graphs

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [August 16, 2022, 1:38pm UTC](https://discourse.julialang.org/t/drawing-a-large-network-using-julia/85793/4 "2022-08-16T13:38:44Z")

</div>

Thanks. I will take a look into these. 🙂

---

<div class="post-metadata">

**Author:** ![math\_opt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/math_opt/32/25317_2.png) [@math\_opt](https://discourse.julialang.org/u/math_opt)\
**Post date:** [August 16, 2022, 1:39pm UTC](https://discourse.julialang.org/t/drawing-a-large-network-using-julia/85793/5 "2022-08-16T13:39:39Z")

</div>

These are some amazing references. I will see which one works the best for me. Thanks a lot! 🙂

---

<div class="post-metadata">

**Author:** ![tstrey](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tstrey](https://discourse.julialang.org/u/tstrey)\
**Post date:** [July 7, 2023, 5:09pm UTC](https://discourse.julialang.org/t/drawing-a-large-network-using-julia/85793/6 "2023-07-07T17:09:49Z")

</div>

@nsajko Is there an easy way to turn a matrix or graph in Julia into something useable by Graphia?

---

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [July 7, 2023, 6:13pm UTC](https://discourse.julialang.org/t/drawing-a-large-network-using-julia/85793/7 "2023-07-07T18:13:26Z")

</div>

GML is nice and simple to generate, here’s an example directed graph with two vertices and one edge:

```plaintext
graph [
  directed 1
  
  node [
    id 1
    label "A"
  ]
  node [
    id 2
    label "B"
  ]

  edge [
    source 1
    target 2
  ]
]

```

What format is your data in?
