This is a small C project implementing an ant colony optimization approach to find a short path in a weighted graph.
The program loads a graph from a text file, runs the ant colony simulation, displays the graph with SDL2, and writes the final pheromone state to graph_result.txt.
This project was originally written in 2022 as a school project
On Ubuntu/Debian:
sudo apt update
sudo apt install build-essential libsdl2-devThe project uses:
gccmakeSDL2- the math library (
libm)
From the project root:
makeThis creates the main executable.
To remove build outputs:
make clean./mainThe SDL window shows the graph while the algorithm is running.
Controls:
- Press
Escapeonce to stop the computation. - Press
Escapeagain to close the program after the result is printed.
After the run, the program writes the result to:
graph_result.txt
This file is generated locally and is intentionally ignored by Git.
The current input graph is hardcoded in main.c:
file_to_matrix_graph("graph_files/directed_graph/graph_file");The start and finish nodes are also hardcoded:
int start = 0;
int finish = 7;To run the algorithm on another graph, edit these values in main.c.
Graph files are stored in:
graph_files/
The first line is the graph size. The following lines are the adjacency matrix. A value of 0 means there is no edge between two nodes.
The algorithm expects a connected directed or undirected graph with positive edge weights.
The project currently focuses on the original interactive SDL visualization rather than command-line arguments or a packaged API.
