igraph-help
[Top][All Lists]

## [igraph] Analyzing Graphs with Non-standard Node Labeling

 From: Lorenzo Isella Subject: [igraph] Analyzing Graphs with Non-standard Node Labeling Date: Wed, 01 Jul 2009 17:34:41 +0200 User-agent: Thunderbird 2.0.0.22 (X11/20090608)

```Dear All,
```
Consider a graph that you generate from an adjacency list but in which the nodes are not labeled with a standard set of integers 0,1,...... increasing by one for each node.
```To fix the ideas, consider the adjacency list of the graph given as

1101 1264
1134 1386
1114 1595
1161 1537
1101 1187
505 1138
1101 1114
1120 1138
501 1321
1132 1381
1138 1567
1197 1245
1118 1381
1499 1567
1101 1118
1002 1003
1197 1567
1167 1327
506 1138
1264 1567
1197 1595
501 1237
1118 1245
1193 1589
1138 1595
504 1167
1114 1567
1007 1524
1002 1237
1118 1514
1118 1264
506 1585
505 1327
1150 1203
1002 1120
1245 1264
1245 1595
504 1321
1101 1132
501 1120
1134 1203
1114 1187
1179 1196
1264 1611
1007 1578
1001 1002
1567 1595
1120 1264
1101 1245
506 1321
505 1585
509 1465
504 1120
1120 1245
1138 1237
1138 1585
1187 1381
506 1237
1264 1514
1386 1514
1245 1567
1237 1245
1132 1193
1101 1499
505 506
505 1120
502 1138
503 1120
1120 1321
501 1196
1101 1514
505 1321
1132 1187

which I saved into the attached file graph_list_no_rep.dat

Now, see what happens once I read and plot the graph

rm(list=ls())

library(Cairo)
library(igraph)

graph_input<-as.matrix(graph_input)

graph_input_unweighted <- graph_input[ ,1:2]

# Now I have the graph as a two-column matrix

g <- graph(t(graph_input_unweighted), directed=FALSE)

g <- simplify(g)

#save the graph in a convenient format (e.g. edgelist)

write.graph(g, "edgelist-graph", format="edgelist")

#Now plot the graph

E(g)\$color <- "grey"
E(g)\$width <- 1
V(g)\$label.color <- "blue"
V(g)\$color  <- "SkyBlue2"

pdf("network.pdf")

plot(g, layout=layout.fruchterman.reingold,
vertex.label.dist=0.5,vertex.label=NA, vertex.size=5)

dev.off()

```
The generated pdf shows a graph having probably hundreds of nodes, which cannot be what I have in mind. The integer numbers giving the ID of each node are not a list where the i-th node is labeled by the integer i (or i-1 if you count from zero), but I still would like to get a standard view of the graph (also for further analysis).
```How should I deal with my input file to generate the graph?
Many thanks

Lorenzo
```

graph_list_no_rep.dat
Description: Netscape Proxy Auto Config

reply via email to