Environment Setup

Use these codes when you have already installed the list of packages, just launched it for the particular file

p <- c('knitr','tidyverse', 'igraph', 'tidygraph', 'ggraph', 'visNetwork', 'lubridate', 'ggrepel', 'magrittr')
lapply(p, require, character.only = TRUE)

Task 1 - Static Organisation Graph

Data Preparation

GAStech_nodes <- read_csv("data/GAStech_email_node.csv")
GAStech_edges <- read_csv("data/GAStech_email_edge-v2.csv")

GAStech_edges$SentDate  = dmy(GAStech_edges$SentDate)
GAStech_edges$Weekday = wday(GAStech_edges$SentDate, label = TRUE, abbr = FALSE)

GAStech_edges_aggregated <- GAStech_edges %>%
  filter(MainSubject == "Work related") %>%
  group_by(source, target, Weekday) %>%
    summarise(Weight = n()) %>%
  filter(source!=target) %>%
  filter(Weight > 1) %>%
  ungroup()

Network Object Creation and Processing

GAStech_graph <- tbl_graph(nodes = GAStech_nodes, edges = GAStech_edges_aggregated, directed = TRUE)

GAStech_graph %>%
  activate(edges) %>%
  arrange(desc(Weight))

Existing Network Graph

g <- GAStech_graph %>%
  mutate(betweenness_centrality = centrality_betweenness()) %>%
  mutate(closeness_centrality = centrality_closeness()) %>%
  ggraph(layout = "nicely") + 
  geom_edge_link(aes()) +
  geom_node_point(aes(colour = closeness_centrality, size=betweenness_centrality))

g + theme_graph()

3 Key Aspects To Improve On

No. Problems Solutions
1. Unable to differentiate nodes by Departments Distiguish nodes of different departments by color coding
2. Unable to identify the Names of each nodes Use names of each nodes as their label
3. Dark colored edges hinder viewers from picking up the location of the nodes Change the color of edges to a lighter tone color to make nodes more visible and increase node size

Sketch Of Alternative Graph Design

Alternative Network Graph

g <- GAStech_graph %>%
  mutate(betweenness_centrality = centrality_betweenness()) %>%
  mutate(closeness_centrality = centrality_closeness())
  
ggraph(g) + 
  geom_edge_link(colour = "sky blue") +
   geom_node_circle(aes(fill = closeness_centrality, r = log(betweenness_centrality)/100, col = Department), size = 1.4)+
  geom_node_label(aes(label=label), nudge_x = 0.03, repel = TRUE)

Task 2 - Interactive Organization Graph

Data Preparation

GAStech_edges_aggregated_task2 <- GAStech_edges %>%
  left_join(GAStech_nodes, by = c("sourceLabel" = "label")) %>%
  rename(from = id) %>%
  left_join(GAStech_nodes, by = c("targetLabel" = "label")) %>%
  rename(to = id) %>%
  filter(MainSubject == "Work related") %>%
  group_by(from, to) %>%
    summarise(weight = n()) %>%
  filter(from!=to) %>%
  filter(weight > 1) %>%
  ungroup()

GAStech_nodes_task2 <- GAStech_nodes %>%
  rename(group = Department)

Existing Network Graph

visNetwork(GAStech_nodes_task2, GAStech_edges_aggregated_task2) %>%
  visIgraphLayout(layout = "layout_with_fr") %>%
  visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE)

Key Aspects To Improve On

No. Problems Solutions
1. Lack of explanation for color coding Include a legend to link color coding to its assigned department
2. Unable to interpret frequency of communications between nodes Set weightage of edges to the variable - weight (frequency of communications)
3. Unable to filter nodes by departments Include another filter using Department (group)
4. Labels of nodes are filtered when nodes are filtered and hard to read due to overlap with edges Ensure that only labels of selected or linked with 1 degree are displayed and are displayed within the node
5. Unable to determine how well connected are the nodes to others Use the number of connections to set the weightage of the nodes to show level of “connectiveness”

Sketch Of Alternative Graph Design

Node and Edges Customization

GAStech_nodes_task2$shape = "circle"
GAStech_nodes_task2$title <- paste0("<p>Name: ",GAStech_nodes_task2$label,"<br>Job Title: ", GAStech_nodes_task2$Title,"</p>")
GAStech_edges_aggregated_task2$title <- paste0("<p>Connection Freq.: ", GAStech_edges_aggregated_task2$weight ,"</p>")

GAStech_edges_aggregated_task2$label <- GAStech_edges_aggregated_task2$value
GAStech_edges_aggregated_task2 <- rename(GAStech_edges_aggregated_task2, value = weight)

Alternative Network Graph

visNetwork(GAStech_nodes_task2, GAStech_edges_aggregated_task2) %>%
  visIgraphLayout(layout = "layout_with_fr") %>%
  visOptions(selectedBy = "group", highlightNearest = list(enabled = TRUE, degree = list(from = 1, to = 1),hover = TRUE, labelOnly = TRUE), nodesIdSelection = TRUE) %>%
  visLegend() %>%
  visInteraction(navigationButtons = TRUE, multiselect = TRUE, tooltipStyle = 'position: fixed;visibility:hidden;padding: 5px;white-space: nowrap;
 font-family: Arial;font-size: 12px;font-color: black;background-color: #87CEEB;') %>%
  visNodes(label="label") %>%
  visEdges(arrows = list(to = list(enabled=TRUE), from = list(enabled=TRUE)))