igraph-help
[Top][All Lists]

## 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:

library(igraph)
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:

plot(g)

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).

--
T.

```