Representing graph data
The theoretical aspects of networks are important, but in order to be able to apply these ideas to a real-world problem, we have to first transform our data into a format that a network analysis program can understand. In this section, we will discover the common formats for representing data in a network-friendly way.
Adjacency matrix
An adjacency matrix is a convenient way to represent graph data. To construct an adjacency matrix for an undirected, unweighted graph, we can create a grid that has all the nodes listed across the top as columns, and also down the side of the grid as rows. Then we use a 1 or 0 to indicate whether there is a link between those two nodes. Consider the unweighted, undirected graph shown in Figure 12:
The adjacency matrix for the Figure 12 graph can be written like this:
A B C D E F A 0 1 1 1 0 0 B 1 0 1 1 0 0 C 1 1 0 0 1 1 D 1 1 0 0 0 0 E 0 0 1 0 0 0 F 0 0 1 0 0 0
A few things jump out right...