Skip to content
Prev 303427 / 398503 Next

per-vertex statistics of edge weights

I have a graph with edge and vertex weights, stored in two data frames:

--8<---------------cut here---------------start------------->8---
vertices <- data.frame(vertex=c("a","b","c","d"),weight=c(1,2,1,3))
edges <- data.frame(src=c("a","a","b","c","d"),dst=c("b","c","d","d","a"),
  weight=c(1,2,1,3,1))
--8<---------------cut here---------------end--------------->8---

I can create a graph from this data:

--8<---------------cut here---------------start------------->8---
library(igraph)
graph <- graph.data.frame(edges, vertices = vertices, directed=FALSE)
--8<---------------cut here---------------end--------------->8---

what I want is to compute some edge weight stats (mean/median/max/min/)
for each vertex.

I guess I can do something like

--8<---------------cut here---------------start------------->8---
Note: no visible global function definition for 'inc' 
[1] 1.333333 1.000000 2.500000 1.666667
--8<---------------cut here---------------end--------------->8---

but I was wondering if this is TRT, given the correct answer with a
scary note.

Thanks!