Skip to content

Subgraph isomorphism using vertex labels

4 messages · HIMANSHU MITTAL, Gábor Csárdi

#
Hi,

igraph will give you the mappings via vertex ids. If you want to use
symbolic vertex names, then attach a vertex attribute called 'name'.
Then any vector of numeric vertex ids (v, from graph g) can be
converted to vertex names via

V(g)$name[v]

or the more readable equivalent

get.vertex.attribute(g, "name", v)

Best,
Gabor
On Tue, Jul 31, 2012 at 3:12 PM, HIMANSHU MITTAL <hm3286 at gmail.com> wrote:

  
    
#
I am sorry, but I don't know what exactly is the problem. What's wrong
with this:

library(igraph)
kar <- nexus.get("karate")
star3 <- graph.formula(A -- B:C:D)
subiso <- graph.get.subisomorphisms.vf2(kar, star3)

Then you can query the symbolic ids:

V(kar)$name[ subiso[[1]]+1 ]   # This is actually a bug and the +1
should not be needed

Or for all isomorphic subgraphs:

subiso2 <- lapply(subiso, function(x) V(kar)$name[x+1])

Gabor
On Wed, Aug 1, 2012 at 11:27 PM, HIMANSHU MITTAL <hm3286 at gmail.com> wrote: