igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Maximum Common Subgraph


From: Tamas Nepusz
Subject: Re: [igraph] Maximum Common Subgraph
Date: Fri, 11 Mar 2011 15:56:56 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8


I am slightly confused what the new build will do.  Does this also update the python bindings I am already using?
Yes, beacuse the two versions (0.5 and 0.6) are binary incompatible; i.e. there were a few updates in the C layer that require the recompilation of the Python interface as well.

I have provided an example so that I'm sure that I am understanding what I should do exactly. 

This is my test case. 

------------------------------------------------------------------------------------------------------------
from igraph import  GraphBase;
You don't need GraphBase; Graph derives from GraphBase and the latter is an internal thing anyway :)

Also, there is one other modification that you have to do; get_subisomorphisms_vf2 does not start using the vertex names "magically", it requires a numeric vector where each element specifies the "color" (or "label") of the corresponding vertex. You have to construct that mapping from names to numeric IDs yourself, and then pass the vectors mapping vertices to "colors" to get_subisomorphisms_vf2. I'll try to adapt your example:

def test(self):
    g = Graph.Formula("A-B-D")
    g2 = Graph.Formula("B-D")
    all_names = set(g.vs["name"]).union(g2.vs["name"])
    names_to_colors = dict((v, k) for k, v in enumerate(all_names))
    colors1 = [names_to_colors[name] for name in g.vs["name"]]
    colors2 = [names_to_colors[name] for name in g2.vs["name"]]
    print g.get_subisomorphisms_vf2(g2, colors1, colors2)

This one prints "[[1, 2]]" for me; I think this is the correct result as vertex 0 of the second graph maps to vertex 1 of the first one and vertex 1 of the second graph maps to vertex 2 of the first one, and there is no other mapping, right?

I'll prepare a Snow Leopard installer for you in the evening or tomorrow, when time allows.

Cheers,
--
Tamas


reply via email to

[Prev in Thread] Current Thread [Next in Thread]