<｜begin▁of▁sentence｜>### Instruction:
Given a weighted graph with the edge set [("A", "B", 3), ("B", "C", 8), ("C", "D", 2), ("A", "D", 5), ("B", "D", 2)], what is the shortest path length from node 'A' to node 'D' using the Bellman-Ford algorithm?
### Response:
import networkx as nx

# Create a weighted graph
G = nx.Graph()
G.add_weighted_edges_from([("A", "B", 3), ("B", "C", 8), ("C", "D", 2), ("A", "D", 5), ("B", "D", 2)])

# Compute the shortest path length using the Bellman-Ford algorithm
path_length = nx.bellman_ford_path_length(G, source="A", target="D", weight='weight')
print("Shortest path length from A to D:", path_length)
<|EOT|>
