Social network analysis on R – Trying to make an oriented graph with Igraph whith multiple kind of links and only one of them is orented

Summary

The problem lies in creating an oriented graph with multiple types of links using the Igraph package in R, where only one type of link, “Succession“, needs to be oriented and displayed with an arrow. The provided code generates a graph with all desired attributes except for the arrows on the “Succession” links in the final PDF output.

Root Cause

The root cause of the issue is the incorrect assignment of arrow.mode and arrow.size attributes for the edges of type “Succession” in the main graph. Although the code correctly sets these attributes for the subset graph g_succession, it does not properly update these attributes for the corresponding edges in the main graph g.

Why This Happens in Real Systems

This issue occurs due to the complexity of managing multiple types of edges and their attributes in a graph. When dealing with large datasets and various edge types, it’s easy to overlook the proper assignment of attributes, especially when working with subset graphs and updating the main graph accordingly.

Real-World Impact

The inability to correctly display oriented links can lead to misinterpretation of the graph’s meaning, potentially causing incorrect conclusions to be drawn from the analysis. In the context of social network analysis, this could result in a failure to understand the directional relationships between entities, which is crucial for understanding the dynamics of the network.

Example or Code

# Correctly update arrow.mode and arrow.size for "Succession" edges in the main graph
succession_indices <- which(E(g)$type_lien == "Succession")
E(g)$arrow.mode[succession_indices] <- 2
E(g)$arrow.size[succession_indices] <- 0.8

How Senior Engineers Fix It

Senior engineers would identify the issue by carefully reviewing the code and the graph’s behavior. They would:

  • Verify attribute assignments: Check that all attributes, including arrow.mode and arrow.size, are correctly assigned to the edges of the main graph.
  • Use debugging techniques: Utilize R’s built-in debugging tools or print statements to inspect the values of arrow.mode and arrow.size for the “Succession” edges in the main graph.
  • Test with subset graphs: Create subset graphs for each edge type to isolate and test the behavior of the attributes.

Why Juniors Miss It

Junior engineers might miss this issue due to:

  • Lack of experience: Limited familiarity with the Igraph package and its nuances.
  • Overlooking details: Failing to carefully review the code and attribute assignments for each edge type.
  • Insufficient testing: Not thoroughly testing the graph’s behavior with different edge types and attributes.