igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] question about edge weights


From: Tamás Nepusz
Subject: Re: [igraph] question about edge weights
Date: Mon, 16 Jul 2012 22:24:15 +0200

> The nodes are the first two columns (ID and var). These represent survey 
> respondents and their contacts.

In this case, take a look at the graph.data.frame function, which creates a 
graph out of a data frame directly:

> test <- data.frame(id=23002:23007, var="Chief", value=c(4,4,3,3,3,2))
> g <- graph.data.frame(test)

The created graph will have the names in the id and var columns as the vertex 
names (see V(g)$name); the value column is assigned to an edge attribute named 
"value":

> E(g)$value
[1] 4 4 3 3 3 2

To reassign this to an edge attribute named "weight":

> E(g)$weight <- E(g)$value

Best,
T.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]