igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Contracting two vertices into one in Igraph - error


From: Tamás Nepusz
Subject: Re: [igraph] Contracting two vertices into one in Igraph - error
Date: Thu, 8 Nov 2012 14:20:47 +0100

> 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?

Quoting myself:

> 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.
In your case, u=1 and v=5 (since you are merging node 5 into node 1), so the 
contraction vector is:

c(1:4, 1, 5:(vcount(g)-1))

Best,
Tamas




reply via email to

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