<｜begin▁of▁sentence｜>### Instruction:
Given two graphs G1 and G2, where G1 consists of nodes 1, 2, 3, 4 connected by edges with labels ('A', 'A', 'A', 'B'), and G2 consists of nodes 5, 6, 7, 8 connected by edges with labels ('B', 'A', 'A', 'A'), can we use the weisfeiler_lehman_graph_hash to get a hash that distinguishes the two graphs based on their structure and edge labels?
### Response:
import networkx as nx
from networkx.algorithms.graph_hashing import weisfeiler_lehman_graph_hash

# Create two graphs
G1 = nx.Graph()
G1.add_edges_from([(1, 2, {'label': 'A'}), (2, 3, {'label': 'A'}), (3, 1, {'label': 'A'}), (1, 4, {'label': 'B'})])
G2 = nx.Graph()
G2.add_edges_from([(5, 6, {'label': 'B'}), (6, 7, {'label': 'A'}), (7, 5, {'label': 'A'}), (7, 8, {'label': 'A'})])

# Hash the graphs without considering edge labels
hash1 = weisfeiler_lehman_graph_hash(G1)
hash2 = weisfeiler_lehman_graph_hash(G2)
print(f'Hash of G1 without edge labels: {hash1}')
print(f'Hash of G2 without edge labels: {hash2}')

# Hash the graphs considering edge labels
hash1_labeled = weisfeiler_lehman_graph_hash(G1, edge_attr='label')
hash2_labeled = weisfeiler_lehman_graph_hash(G2, edge_attr='label')
print(f'Hash of G1 with edge labels: {hash1_labeled}')
print(f'Hash of G2 with edge labels: {hash2_labeled}')
<|EOT|>
