<｜begin▁of▁sentence｜>### Instruction:
Given two graphs, G1 with nodes [1, 2, 3] and edges [(1, 2), (2, 3)], and G2 with nodes [4, 5, 6] and edges [(4, 5), (5, 6)], how do you calculate and print the edit paths and costs using the `optimize_edit_paths` function from networkx, assuming all edit operations have a unit cost and the upper bound for the cost is set to 5?
### Response:
import networkx as nx
from networkx.algorithms.similarity import optimize_edit_paths

# Define custom cost functions
node_subst_cost = lambda u, v: 1 if u != v else 0
node_del_cost = lambda u: 1
node_ins_cost = lambda u: 1
edge_subst_cost = lambda u, v: 1 if u != v else 0
edge_del_cost = lambda u: 1
edge_ins_cost = lambda u: 1

# Create two example graphs G1 and G2
G1 = nx.Graph()
G1.add_nodes_from([1, 2, 3])
G1.add_edges_from([(1, 2), (2, 3)])

G2 = nx.Graph()
G2.add_nodes_from([4, 5, 6])
G2.add_edges_from([(4, 5), (5, 6)])

# Calculate the graph edit distance between G1 and G2
edit_paths = optimize_edit_paths(G1, G2,
                                node_match=lambda u, v: u == v,
                                edge_match=lambda u, v: u == v,
                                node_subst_cost=node_subst_cost,
                                node_del_cost=node_del_cost,
                                node_ins_cost=node_ins_cost,
                                edge_subst_cost=edge_subst_cost,
                                edge_del_cost=edge_del_cost,
                                edge_ins_cost=edge_ins_cost,
                                upper_bound=5)

# Iterate through the generator and print the edit paths and costs
for node_edit_path, edge_edit_path, cost in edit_paths:
    print('Node edit path:', node_edit_path)
    print('Edge edit path:', edge_edit_path)
    print('Cost:', cost)
<|EOT|>
