Hi Tamas, Thank you for your help. I understand this function better, but here's the other problem:
Of the vertices 1:26, I can also choose two nodes that are not consecutive, as in, I can choose to merge (1,5) or (7,18) into a single vertex. Can this be done? Thank you for getting back to me! I really appreciate it! Best, Krishna. On Thu, Nov 8, 2012 at 3:29 AM, Tamás Nepusz <[email protected]> wrote: > > And after I pick two nodes, say 25, 26, which have multiple edges > between them, I'm trying to merge them into a single vertex: > The right contraction vector in this case is: > > c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,25) > > The reason is as follows. In the contraction vector, the i-th element must > contain the _new_ ID of vertex i of the _old_ graph (making sure that the > new IDs are in a continuous range from 1 to the desired number of vertices > in the new graph). This is to allow making several contractions and > permutations in a single step. Since the _new_ ID of every vertex except > your vertex 26 must stay the same, the first 25 elements of the vector are > 1:25. The 26th element must be 25 because you want the new ID of vertex 26 > to become 25 (since you merged that into vertex 25). > > In general, if you want to merge vertex v into vertex u (assuming that v > > u), you will need a contraction vector as follows: > > vec <- c(1:(v-1), u, v:(vcount(g)-1)) > > If v < u, just swap u and v and do the same thing. > > Best, > Tamas > > > _______________________________________________ > igraph-help mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/igraph-help >
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
