Search code examples
rsocial-networkingigraphbipartite

Visualizing collaboration network structure with existing R applications/packages


I am trying to visualize a relational data structure of "joint venture" (i.e., firms collaborate with others in products). For example, firm i may be involved in joint venture A with firm j, yet firm i also participates in joint venture B with firm j and firm k, etc., so both firm i, j, k all share some sort of co-membership relations ({i, j}, {i, j, k}), but the strength of collaboration between firm {i, j} is stronger than that of firm {i, k} as firm i and j collaborate in more joint venture.

I would to visualize this in those iconic network graphs but emphasize the strength of relationship that varies between different dyads (firms). A relevant example that came to my mind is Mark Newman's co-authorship studies in PNAS (Newman 2004), in Fig. 6 each pair of nodes (i.e., authors) are connected by edges of different thickness, representing the strength of co-authorship intensity between each pair of authors (i.e., number of collaborative works between the two), like the picture shown below:

From Newman (2004) I have checked out a number of previous posts (such as this one) pertaining to R's igraph and bipartite packages, but do not think bipartite network and its application fit my purpose here.

I am wondering (1) if there are any existing R packages/applications out there that will help to visualize the strength of connectedness between each nodes in a network, and (2) how should the structure of this type of data look like? (using 'firm', 'project' as columns or rows?)

Thank you.


Solution

  • As @R.B noted, you may use the visNetwork library. The code with invented data may look like this:

    library(igraph)
    library(visNetwork)
    
    set.seed(98765)   # for reproducibility
    ### generate some data, 
    ### nodes are entitities: letters represent contributors
    nodes <- data.frame(id = 1:11, 
                        label = LETTERS[1:11],  # name of node
                        title = LETTERS[1:11])  # optional tooltip
    ### edges represent relations 
    edges <- data.frame(
      from = sample(1:11, 50, replace = TRUE),
      to =  sample(1:11, 50, replace = TRUE),
      arrows = "",
      width = c(rep(1, 20), rep(4, 20), rep(6,6), rep(10, 3), 15)  ## weights
    )
    
    
    visNetwork(nodes, edges, width = "100%") %>%
      visIgraphLayout(layout = "layout_in_circle") %>%
      visNodes(size = 25) %>%
      visOptions(highlightNearest = list(enabled = F, hover = T) )
    

    This generates the following plot (interactive in html)

    enter image description here

    Please let me know whether this is what you want.