I have a data.frame
df = data.frame(a=LETTERS[1:5],b=LETTERS[3:7],w=rnorm(5))
and am trying yo put it into igraph for network analysis. When I try
g2 = add.edges(graph.empty(5), t(as.character(df[,1:2])), weight=df[,3])
Error in as.igraph.vs(graph, edges) : Invalid vertex name(s)
I would like to be able to work with the vertices as their names, and not a numeric conversion of the factor. Eventually, I would like to do a further shortest_path and alternative_path analysis.
I am new to igraph
, and have not been able to find a solution thus far.