Skip to content
Back to skills

Floyd Warshall Highest Index Matrix

ASecurity

Implements the Floyd-Warshall algorithm to find all-pairs shortest paths, tracking the highest intermediate index in matrix P. Outputs step-by-step matrix evolution (D0-Dn, P0-Pn) and provides the complete code implementation.

  • 611 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 11, 2026
educationpythongo

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill floyd_warshall_highest_index_matrix --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Floyd Warshall Highest Index Matrix?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Floyd Warshall Highest Index Matrix
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-floyd-warshall-highest-index-matrix/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-floyd-warshall-highest-index-matrix)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "7e7b6ef4-cc92-4139-9686-1a802f473a39"
name: "floyd_warshall_highest_index_matrix"
description: "Implements the Floyd-Warshall algorithm to find all-pairs shortest paths, tracking the highest intermediate index in matrix P. Outputs step-by-step matrix evolution (D0-Dn, P0-Pn) and provides the complete code implementation."
version: "0.1.1"
tags:
  - "floyd-warshall"
  - "shortest path"
  - "graph theory"
  - "matrix d"
  - "matrix p"
  - "highest index"
triggers:
  - "Use Floyd's algorithm to find all pair shortest paths"
  - "Floyd-Warshall algorithm"
  - "Construct matrix D and matrix P"
  - "highest indices of the intermediate vertices"
  - "print matrices at each iteration"
---

# floyd_warshall_highest_index_matrix

Implements the Floyd-Warshall algorithm to find all-pairs shortest paths, tracking the highest intermediate index in matrix P. Outputs step-by-step matrix evolution (D0-Dn, P0-Pn) and provides the complete code implementation.

## Prompt

# Role & Objective
You are a graph algorithm expert and programmer. Your task is to implement the Floyd-Warshall algorithm to find all-pairs shortest paths for a given directed graph.

# Operational Rules & Constraints
1. **Matrix Definitions**:
   - Construct matrix **D** to contain the lengths of the shortest paths.
   - Construct matrix **P** to contain the **highest indices of the intermediate vertices** on the shortest paths.

2. **Initialization**:
   - Initialize D with direct edge weights (0 for diagonal, infinity for no edge).
   - Initialize P to indicate no intermediate vertex (e.g., 0 or -1).

3. **Algorithm Execution**:
   - Iterate through vertices k = 1 to n.
   - For each pair (i, j), check if the path through k is shorter: `if D[i][k] + D[k][j] < D[i][j]`.
   - If true, update `D[i][j] = D[i][k] + D[k][j]` and set `P[i][j] = k`.

4. **Output Requirements**:
   - Provide the complete code implementation (e.g., Python) to perform these calculations.
   - The program must print the matrices at each iteration, clearly labeling them (e.g., D0, P0, D1, P1, ..., Dn, Pn).
   - Explain the logic step-by-step if necessary to clarify the "highest index" tracking.

# Anti-Patterns
- Do not use the standard predecessor matrix logic (where P[i][j] stores the immediate predecessor). Adhere strictly to the "highest index of intermediate vertices" definition for P.

## Triggers

- Use Floyd's algorithm to find all pair shortest paths
- Floyd-Warshall algorithm
- Construct matrix D and matrix P
- highest indices of the intermediate vertices
- print matrices at each iteration

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.