[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[igraph] Intersect graphs with different vertices
From: |
Magnus Torfason |
Subject: |
[igraph] Intersect graphs with different vertices |
Date: |
Wed, 28 Oct 2009 10:58:04 -0400 |
User-agent: |
Thunderbird 2.0.0.23 (Windows/20090812) |
Hi all,
I need to intersect two graphs that do not have the same vertices - I am
using the name attribute to identify vertices. In other words, I would
like to run:
> g1 <- graph.formula(a-b-c)
> g2 <- graph.formula(b-c-d)
> g3 <- graph.intersection(g1,g2)
and have g3 be the same graph as g4, constructed in the following manner:
> g4 <- graph.formula(b-c)
Obviously (obvious enough if you run the code, that is), this does not
happen. In accordance with the disclaimer in the help file, the
attributes are ignored.
The question is then: Is there code to achieve this functionality
floating around somewhere?
If not, I'll probably have to create it. Since matching up the real
indexes in two graphs seems like a not completely trivial task, I expect
I would opt for constructing two data.frames representing each edgelist,
merge them, and reconstruct the graph.
I'd appreciate any helpful pointers on whether there are prettier ways
to achieve this.
If I end up having to write the function, I'd be willing to share it (it
seems pretty general), but it would be written in R, not in C, so I'm
not sure if it would be suitable for inclusion in igraph itself
(Gabor/Tamas?).
Best,
Magnus
- [igraph] Intersect graphs with different vertices,
Magnus Torfason <=