<｜begin▁of▁sentence｜>### Instruction:
Given an undirected graph with edges [(1, 2), (2, 3), (3, 4)], can you use the Matching class from NetworkX to determine whether a given matching is maximal?
### Response:
import networkx as nx

# Create a graph
G = nx.Graph()
G.add_edges_from([(1, 2), (2, 3), (3, 4)])

# Find a matching in the graph
good_matching = {(1, 2), (3, 4)}
bad_matching = {(1, 2)}

# Use the Matching class to check if the matching is maximal
matching_obj_good = nx.algorithms.matching.Matching(good_matching)
is_good_maximal = matching_obj_good.is_maximal()
print(f'Good matching is maximal: {is_good_maximal}')

matching_obj_bad = nx.algorithms.matching.Matching(bad_matching)
is_bad_maximal = matching_obj_bad.is_maximal()
print(f'Bad matching is maximal: {is_bad_maximal}')
<|EOT|>
