Home

Awesome

NetworkViz

Linux, OSX : Build Status

Windows : Build status

A Julia module to render graphs in 3D using ThreeJS tightly coupled with LightGraphs.

Install

In a Julia REPL, run:

Pkg.add("NetworkViz")

Graph Algorithms Used

Graph Primitives

NodeProperty

The NodeProperty type stores the properties of each node in the graph. It stores the following properties :

EdgeProperty

The EdgeProperty type stores the properties of each edge in the graph. It stores the following properties :

Visualizing Graphs

The drawGraph function can be used to draw the graphs in 2D or 3D with nodes having different colors. It can accept LightGraphs.Graph and LightGraphs.Digraph types. drawGraph can be used to draw graphs from adjacency matrices also. The function accepts an additional kwargs node::NodeProperty, edge::EdgeProperty, and z. If z=1, it draws a 3D graph. If z=0, a 2D visualization of the graph is drawn. node and edge determines the properties of nodes and edges respectively.

Usage :

g = CompleteGraph(10)
c = Color[parse(Colorant,"#00004d") for i in 1:nv(g)]
n = NodeProperty(c,0.2,0)
e = EdgeProperty("#ff3333",1)
drawGraph(g,node=n,edge=e,z=1) #Draw using a Graph object (3D).

am = full(adjacency_matrix(g))
drawGraph(am,node=n,edge=e,z=0) #Draw using an adjacency matrix (2D).

dgraph = bfs_tree(g,1)
drawGraph(dgraph,z=1) #Draw a Digraph.

Utility Functions

Examples

#Run this code in Escher
using NetworkViz
using LightGraphs
main(window) = begin
  push!(window.assets, "widgets")
  push!(window.assets,("ThreeJS","threejs"))
  g = CompleteGraph(10)
  drawGraph(g)
end

The above code produces the following output :

alt tag

Here is another example with a code-mirror where functions can be typed in. Depending on the LightGraphs function used, 2D as well as 3D graphs are drawn. You can see the working demo here.

You can find many other examples in the examples/ folder.

Acknowledgement

IainNZ for the original Spring-Embedder code. (Taken from GraphLayout.jl).