in reply to
How to compare two undirected graphs?

Your description is confusing.

Comparing the "shape" sound like a isomorphism test. In this case be aware that the "graph isomorphism problem" is NP-complete.

Then you say your nodes are already named and have "children". General graphs have no children they have neighbours. So maybe you are speaking of trees or lattices (which have a bottom and a top element).

But names and other properties should simplify the comparison it can be easier to normalize both graph according those weights and consequently ordering the nodes.

This depends on the memory representation, e.g. when taking an incidence matrix of both graphs you can order rows and columns according to the associated weights (e.g. first row/column representing the "top node" and so on). Graphs with the same incidence matrix after permutation are isomorphic.

Of course this becomes more complicated when having a nontrivial automorphism group in large graphs which is the reason for the mentioned NP-completeness.

In short there is no general __fast__ solution for arbitrary graphs when they get big, but *"a number of important special cases of the graph isomorphism problem have efficient, polynomial-time solutions"*

Cheers Rolf

UPDATE:added links

Comment on
Re: How to compare two undirected graphs?
Replies are listed 'Best First'. | |
---|---|

Re^2: How to compare two undirected graphs? by Anonymous Monk on Oct 18, 2010 at 17:06 UTC | |

- Re^3: How to compare two undirected graphs?
by LanX (Canon) on Oct 18, 2010 at 21:54 UTC | |

- Re^3: How to compare two undirected graphs?
by dwm042 (Priest) on Oct 19, 2010 at 17:07 UTC |

In Section
Seekers of Perl Wisdom