<｜begin▁of▁sentence｜>### Instruction:
Imagine we're working on a construction project and we've mapped out the logistics network for transporting materials between different sites. The network is directed, capturing the one-way routes between sites, and each route incurs a different transportation cost. We have this cost network outlined as follows: the route from Site 0 to Site 1 costs $4.5 million, from Site 1 to Site 2 is $6.2 million, from Site 2 to Site 3 is $3.1 million, and from Site 3 to Site 4 is $2.7 million.

As a Construction Estimator, your task is to figure out the least expensive path to transport materials from Site 0, the origin, to Site 4, the destination, using the provided cost network. Could you calculate the most cost-effective path using the Bellman-Ford algorithm? Keep in mind that the accurate calculation of this optimal route is crucial for minimizing the project's transportation expenses.
### Response:
import networkx as nx

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

# Use Bellman-Ford algorithm to find the shortest path length
try:
    length = nx.bellman_ford_path_length(G, 0, 4)
    print('Shortest path length from node 0 to 4:', length)
except nx.NodeNotFound as e:
    print('One of the nodes does not exist:', e)
except nx.NetworkXNoPath as e:
    print('There is no path between the specified nodes:', e)
<|EOT|>
