Interested in making beautiful charts out of social network data? Visualize networks of communities, groups of entities, and glean information from the graphs for further network analysis using R packages igraph and NetworkD3.
The theme for the third week of Research Data and Digital Scholarship Data Jam 2021 was “Visualizing Text and Networks”.
The “Network Visualization with R” workshop was a live-coding session which detailed the following:
Glossary of Network Visualization Terms
Software and Programming Alternatives to Network Visualization with igraph and NetworkD3
Network visualization allows the viewer to understand a lot of information quickly and intuitively about the state of the network at a glance. Social networks have actors with relations between them. Network diagrams (or Graphs) show interconnections betwe
en a set of entities. Each entity is represented by a Node (or Vertice). Connections between nodes are represented by links (or edges).
R Packages commonly used for network visualization include:
Software alternatives for network visualization are:
For the RStudio demonstration, after installing and running igraph package, a variety of graphs were displayed.
# Install igraph library
# Run igraph librarylibrary(igraph)
These included graphs with different number of nodes and edges, directed and undirected graphs, and graphs of different shapes. For example:
# Create a directed graph with 3 nodes 1, 2, and 3
g3d <- graph( edges=c(1,2, 2,3, 3, 1), n=3, directed=T)
A simple graph was developed in the form of visualizing a network of historical roads in Philadelphia where the starting point of a street and the ending point of the street are the source and destination, respectively.
## Interactive Network Graphs## Historic Streets of Philadelphialibrary(networkD3)
# Load data
edges <- read.csv("Historic_Streets.csv")
#IdentifySource and Target Edgessource <- edges["FROM_STREET"]
target <- edges["TO_STREET"]
# Format into network data
simpleNetwork(networkData,nodeColour= "green", zoom=T, height = 300, width = 300,fontSize= 16)
The network of interactions in the book Les Misérables by Victor Hugo was also mapped as a force-directed network graph.
## Network of Interactions in LesMiserablescharacters# Load data
forceNetwork(Links =MisLinks, Nodes =MisNodes,
Source = "source", Target = "target",
Value = "value",opacityNoHover= 0.9, NodeID = "name",
Group = "group", opacity = 0.8, zoom=T)
# Find all links to Valjean
which(MisNodes== "Valjean",arr=TRUE) - 1
## Zachary's Karate Club Networklibrary(igraphdata)
# How many factions are in the karate club?
# How many subcommunities clusters are in the karate club?
It is important to keep in mind the accessibility concerns of network visualizations. For example, overlapping nodes might make the graph seem populated with lower number of nodes. While changing the size and color of nodes might be helpful to discern or distinguish the types of nodes, it might lead to confusion. The 2D graph might be mistaken for occupying 3D space. It is also helpful to use the ColorBrewer2 app to confirm the accessibility features of the colors used in the graph.
Other ways to distinguish nodes, edges, clusters, and networks are as following: