<｜begin▁of▁sentence｜>### Instruction:
Certainly! Imagine you are overseeing a supply chain operation as a Purchasing Manager, and you're evaluating the efficiency of different routes for transporting goods between four warehouses, designated as Warehouse 0, Warehouse 1, Warehouse 2, and Warehouse 3. Each route between the warehouses has an associated cost, and the objective is to minimize this transportation cost.

You have transportation data that outlines the costs between the warehouses as follows: the route from Warehouse 0 to Warehouse 1 has a cost of 3, from Warehouse 1 to Warehouse 2 the cost is 7, from Warehouse 2 to Warehouse 3 it's 2, and there's a direct route from Warehouse 1 to Warehouse 3 that only costs 1.

Using NetworkX, a tool that can help us analyze and optimize network paths, how can we determine the most cost-effective path for goods to travel from Warehouse 0 to all other warehouses? Additionally, how do we find out which warehouse should act as a predecessor or intermediary stop to ensure the lowest transportation costs?
### Response:
import networkx as nx

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

# Compute the shortest path and predecessors starting from node 0
pred, dist = nx.dijkstra_predecessor_and_distance(G, source=0)

# Output the results
print('Predecessors:', sorted(pred.items()))
print('Distances:', sorted(dist.items()))
<|EOT|>
