Search code examples
rattrigraphedges

R igraph add.edges() with attributes


Assign during add.edges() an attribute, like width:

g <- add.edges(g,c(from,to), attr= width <- 1 ) 

Error message:
please supply names for attributes

Solution

  • You need to assign it a named list:

    g <- graph.adjacency(matrix(0,2,2))
    g <- add.edges(g,c(1,2),attr=list(width=10))
    

    With the code you used you assign 1 to a variable width and then assign the value of width, i.e. 1, to the argument attr.