<｜begin▁of▁sentence｜>### Instruction:
Given a directed path graph with 5 nodes in sequence, can you compute and print the shortest path lengths from all nodes to the target node with id 4?
### Response:
import networkx as nx

# Create a directed graph
G = nx.path_graph(5, create_using=nx.DiGraph())

# Compute the shortest path lengths to target node 4 from all reachable nodes
lengths = dict(nx.single_target_shortest_path_length(G, 4))

# Print shortest path lengths to target node 4
for node in range(5):
    print(f"{node}: {lengths[node]}")
<|EOT|>
