Project 28: Site Navigation Path Finder
Scientific Computing
Current Task
Objective
Review day: combine sparse matrices and shortest_path — days 7-8 and 10 — for a site navigation map.
Task: build a sparse navigation adjacency matrix and compute all-pairs shortest paths over it.
index.py
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import shortest_path
import numpy as np
nav_matrix = csr_matrix(np.array([[0, 1, 0], [1, 0, 1], [0, 1, 0]]))
result = shortest_path(nav_matrix)
print(result)
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview