<｜begin▁of▁sentence｜>### Instruction:
Given a graph represented as a path graph with 5 nodes (nodes are numbered from 0 to 4), can you compute the shortest path from node 0 to node 4, the shortest paths from node 0 to all other nodes, the shortest paths to node 4 from all other nodes, and the shortest paths between all pairs of nodes using NetworkX?
### Response:
import networkx as nx

# Create a graph
G = nx.path_graph(5)

# Compute the shortest path from node 0 to node 4
path = nx.shortest_path(G, source=0, target=4)
print(path)

# Compute the shortest paths from node 0 to all other nodes
paths_from_source = nx.shortest_path(G, source=0)
print(paths_from_source[3])

# Compute the shortest paths to node 4 from all other nodes
paths_to_target = nx.shortest_path(G, target=4)
print(paths_to_target[1])

# Compute the shortest paths between all pairs of nodes
all_shortest_paths = nx.shortest_path(G)
print(all_shortest_paths[2][4])
<|EOT|>
