Difference between Graph Isomorphism and Automorphism using Python NetworkX
Graph isomorphism and automorphism are important concepts in graph theory. Graph isomorphism checks the equivalence of two graphs, while graph automorphism deals with the symmetry within a single graph. Using Python NetworkX, we can easily explore and visualize these concepts, making it a valuable tool for studying complex networks.
Difference between Graph Isomorphism and Automorphism
Characteristics | Graph Isomorphism | Graph Automorphism |
---|---|---|
Definition | A bijective mapping between the vertices of two graphs preserving the adjacency. | A re-labeling of the graph's vertices that maps the graph onto itself. |
Relationship | Between the two different graphs. | Within the same graph. |
Purpose | To check if two graphs are structurally identical. | To find symmetries within the graph. |
Example Code Usage | nx.is_isomorphic(G1, G2) | nx.algorithms.isomorphism.GraphMatcher(graph, graph).isomorphisms_iter() |
Real-world Example | Checking if two social networks are identical. | Finding symmetrical properties in the molecular structures. |
What is Graph Isomorphism?
Graph isomorphism is a concept where two graphs
Graph isomorphism is important in various fields, including chemistry (for comparing molecular structures), network theory, and computer science (for pattern recognition and data structure analysis).
Formal Definition
Two graphs
Example:
import networkx as nx
def are_isomorphic(graph1, graph2):
return nx.is_isomorphic(graph1, graph2)
# Example usage:
G1 = nx.Graph()
G1.add_edges_from([(0, 1), (1, 2), (2, 0)])
G2 = nx.Graph()
G2.add_edges_from([(10, 11), (11, 12), (12, 10)])
print("Are G1 and G2 isomorphic?", are_isomorphic(G1, G2))
Output:
Are G1 and G2 isomorphic? True
What is Graph Automorphism?
Graph automorphism is a special case of graph isomorphism where a graph GGG is mapped onto itself in a way that preserves its structure. An automorphism of a graph is a permutation of the vertices that preserves adjacency.
Graph automorphisms are significant in studying the symmetries of graphs, which has applications in chemistry (studying molecular symmetries), network theory (analyzing symmetrical structures in networks), and combinatorial design.
Formal Definition
A graph
Example:
import networkx as nx
def automorphisms(graph):
return list(nx.algorithms.isomorphism.GraphMatcher(graph, graph).isomorphisms_iter())
# Example usage:
G = nx.Graph()
G.add_edges_from([(0, 1), (1, 2), (2, 0)])
auto_list = automorphisms(G)
print("Automorphisms of G:", auto_list)
Output:
Automorphisms of G: [{0: 0, 1: 1, 2: 2}, {0: 0, 2: 1, 1: 2}, {1: 0, 0: 1, 2: 2}, {1: 0, 2: 1, 0: 2}, {2: 0, 0: 1, 1: 2}, {2: 0, 1: 1, 0: 2}]