1.0 Importing Libraries

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

for(p in packages){library
  if(!require(p, character.only = T)){
    install.packages(p)
  }
  library(p, character.only = T)
}

2.0 Data Wrangling

2.1 Reading CSV files

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

2.2 Wrangling the Data & Attributes

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()

2.3 Creating the Network objects via tidygraph

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

2.4 Original Output

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  

Task 1: Static Organisation Graph

  1. Improve the code chunk used to create the organisation network graph by using the latest functions provided in ggraph2.0.
  2. Identify three aspects of the graph visualisation in Section 6.1 that can be improved.
  3. Provide the sketch of your alternative design.
  4. Using appropriate ggraph functions, plot the alternative design.

Task 1(a)

Because of the newly implemented functions given in ggraph2.0, Tidygraph is now part of the ggraph, hence we do not need to create new variables for centrality closness and centrality between fuctions. Thus we can just include the functions in the asthetic parememters within geom_node_point() function. This helps to reduce the number of lines written therefore, less trouble.

ggraph(GAStech_graph, layout="nicely") + 
  geom_edge_link() +
  geom_node_point(aes(size=centrality_betweenness(),colour=centrality_closeness()))

Task 1(b)

  1. Colour of the nodes
  • The colour of the nodes ranges from dark blue to light blue. The darker the colour, the more it mergers with the the edges as the colour is too similar, I suggest changing the background colour or the colour of both the node and edges to make the plot more visable.
  • The colour of the node should be changed to blue-red-yellow scale.
  1. Labelling of the nodes
  • The nodes are not labelled, because this is a static view page, we do not know what each node is represented by. Hence I would suggest labelling each node to help ensure that the readers or user can understand what is being presented. Therefore labelling of each node is important
  1. Edges are too clustered and the overlaps makes it really hard to see
  • The lines of the edges are too bolded hence it overlapses with other edges hence it makes the graph less visable. To resolve this problem we should make the lines thinner.
  • The second solution is also to make this graph interactive hence users are able to manipulate the graph zoom in and out to clear see the information presented.
  • This graph shows the overview of teh company, I would suggest breaking them down to individual departments to get a better understanding too.
  1. Colour of the edges does not go well with the node
  • I feel that changing the colours of the edges will help with the visualisation. If the colour was changed to grey, it would help to make the graph easily readable.

Task 1(c)

Task 1(d)

ggraph(GAStech_graph, layout="nicely") + 
  geom_edge_link(colour="darkgrey") +
  geom_node_point(aes(size=centrality_betweenness(),colour=centrality_closeness())) +
  scale_colour_gradient(low="yellow",high="blue") +
  geom_node_text(aes(label=label), repel=TRUE, size =2.5,colour="black") +
  th_foreground(foreground = "grey80",  border = TRUE) 

ggraph(GAStech_graph, layout="kk") + 
  geom_edge_link(colour="darkgrey") +
  geom_node_point(aes(size=centrality_betweenness(),colour=centrality_closeness())) +
  scale_colour_gradient(low="yellow",high="blue") +
  geom_node_text(aes(label=label), repel=TRUE, size =2.5,colour="black") +
  facet_nodes(~Department,scale="free") +
  th_foreground(foreground = "grey80",  border = TRUE)

Task 2: Interactive Organisation Graph

  1. Improve the design of the graph by incorporating the following interactivity: * When a name is selected from the drop-down list, the corresponding node will not only be highlighted but also will be labelled. Furthermore, all the linked nodes of the selected node will also be labelled too. * When a node of the interactive graph is selected, the node will not only be highlighted but also will be labelled. Furthermore, all the linked nodes of the selected node will be labelled as well.
  2. Identify three aspects of the graph visualisation in Section 7.4 that can be improved.
  3. Provide the sketch of your alternative design.
  4. Using appropriate visNetwork functions, plot the alternative design.

Data Preperation

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)

Task 2(a)

GAStech_nodes <- GAStech_nodes %>%
  mutate(font.size = 55)

visNetwork(GAStech_nodes, GAStech_edges_aggregated) %>%
  visIgraphLayout(layout = "layout_with_fr") %>%
  visOptions(highlightNearest = list(enabled= TRUE, labelOnly = FALSE), nodesIdSelection = TRUE)

Task 2(b)

  1. No Legend
  • Without the labelling of the legend we are unable to tell what the colour represents
  • Adding legend and description would help resolve the problem
  1. One Dimension Analysis
  • Users are analyse the graph via User ID, we could add an extra dimension such as the department
  1. Navigation Issues
  • The graph might be hard to navigate, hence adding navigational button would help with the user friendliness.

ask 2(c)

Task 2(d)

GAStech_nodes <- GAStech_nodes %>%
  mutate(font.size = 55)

p <- visNetwork(GAStech_nodes, GAStech_edges_aggregated, height = "700px", width = "100%") %>%
  visLegend(position = "right", main = "Department", zoom = FALSE) %>% 
  visIgraphLayout(layout = "layout_with_fr") %>%
  visOptions(selectedBy = list(variable = "group"), highlightNearest = list(enabled= TRUE, labelOnly = FALSE), nodesIdSelection = list(enabled = TRUE))
  

visInteraction(p,dragNodes = TRUE,navigationButtons = T)