igraph-help
[Top][All Lists]
Advanced

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

[igraph] reordering the vertex sequence


From: Lin Freeman
Subject: [igraph] reordering the vertex sequence
Date: Sat, 28 May 2011 07:12:45 -0700

Suppose I have a data set, "zach" in an ncol form with weights:

                   2                   1                   4
                   3                   1                   5
                   3                   2                   6
                   4                   1                   3
                   4                   2                   3
                   4                   3                   3
                   5                   1                   3
                   6                   1                   3
                   7                   1                   3
                   7                   5                   2
                   7                   6                   5
                   8                   1                   2
                   8                   2                   4
                   8                   3                   4
                   8                   4                   3
                   9                   1                   2
                   9                   3                   5
                  10                   3                   1
                  11                   1                   2
                  11                   5                   3
                  11                   6                   3
                  12                   1                   3
                  13                   1                   1
                  13                   4                   3
                  14                   1                   3
                  14                   2                   5
                  14                   3                   3
                  14                   4                   3
                  17                   6                   3
                  17                   7                   3
                  18                   1                   2
                  18                   2                   1
                  20                   1                   2
                  20                   2                   2
                  22                   1                   2
                  22                   2                   2
                  26                  24                   5
                  26                  25                   2
                  28                   3                   2
                  28                  24                   4
                  28                  25                   3
                  29                   3                   2
                  30                  24                   3
                  30                  27                   4
                  31                   2                   2
                  31                   9                   3
                  32                   1                   2
                  32                  25                   2
                  32                  26                   7
                  32                  29                   2
                  33                   3                   2
                  33                   9                   3
                  33                  15                   3
                  33                  16                   3
                  33                  19                   1
                  33                  21                   3
                  33                  23                   2
                  33                  24                   5
                  33                  30                   4
                  33                  31                   3
                  33                  32                   4
                  34                   9                   4
                  34                  10                   2
                  34                  14                   3
                  34                  15                   2
                  34                  16                   4
                  34                  19                   2
                  34                  20                   1
                  34                  21                   1
                  34                  23                   3
                  34                  24                   4
                  34                  27                   2
                  34                  28                   4
                  34                  29                   2
                  34                  30                   2
                  34                  31                   3
                  34                  32                   4
                  34                  33                   5

I can read it into igraph as follows:

> G <- read.graph("zach.txt", format="ncol", weights=V(G)$weight

But, then, the vertex sequence is:

> V(G)
Vertex sequence:
 [1] "2"  "1"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "17"
[16] "18" "20" "22" "26" "24" "25" "28" "29" "30" "27" "31" "32" "33" "15" "16"
[31] "19" "21" "23" "34"

However, I want the vertices in G to be arranged in the natural order according to their labels, "1"  "2"  etc.
That way I can interpret the memberships produced by a community finding algorithm easily.

How can I get the vertices into the order I want?

Thank you,

Lin Freeman

--
Linton C. Freeman
Institute for Mathematical Behavioral Sciences and
Department of Sociology
School of Social Sciences  SSPA 2143
University of California
Irvine, CA 92697-5100

Office:             (949) 824-6698
Home (CA):      (949) 494-6139
          (FL):      (941) 778-1074
Secretary:        (949) 824-3663
FAX:                (949) 824-3733

reply via email to

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