Here is an example of how to create a edge-labeled graph using igraph.

> a  
a
[,1] [,2] [,3]
[1,] 0 2 1
[2,] 2 0 3
[3,] 1 3 0
> g1  
g1
Vertices: 3
Edges: 6
Directed: TRUE
Edges:

[0] 0 -> 1
[1] 0 -> 2
[2] 1 -> 0
[3] 1 -> 2
[4] 2 -> 0
[5] 2 -> 1
> E(g1)$weight
[1] 2 1 2 3 1 3
> E(g1)
Edge sequence:

[0] 0 -> 1
[1] 0 -> 2
[2] 1 -> 0
[3] 1 -> 2
[4] 2 -> 0
[5] 2 -> 1
> get.adjacency(g1, attr="weight")
[,1] [,2] [,3]
[1,] 0 2 1
[2,] 2 0 3
[3,] 1 3 0
Advertisements