<｜begin▁of▁sentence｜>### Instruction:
Given a directed graph with weighted edges [(0, 1, 3), (1, 2, 4), (2, 3, 5), (3, 1, -10)], can you compute the shortest path lengths from node 0 to all other nodes using the Bellman-Ford algorithm?
### Response:
import networkx as nx

# Create a weighted graph
G = nx.DiGraph()
G.add_weighted_edges_from([(0, 1, 3), (1, 2, 4), (2, 3, 5), (3, 1, -10)])

# Compute the shortest path length using Bellman-Ford algorithm
length = nx.single_source_bellman_ford_path_length(G, 0)

for node in G.nodes():
  print(f"Shortest path length from node 0 to {node}: {length[node]}")
<|EOT|>
