LIS 4317 Data Visualization: Networks

LIS 4317 Data Visualization: Networks
Figure 1: A network of 26 entities.

Network analysis is a very useful tool for describing complex relationships between many entities. To explore the concepts of network analysis I created 26 entities and randomly generated connections between them. To do this I wrote an R script which you can find on my GitHub here, or follow the link at the bottom of this post.

To map a network, one first needs to create an edge list of connections that exist or a matrix of all possible edges. An edge list is simply a table with one column describing each connection or edge, and then another column with a tally for how often the connection occurs. I used a matrix to create the above visualization, which has the rows and columns for each connection. To generate this edge matrix I used the following code.

#Build a matrix, 0 = no connection, higher count, stronger connection
my_net_matrix <- matrix(round(runif(676, min = 0, max = 0.53)), nrow = 26)
Code language: R (r)

Here I use a uniform distribution that randomly generates a number between 0 and 0.53, and then rounds that number to either 0, or 1. I then put into a square matrix with 26 rows. This creates a sparse matrix, it is mostly filled with 0’s. I purposefully did that so that more interesting structures would appear in the network and would be more representative of a real network.

Once the edge matrix is generated, making the network is fairly simple. The following code first turns the matrix into a network object, then gives each node a name, here I give them letters. Then plot the network with ggnet2.

#Convert to Network
my_net <- network(my_net_matrix, directed = TRUE)

#Give names to nodes
network.vertex.names(my_net) = letters[1:26]

#Plot with ggnet2
ggnet2(my_net, label = TRUE)
Code language: R (r)

This code produce the output in Figure 1.

In Figure 1 there are a couple of interesting things to see. First is the presence of two clusters. There is one on the right side and another on the left. These two clusters are bridged by Entity S. When dealing with clusters, an interesting point of analysis is finding how the clusters are connected. There are also clusters that are not connected to the rest of the network as is the case of entity L and J.

With network analysis one can discover new and interesting patterns in complex systems, such as a social network. From this analysis new questions can be formed, such as why Entity S in Figure 1 is a bridge between the two clusters. Looking into equations such as that may reveal new insights into how the overall system works.

Links:

GitHub: https://github.com/SimonLiles/LIS4317DataVisualization/blob/main/LIS4317Mod12.R