1 Task 1: ggraph

1.1 Revised code chunks

packages = c('igraph', 'tidygraph', 'ggraph', 'visNetwork', 'lubridate', 'tidyverse','deldir','ggrepel')

for(p in packages){library
  if(!require(p, character.only = T)){
    install.packages(p)
  }
  library(p, character.only = T)
}
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()
GAStech_edges_aggregated
GAStech_graph <- tbl_graph(nodes = GAStech_nodes, edges = GAStech_edges_aggregated, directed = TRUE)
g <- ggraph(GAStech_graph,
            layout = 'nicely') + 
  geom_edge_link(aes()) + 
  geom_node_point(aes(colour = centrality_closeness(),
                      size= centrality_betweenness()))
g + theme_graph()

1.2 Areas of improvement

  • The color of centrality closeness is hard to distinct from black color
  • There is no information about the deapartment each node belongs to
  • There is no label to show who is that node

1.3 Alternative design

Alternate design for the ggraph plot

Alternate design for the ggraph plot

1.4 Alternative graph

g + geom_node_voronoi(aes(fill = Department), max.radius = 0.2, colour = 'white',alpha=0.5)+ 
  geom_edge_link(aes(),edge_colour="antiquewhite4",edge_alpha=0.5) + 
  geom_node_point(aes(colour = centrality_closeness(),
                      size= centrality_betweenness()),
                  alpha=0.7) +
  geom_node_text(aes(label = label,size=30), repel = TRUE)+
  guides(fill=guide_legend(ncol = 2),size=guide_legend(ncol = 2)) +
  theme(legend.position="right",
        legend.title = element_text(size = 10),
        legend.text = element_text(size = 8)) +
  labs(title="GAStech email network",colour="Closeness Centrality",size="Betweenness Centrality")

2 Task 2: visnetwork

2.1 Improve the graph design

GAStech_edges_aggregated <- 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 <- GAStech_nodes %>%
  rename(group = Department)
visNetwork(GAStech_nodes, GAStech_edges_aggregated,width = "100%") %>%
  visNodes(label =NULL,font = list(size=50)) %>%
  visIgraphLayout(layout = "layout_with_fr") %>%
  visOptions(
    highlightNearest= list(enabled = TRUE,
                           degree = 1,
                           hover = FALSE,
                           labelOnly = FALSE), 
    nodesIdSelection = list(enabled = TRUE)) %>%
  visLayout(randomSeed = 100)

2.2 Areas of improvement

  • The edge did not visualize the weights
  • The edge color is too corlorful that make the graph distracted/ hard to see sometimes
  • The graph can be zoom in/out accidentally so most of the time it is not at the optimal size for viewer to see
  • There is no legends and title
  • There is no direction for the edge arrow

2.3 Alternative design

Alternate design for the visNetwork plot

Alternate design for the visNetwork plot

2.4 Alternative graph

colnames(GAStech_edges_aggregated)[ncol(GAStech_edges_aggregated)] <- "value"
visNetwork(GAStech_nodes, GAStech_edges_aggregated,
           main = "GAStech email network") %>%
  visNodes(font = list(size=55,color = "black")) %>%
  visIgraphLayout(layout = "layout_with_fr") %>%
  visEdges(arrows = "to",color =list(background="azure3", highlight= "red")) %>%
  visOptions(
    highlightNearest= list(enabled = TRUE,
                           degree = 1,
                           hover = FALSE,
                           labelOnly = FALSE), 
    nodesIdSelection = list(enabled = TRUE,
                             main = "Select by name:")) %>%
  visLayout(randomSeed = 100) %>%
  visInteraction(dragView=FALSE,zoomView = FALSE,navigationButtons = TRUE) %>%
  visLegend(main = "Department",stepY = 60,zoom=FALSE) %>%
  addFontAwesome()