SkillAgentSearch skills...

Dijkstra

A small implementation of Dijkstra's algorithm, as implemented to find shortest paths between cities.

Install / Use

/learn @fedelebron/Dijkstra
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

A small implementation of Dijkstra's algorithm, for single-source shortest paths in a nonnegatively weighted directed graph.

Comments are in the header files, in Spanish. Its input is something of this form:

  1. City 0 name here
  2. City 1 name here . . . n) City n name here

i -> j k . . . i' -> j' k'

Where an arrow i -> j k means an edge from node i to node j, of weight k. The node indices come from the previous list.

main.c has the city to start the search from, and an optional city to find the shortest distance to, and color a shortest path.

The directory C++ contains an implementation in C++ of the same algorithm. The input format is different - it starts with which node is the source, then how many vertices there are, then a list of vertices, and then a series of nodes to which one wants to find the shortest distance, starting from the source.

A sample run of that is ./Dijkstra < grafo.txt. It will list out the shortest distances to the target nodes, or inf if one cannot get to the target node from the source.

View on GitHub
GitHub Stars12
CategoryDevelopment
Updated11mo ago
Forks4

Languages

C

Security Score

67/100

Audited on Apr 24, 2025

No findings