isomorphism#
- graph_tool.topology.isomorphism(g1, g2, vertex_inv1=None, vertex_inv2=None, isomap=False)[source]#
Check whether two graphs are isomorphic.
- Parameters:
- g1
Graph
First graph.
- g2
Graph
Second graph.
- vertex_inv1
VertexPropertyMap
(optional, default: None) Vertex invariant of the first graph. Only vertices with with the same invariants are considered in the isomorphism.
- vertex_inv2
VertexPropertyMap
(optional, default: None) Vertex invariant of the second graph. Only vertices with with the same invariants are considered in the isomorphism.
- isomap
bool
(optional, default:False
) If
True
, aVertexPropertyMap
with the isomorphism mapping is returned as well.
- g1
- Returns:
- is_isomorphism
bool
True
if both graphs are isomorphic, otherwiseFalse
.- isomap
VertexPropertyMap
Isomorphism mapping corresponding to a property map belonging to the first graph which maps its vertices to their corresponding vertices of the second graph.
- is_isomorphism
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