[R] Help on comparing two matrices
Steve Lianoglou
mailinglist.honeypot at gmail.com
Tue Aug 25 15:40:34 CEST 2009
Hi,
It looks like you're getting more good stuff, but just to follow up:
On Aug 24, 2009, at 4:01 PM, Michael Kogan wrote:
> Steve: The two matrices I want to compare really are graph matrices,
> just not adjacency but incidence matrices. There should be a way to
> get an adjacency matrix of a graph out of its incidence matrix but I
> don't know it...
If you're working with graph data, do yourself a favor and install
igraph (no matter what solution you end up using for this particular
problem).
http://cran.r-project.org/web/packages/igraph/
http://igraph.sourceforge.net/
In there, you'll find the `graph.incidence` function which creates a
graph from its incidence matrix. You can then test if the two graphs
are isomorphic.
That would look like so:
library(igraph)
g1 <- graph.incidence(matrix.1)
g2 <- graph.incidence(matrix.2)
is.iso <- graph.isomorphic(g1, g2)
# Or, using the (somehow fast) vf2 algorithm
is.iso <- graph.isomorphic.vf2(g1, g2)
HTH,
-steve
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the R-help
mailing list