shortest-path

Compute shortest paths in weighted graphs using Dijkstra, Bellman-Ford, Floyd-Warshall, and A*.

Updated Jan 26, 2026
One-click install
npx skills add https://github.com/SPIRAL-EDWIN/MCM-ICM-2601000 --skill shortest-path
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shortest-path
Source: https://github.com/SPIRAL-EDWIN/MCM-ICM-2601000/tree/main/.github/skills/shortest-path
Command: npx skills add https://github.com/SPIRAL-EDWIN/MCM-ICM-2601000 --skill shortest-path

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps users compute optimal routes and connectivity in weighted graphs, eliminating manual graph-traversal tasks and enabling rapid decision-making in routing, logistics, and network analysis.

Core Features & Use Cases

  • Single-source shortest paths with non-negative weights using Dijkstra.
  • All-pairs shortest paths with Floyd-Warshall for dense graphs or precomputed matrices.
  • Negative weights handling via Bellman-Ford and robust path reconstruction.
  • Heuristic search using A* when an admissible heuristic is available (e.g., geographic distance).
  • Real-world scenarios: city logistics routing, emergency response planning, network routing optimization.

Quick Start

Run the included examples to compute a sample path, or adapt the code to your graph. For example, use networkx to build a graph and call the dijkstra, bellman_ford, floyd_warshall, or a_star functions to obtain distances and reconstruct paths.

Frequently Asked Questions about shortest-path

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find the shortest path in a weighted graph for routing and logistics planning?

To find the shortest path in a weighted graph, you can use algorithms like Dijkstra for non-negative weights, Bellman-Ford for negative weights, Floyd-Warshall for all-pairs, or A* for heuristic geographic searches. This Skill implements these with path reconstruction for logistics and network optimization.

Can I compute all-pairs shortest paths for a dense graph using Floyd-Warshall?

Yes, you can compute all-pairs shortest paths for dense graphs or precomputed matrices using the Floyd-Warshall algorithm. This Skill provides Floyd-Warshall implementation to generate complete distance matrices for comprehensive network analysis.

How do I handle negative weights and detect negative cycles in graph traversal?

You handle negative weights and detect negative cycles using the Bellman-Ford algorithm. This Skill includes Bellman-Ford with robust path reconstruction and optional negative-cycle detection to ensure safe routing in complex networks.

What is the best way to compute single-source shortest paths with non-negative edge weights?

The best way to compute single-source shortest paths with non-negative edge weights is using Dijkstra's algorithm. This Skill implements Dijkstra to efficiently find optimal routes and connectivity for transportation networks.

Does A* search work for geographic distance routing in transportation networks?

Yes, A* search works for geographic distance routing when an admissible heuristic is available. This Skill implements A* to enable heuristic search, optimizing pathfinding in real-world scenarios like city logistics and emergency response planning.

How do I reconstruct the actual path after running Dijkstra or Bellman-Ford?

You reconstruct the actual path by calling the dijkstra or bellman_ford functions to obtain distances and using the built-in path reconstruction features. This Skill provides robust path reconstruction alongside distance calculations for all implemented algorithms.