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)
}
GAStech_nodes <- read_csv("/Users/kelvincsw/Google Drive/SMU Stuffs/Sem 3.1/VA/Week 11/data/GAStech_email_node.csv")
GAStech_edges <- read_csv("/Users/kelvincsw/Google Drive/SMU Stuffs/Sem 3.1/VA/Week 11/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_graph <- tbl_graph(nodes = GAStech_nodes, edges = GAStech_edges_aggregated, directed = TRUE)
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()
ggraph(GAStech_graph, layout="nicely") +
geom_edge_link() +
geom_node_point(aes(size=centrality_betweenness(),colour=centrality_closeness()))
1. Links Color The links in the original graph is black and it creates too much distraction in the graph. It is also harder for users to determine the lines. Hence, it should be replaced with a lighter color like light grey.
2. Node Color
The color of the nodes is using a sequential color scheme and it is hard to users to determine the centrality closeness. Hence, a diverging color scheme can be adopted to better distinguish them.
3. Node Label
The node should be labelled to allow the user to visualise which employee have high centrality betweenness and closeness.
ggraph(GAStech_graph, layout="nicely") +
geom_edge_link(colour="#BBBBBB") +
geom_node_point(aes(size=centrality_betweenness(),colour=centrality_closeness())) +
geom_node_text(aes(label=label), repel=TRUE, size =2.5,colour="black")+
scale_colour_gradient(low="#ED4534",high="#74FF9C")
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) %>%
rename(title = Title)
visNetwork(GAStech_nodes, GAStech_edges_aggregated) %>%
visIgraphLayout(layout = "layout_with_fr") %>%
visOptions(highlightNearest = TRUE, nodesIdSelection = TRUE)
GAStech_nodes <- GAStech_nodes %>% mutate(font.size = 50)
visNetwork(GAStech_nodes, GAStech_edges_aggregated) %>%
visIgraphLayout(layout = "layout_with_fr") %>%
visOptions(nodesIdSelection = TRUE, highlightNearest = list(enabled= TRUE, labelOnly = FALSE))
1. Missing Legend
Users do not know what the color coding of each node represents. There should be a legend to display the color code for each department.
2. More filter options
Users are unable to select multiple nodes that belong to the same department. To allow for in-depth analysis for interactions between departments, a new filter can be implemented to group nodes by departments.
3. Lack of navigation control
The controls to zoom in/out, reset view is not clearly defined and new users may face difficulty interacting with the interface. Navigation control buttons can be implemented to allow users to easily navigate the graph.
GAStech_nodes <- GAStech_nodes %>% mutate(font.size = 50)
#Groups had to be manually color coded to reflect to the legend correctly.
visual <- visNetwork(GAStech_nodes, GAStech_edges_aggregated) %>%
visIgraphLayout(layout = "layout_with_fr") %>%
visOptions(selectedBy = list(variable = "group",
style = 'width: 160px; height: 26px;'),
highlightNearest = list(enabled= TRUE,
labelOnly = FALSE),
nodesIdSelection = list(enabled = TRUE,
style = 'width: 175px; height: 26px;')) %>%
visLegend(position = "right", main = "Department") %>%
visGroups(groupname = "Facilities", color = "pink", shadow = list(enabled = TRUE)) %>%
visGroups(groupname = "Executive", color = "lightgreen", shadow = list(enabled = TRUE)) %>%
visGroups(groupname = "Administration", color = "lightblue", shadow = list(enabled = TRUE)) %>%
visGroups(groupname = "Engineering", color = "cyan", shadow = list(enabled = TRUE)) %>%
visGroups(groupname = "Security", color = "yellow", shadow = list(enabled = TRUE)) %>%
visGroups(groupname = "Information Technology", color = "#C681FF", shadow = list(enabled = TRUE))
visInteraction(visual,dragNodes = TRUE,navigationButtons = T)