Check isomorphism of directed graphs.
A DiGraphMatcher is responsible for matching directed graphs (DiGraph or XDiGraph) in a predetermined manner. For graphs G1 and G2, this typically means a check for an isomorphism between them, though other checks are also possible. For example, the DiGraphMatcher class can check if a subgraph of G1 is isomorphic to G2.
Matching is done via syntactic feasibility. It is also possible to check for semantic feasibility. Feasibility, then, is defined as the logical AND of the two functions.
To include a semantic check, you should subclass the GraphMatcher class and redefine semantic_feasibility(). By default, the semantic feasibility function always returns True. The effect of this is that semantics are not considered in the matching of G1 and G2.
Suppose G1 and G2 are isomorphic graphs. Verfication is as follows:
>>> G1=nx.path_graph(4)
>>> G2=nx.path_graph(4)
>>> GM = nx.GraphMatcher(G1,G2)
>>> GM.is_isomorphic()
True
>>> GM.mapping
{0: 0, 1: 1, 2: 2, 3: 3}
GM.mapping stores the isomorphism mapping.