SciPy

1.17.1 · active · verified Sat Mar 28

SciPy is a Python library for scientific computing, offering modules for optimization, integration, interpolation, linear algebra, statistics, and more. The current version is 1.17.1, released on February 22, 2026, with a regular release cadence of approximately every 6 months.

Warnings

Install

Imports

Quickstart

This example demonstrates how to compute the shortest path distances in a graph using SciPy's sparse graph module.

import numpy as np
from scipy.sparse.csgraph import shortest_path

# Create a sample graph as a 2D NumPy array
graph = np.array([[0, 1, 2], [1, 0, 0], [2, 0, 0]])

# Compute the shortest path distances
dist_matrix, predecessors = shortest_path(graph, return_predecessors=True)

print('Shortest path distance matrix:')
print(dist_matrix)

view raw JSON →