[Top][All Lists]

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

Re: [igraph] A very elementary question

From: Tamás Nepusz
Subject: Re: [igraph] A very elementary question
Date: Sat, 8 Jan 2011 22:29:26 +0100

Let's generate a random graph using preferential attachment as an example:

g <- barabasi.game(25, m=2)

Let's add some weights just for the sake of our example:

E(g)$weight <- seq(1, ecount(g))

Also, let's add some node labels:

V(g)$label <- LETTERS[1:vcount(g)]

Now, we have to assign the edge weights as the "label" attribute to the edges:

E(g)$label <- E(g)$weight

Finally, we can plot the graph:


It's no different if you imported your graph from Pajek; use 
list.vertex.attributes() and list.edge.attributes() to find the names of your 
vertex/edge attributes and decide which one should be assigned to the "label" 
attributes of the vertices/edges. If you want to vary the edge width instead of 
using edge labels, assign a numeric vector to the "weight" attribute of the 
edges (i.e. E(g)$weight).


reply via email to

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