isomorphism

Contents

isomorphism#

graph_tool.topology.isomorphism(g1, g2, vertex_inv1=None, vertex_inv2=None, isomap=False)[source]#

Check whether two graphs are isomorphic.

Parameters:
g1Graph

First graph.

g2Graph

Second graph.

vertex_inv1VertexPropertyMap (optional, default: None)

Vertex invariant of the first graph. Only vertices with with the same invariants are considered in the isomorphism.

vertex_inv2VertexPropertyMap (optional, default: None)

Vertex invariant of the second graph. Only vertices with with the same invariants are considered in the isomorphism.

isomapbool (optional, default: False)

If True, a VertexPropertyMap with the isomorphism mapping is returned as well.

Returns:
is_isomorphismbool

True if both graphs are isomorphic, otherwise False.

isomapVertexPropertyMap

Isomorphism mapping corresponding to a property map belonging to the first graph which maps its vertices to their corresponding vertices of the second graph.

Examples

>>> g = gt.random_graph(100, lambda: (3,3))
>>> g2 = gt.Graph(g)
>>> gt.isomorphism(g, g2)
True
>>> g.add_edge(g.vertex(0), g.vertex(1))
<...>
>>> gt.isomorphism(g, g2)
False