I have a transport network I have represented in igraph, and for each station I have a number of boardings. I'm wondering how I can accumulate the boardings at each node from the end of the graph into the centre (Central Station)?
library(tidyverse)
library(igraph)
library(ggraph)
rm(list=ls())
nodes <- tribble(
~name, ~netboardings,
"Station A", 10,
"Station B", 20,
"Station C", 30,
"Station D", 10,
"Central Station", 20,
"Station F", 30,
"Station G", 50,
"Station H", 60,
"Station I", 80
)
ties <- tribble(
~from, ~to,
"Station C", "Station B",
"Station B", "Station A",
"Station A", "Station D",
"Station G", "Station A",
"Station H", "Station I",
"Station I", "Station F",
"Station F", "Station D",
"Station D", "Central Station"
)
g <-
ties %>%
graph_from_data_frame(directed = TRUE, vertices = nodes)
g %>%
ggraph() +
geom_node_point(aes(size=netboardings),color="blue") +
geom_edge_link(arrow = arrow(length = unit(2, 'mm'),type = "closed")) +
geom_node_label(aes(label=name),repel = TRUE)
I found this data.tree solution, but would like to do it in igraph.
Many thanks,