Hello Everyone! This is my first post to the mailing list so please forgive me if I am a bit deflected from the general format of this mailing list posts. Since I need help in this matter urgently, I would cover up any of my mistakes in posting later. That said, I have a problem in merging 2 graphs that have common nodes between them. I have a graph G1, that have nodes N1 and edge set E1 and graph G2, with nodes N2, edge set E2. Nodes N1 and N2 have some common nodes in them say N3 = N1(intersection)N2. I want to create a new graph G3 such that it has interactions from both these graphs amongst these nodes. Like union of G1, G2. Trouble is when I use Igraph and do the addition of edges and vertices into the new graph, the associations are not consistent. For eg A -- B in G1 B -- C in G2 so in G3 I would expect A -- B B -- C Instead I get B -- Z which baffles me. I tried getting around this all day but couldn't come up with the resultant graph. I am sure I am missing something basic here but the Igraph documentation is not that helpful. Any suggestions and tips? Thanks in advance.. -- Sandeep Amberkar PhD Student, Bioquant, University of Heidelberg,Germany -- View this message in context: http://r.789695.n4.nabble.com/Merging-graphs-with-common-nodes-tp3400017p3400017.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
Hi Sandeep. On Wed, Mar 23, 2011 at 1:03 PM, ssamberkar <ssamberkar at gmail.com> wrote: [...]> > A -- B in G1 > > B -- C in G2 > > so in G3 I would expect > > A -- B > > B -- C > > > Instead I get B -- Z which baffles me.This is because the operations are based on the internal vertex ids and not on the vertex names. You can do two things. One is that you permute the vertices in your graphs, so that the vertex id match, see permute.vertices() this. The other is that you take the code from http://lists.gnu.org/archive/html/igraph-help/2009-10/msg00087.html Best, Gabor> I tried getting around this all day but couldn't come up with the resultant > graph. I am sure I am missing something basic here but the Igraph > documentation is not that helpful. > Any suggestions and tips? > > Thanks in advance.. > > > -- > > Sandeep Amberkar > > PhD Student, > > Bioquant, University of Heidelberg,Germany > > > -- > View this message in context: http://r.789695.n4.nabble.com/Merging-graphs-with-common-nodes-tp3400017p3400017.html > Sent from the R help mailing list archive at Nabble.com. > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Gabor Csardi <csardi at rmki.kfki.hu>? ?? MTA KFKI RMKI
Hi Gabor, Thanks a lot for your help! Those graph functions worked smoothly. I had to only change the flag allow.duplicates=TRUE in safer.merge function. I have another issue. Does the write.graph function support the xml or graphml format to write graphs? That way these graphs are easier to import in Cytoscape. Although .gml works well too but that's the only file format compatible to Cytoscape. Can you suggest some work around for this? Thanks a lot again.. -- View this message in context: http://r.789695.n4.nabble.com/Merging-graphs-with-common-nodes-tp3400017p3405258.html Sent from the R help mailing list archive at Nabble.com.
Hi Gabor, Thanks a lot for your help! Those graph functions worked smoothly. I had to only change the flag allow.duplicates=TRUE in safer.merge function. I have another issue. Does the write.graph function support the xml or graphml format to write graphs? That way these graphs are easier to import in Cytoscape. Although .gml works well too but that's the only file format compatible to Cytoscape. Can you suggest some work around for this? Thanks a lot again.. -- View this message in context: http://r.789695.n4.nabble.com/Merging-graphs-with-common-nodes-tp3400017p3405261.html Sent from the R help mailing list archive at Nabble.com.