Graph with thousands of observations does not load

My code is below, I have used all graphing visualisation libraries and noticed for observations eg: 100000 + they do not load a graph at all

A 30000 observation took more than 20 minutes to load, how can I expedite the process, my server has 32gb ram and 16 cpus so I don't think that's an issue although I am not sure if my code is parallelised?

to <- df %>%
distinct(to) %>%
rename(label = to)

from <- df %>%
  distinct(from) %>%
  rename(label = from)

nodes <- full_join(to, from, by = "label")

nodes <- nodes %>% rowid_to_column("id")

per_route <- df %>%  
  group_by(from, to) %>%
  summarise(weight = n()) %>% 
  ungroup()

edges <- per_route %>% 
  left_join(nodes, by = c("to" = "label")) %>% 
  rename(to = id)

edges <- edges %>% 
  left_join(nodes, by = c("from" = "label")) %>% 
  rename(from = id)

edges <- select(edges, from, to, weight)


visNetwork(nodes, edges) %>%
  visPhysics(stabilization = FALSE) %>%
  visIgraphLayout() %>%
  visEdges(arrows = "from")`

with graph

 routes_tidy <- tbl_graph(nodes = nodes, edges = edges, directed = TRUE)
 routes_igraph_tidy <- as_tbl_graph(routes_igraph)
 
 routes_tidy %>% 
   activate(edges) %>% 
   arrange(desc(weight))
 ggraph(routes_tidy) + geom_edge_link() + geom_node_point() + theme_graph()

ggraph(routes_tidy, layout = "graphopt") +
   geom_node_point() +
  geom_edge_link(aes(width = weight), alpha = 0.8) +
 scale_edge_width(range = c(0.2, 2)) +
  geom_node_text(aes(label = label), repel = TRUE) +
   labs(edge_width = "Letters") +
 theme_graph()

Do you have a toy df to share? I've done graphs of that size on an 4GB/4core Mac. I'd be surprised if the problem was intrinsic to N.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.