1. Network visualization
You may have seen node-link diagrams involving more than a hundred thousand nodes.
2. Irrational vs. Rational visualizations
They purport to show a visual representation of the network, but in reality just show a hairball. In this section, we are going to look at alternate ways of visualizing network data that are much more rational.
3. Visualizing networks
I'm going to introduce to you three different types of network visualizations. The first is visualizing a network using a Matrix Plot. The second is what we call an "Arc Plot", and the third is called "Circos Plot".
4. Visualizing networks
Let's start first with a Matrix Plot.
5. Matrix plot
In a Matrix Plot, nodes are the rows and columns of a matrix, and cells are filled in according to whether an edge exists between the pairs of nodes. On these slides, the left matrix is the matrix plot of the graph on the right. In an undirected graph,
6. Matrix plot
the matrix is symmetrical around the diagonal, which I've highlighted in gray. I've also highlighted
7. Matrix plot
one edge in the toy graph, edge (A, B), which is equivalent to the edge (B, A).Likewise for edge (A, C),
8. Matrix plot
it is equivalent to the edge (C, A), because there's no directionality associated with it.
9. Directed matrices
If the graph were a directed graph, then the matrix representation is not necessarily going to be symmetrical. In this example, we have a bidirectional edge between A and C, but only an edge from A to B and not from B to A. Thus, we will have (A, B) filled in, but not (B, A). If the nodes are ordered along the rows and columns such that neighbors are listed close to one another, then a matrix plot can be used to visualize clusters, or communities, of nodes.
10. Visualizing networks
Let's now move on to Arc plots. An Arc Plot
11. Arc plot
is a transformation of the node-link diagram layout, in which nodes are ordered along one axis of the plot, and edges are drawn using circular arcs from one node to another. If the nodes are ordered according to some some sortable rule, for example, age in a social network of users, or otherwise grouped together, for example, by geographic location in map for a transportation network, then it will be possible to visualize the relationship between connectivity and the sorted (or grouped) property. Arc plots are a good starting point for visualizing a network, as it forms the basis of the later plots that we'll take a look at.
12. Visualizing networks
Let's now move on to Circos plots. A Circos plot
13. Circos plot
is a transformation of the Arc plot, such that the
14. Circos plot
two ends of the Arc plot are joined together into a circle. Circos plots were originally designed for use in genomics, and you can think of them as an aesthetic and compact alternative to Arc plots. You will be using a plotting utility that I developed
15. nxviz API
called nxviz. Here's how to use it. Suppose we had a Graph G in which we added nodes and edges. To visualize it using nxviz, we first need to import nxviz as nv, and import matplotlib to make sure that we can show the plot later. Next, we instantiate a new nv-dot-arc plot, and pass in a graph G. We can also order nodes by the values keyed on some "key". Finally, we can call the draw function, and as always, we also call plt-dot-show. The code example here shows you how to create an Arc plot using nxviz, and you'll get a chance to play around with the other plots in the exercises.
16. Let's practice!
Alright! Let's get hacking!