<｜begin▁of▁sentence｜>### Instruction:
Given a weighted undirected graph with the edges set [(0, 1, 3), (1, 2, 4), (2, 3, 5), (0, 4, 2), (4, 3, 1)], how do you compute the shortest paths and distances to all nodes starting from the source nodes 0 and 4?
### Response:
import networkx as nx

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

# Compute shortest paths and lengths from source nodes 0 and 4
distance, path = nx.multi_source_dijkstra(G, {0, 4})

# Print distance and path for each target node
for node in G:
    print(f"{node}: {distance[node]} - Path: {path[node]}")
<|EOT|>
