<｜begin▁of▁sentence｜>### Instruction:
Given a directed graph with edge set [(0, 1, 5), (1, 2, 3), (2, 3, 1), (0, 3, 4)] where the tuples represent (source, target, weight), can you compute the shortest path lengths from node 0 to all other nodes, as well as the specific shortest path from node 0 to node 3 using the Bellman-Ford algorithm?
### Response:
import networkx as nx

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

# Compute shortest paths and lengths from source node 0
length, path = nx.single_source_bellman_ford(G, 0)

# Print shortest path lengths from source to all other nodes
for node in G:
    print(f"Shortest path length from 0 to {node}: {length[node]}")

# Print the shortest path from source to node 3
print(f"Shortest path from 0 to 3: {path[3]}")
<|EOT|>
