[R-sig-networks] Subsets of edges with igraph

Manolito Perez c@neydeoriente @ending from y@hoo@com
Sun Jul 29 18:11:41 CEST 2018


Hi all, 
First of all, I have to say that I am new to R, and my first impression is very good, so I am determined to become proficient in it. Well, I have a simple undirected graph in the package 'igraph', and I want to generate all subsets of its edges. I have seen two functions that do that, one being 'combn', from the package 'combinat', and the other one being 'set_combn', from the package 'sets' (if I remember correctly). However, none of them does what I want, and I don't quite understand what is happenning. More precisely, my graph has the following edge list:
    > mylist
         [,1] [,2][1,]    1    2[2,]    2    3[3,]    1    3
Now, I want to generate all the subsets with two edges, and I call the function 'combn', which gives the following result: 
    > combn(mylist, 2)
         [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15]
[1,]    1    1    1    1    1    2    2    2    2     1     1     1     2     2     3
[2,]    2    1    2    3    3    1    2    3    3     2     3     3     3     3     3

First of all, the result are pairs of vertices, and not pairs of edges, that should contain four vertices, if I understand correctly. Second, there are repeated pairs, and combinations should contain no repetitions, right?
As for the other function, 'set_combn', it gives the following result:
    > set_combn(mylist,2) 
    {{1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}}
which is also incorrect. Any help, please? 


	[[alternative HTML version deleted]]



More information about the R-sig-networks mailing list