igraph-help
[Top][All Lists]
Advanced

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

[igraph] regarding adjlist


From: Amit Kumar
Subject: [igraph] regarding adjlist
Date: Thu, 11 Sep 2008 14:41:34 +0100

Hello,
To get neighbourhood info of a random graph, as suggested by Gabor, I used this:

g <- erdos.renyi.game(100, 0.15)
adj <- get.adjlist(g)
out <- file("C:/Users/Amit/Documents/random_p1_100.nei", open="w")
lapply(seq_along(adj), function(x) {
  cat(x, "\t", length(adj[[x]]), "\t\t", sep=" ", file=out)
  cat(adj[[x]], sep="  ", file=out)
  cat("\n", file=out)
})
close(out)

got an output like this:
1      18         3  9  19  25  29  31  37  39  45  54  58  62  68  70  72  75  86  91
2      15         8  13  17  23  28  32  46  50  68  70  88  90  97  98  99
3      18         23  24  27  29  31  37  38  39  41  42  46  51  55  63  73  76  90  96
4      10         0  11  14  25  32  51  69  73  75  84
5      16         12  29  36  37  45  46  47  62  66  69  71  72  74  76  81  96
6      11         14  27  50  55  62  67  68  69  79  84  90
7      12         8  18  20  21  24  28  30  35  58  68  74  81
8      13         10  11  19  24  27  30  55  58  68  74  78  88  91
9      13         1  6  28  59  62  64  71  75  76  85  87  88  97
10      15         0  10  15  18  21  27  28  29  35  43  49  77  84  85  96

But I need output in the following format as the software i will be using is sensitive to spaces:

0
      1     3     2   129   130
      2     5     1       3   129   130   131
      3     5     2       4   130   131   132
      4     5     3       5   131   132   133
      5     5     4       6   132   133   134
      6     5     5       7   133   134   135
      7     5     6       8   134   135   136
      8     5     7       9   135   136   137
      9     5     8     10   136   137   138
    10     5     9     11   137   138   139

please help!

reply via email to

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