r - Identify important connecting node in a network -


i have list of bus stops , number of buses running between 2 bus stops.the data looks given below snap shot.

bus stop    bus stop    no of buses 1   3   10 2   4   23 3   9   4 4   3   34 5   2   1 6   4   3 7   1   543 8   5   5 9   2   2 10  5   1 

i need identify important bus stops connect maximum bus routes.

how can in r.

i tried using arules package not identify important bus stop. there other package in r can me solve problem.

it seems me can use graph solve problem.

import data:

dat <- read.table(text="       number 1   3   10 2   4   23 3   9   4 4   3   34 5   2   1 6   4   3 7   1   543 8   5   5 9   2   2 10  5   1", header=true) 

convert graph, using package igraph , plot

library(igraph) p <- graph.data.frame(dat, directed=false) set.seed(42) plot.igraph(p, edge.width=log1p(e(p)$number)) 

enter image description here

it quite apparent edges 2, 3, 4, , 5 have 3 routes each. can establish using function neighbors():

x <- sapply(v(p), function(i)length(neighbors(p, i)), use.names = true) x ## [1] 2 3 3 3 3 1 1 1 2 1  which(x == max(x)) ## [1] 2 3 4 5 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -