Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Contracting two vertices into one in Igraph - error
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Priyanka Kadiyala  
View profile  
 More options Nov 7 2012, 7:55 pm
From: Priyanka Kadiyala <kkp1...@gmail.com>
Date: Wed, 7 Nov 2012 18:55:38 -0600
Local: Wed, Nov 7 2012 7:55 pm
Subject: [igraph] Contracting two vertices into one in Igraph - error

Hello All,

I'm trying to implement the Nagamochi-Ibaraki algorithm and have the
following problem:

I have picked two vertices, say "x" and "y" that need to be contracted into
a single vertex. I have tried to understand the contract.vertices function
but the mapping parameter is confusing me. The total vertices in my graph
are 26, and they will be contracted recursively until I have only 2 nodes
left. Can you please help me with this? I'm not sure what I'm doing wrong.

My graph is this: g1 <- barabasi.game(26, m=4, directed=FALSE,
algorithm="bag")

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:

> g2 <- contract.vertices(g1,(25:26),vertex.attr.comb=toString)

Error in contract.vertices(g1, (25:26), vertex.attr.comb = toString) :
  At structural_properties.c:6922 : Invalid mapping vector length, Invalid
value

Thank you,
Krishna.

_______________________________________________
igraph-help mailing list
igraph-h...@nongnu.org
https://lists.nongnu.org/mailman/listinfo/igraph-help


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tamás Nepusz  
View profile  
 More options Nov 8 2012, 4:29 am
From: Tamás Nepusz <nta...@gmail.com>
Date: Thu, 8 Nov 2012 10:29:25 +0100
Local: Thurs, Nov 8 2012 4:29 am
Subject: Re: [igraph] Contracting two vertices into one in Igraph - error
> 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
igraph-h...@nongnu.org
https://lists.nongnu.org/mailman/listinfo/igraph-help


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Priyanka Kadiyala  
View profile  
 More options Nov 8 2012, 8:18 am
From: Priyanka Kadiyala <kkp1...@gmail.com>
Date: Thu, 8 Nov 2012 07:17:51 -0600
Local: Thurs, Nov 8 2012 8:17 am
Subject: Re: [igraph] Contracting two vertices into one in Igraph - error

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.

_______________________________________________
igraph-help mailing list
igraph-h...@nongnu.org
https://lists.nongnu.org/mailman/listinfo/igraph-help


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tamás Nepusz  
View profile  
 More options Nov 8 2012, 8:21 am
From: Tamás Nepusz <nta...@gmail.com>
Date: Thu, 8 Nov 2012 14:20:47 +0100
Local: Thurs, Nov 8 2012 8:20 am
Subject: Re: [igraph] Contracting two vertices into one in Igraph - error

> 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

_______________________________________________
igraph-help mailing list
igraph-h...@nongnu.org
https://lists.nongnu.org/mailman/listinfo/igraph-help


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Priyanka Kadiyala  
View profile  
 More options Nov 8 2012, 8:24 am
From: Priyanka Kadiyala <kkp1...@gmail.com>
Date: Thu, 8 Nov 2012 07:23:58 -0600
Local: Thurs, Nov 8 2012 8:23 am
Subject: Re: [igraph] Contracting two vertices into one in Igraph - error

Thank you! I had read that part, I just implemented it wrong and was
getting an error, the example clarified it further and I successfully tried
contracting a few more nodes.

I really appreciate your help and patience! Thank you!

_______________________________________________
igraph-help mailing list
igraph-h...@nongnu.org
https://lists.nongnu.org/mailman/listinfo/igraph-help


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »