The project focuses on solving and analyzing several problems related to graphs and digraphs using techniques such as BFS, Union-Find, Johnson's algorithm and Bertossi's algorithm.
This assignment involves solving the following problems:
- Geodesic Graph Detection – Determine if a given connected graph is geodesic (i.e., has a unique shortest path between each pair of vertices).
- Connected Components in Sparse Matrices – Count connected components in a 0/1 matrix representing adjacency, using O(n) space.
- All-Pairs Shortest Path – Use Johnson’s algorithm to compute shortest paths in a weighted, directed graph.
- Minimum Total Dominating Set in Intervals – Solve using Bertossi's algorithm for interval graphs.
- Breadth-First Search (BFS)
- Union-Find (Disjoint Sets)
- Johnson’s Algorithm (Bellman-Ford + Dijkstra)
- Interval Graph Modeling
- Complexity analysis and empirical benchmarking
Each algorithm was tested on custom and randomized instances. All experiments were benchmarked and results aligned with the expected theoretical time complexities.
- Geodesic Graphs: Verified with cycle-based and complete graphs
- Connected Components: Space-efficient linear scans with sliding-window Union-Find
- Shortest Paths: Efficient detection of negative cycles and correct shortest-path reconstruction
- Dominating Sets: Graph reduction and pathfinding over transformed digraphs
📄 See
informe.pdf
for detailed complexity analysis, figures, tables, and graphs.
📅 Term: 2nd semester of 2022 🏫 Universidad de Buenos Aires, Facultad de Ciencias Exactas y Naturales
Inside each exercise directory, run the following commands from the console:
make
for i in ./instancias/*.txt; do echo ${i} >> ./resultados/tiempos.txt; timeout 600 ./resolucion < ${i}; done
make
echo './instancias/nombre-instancia' >> ./resultados/tiempos.txt
./resolucion < ./instancias/nombre-instancia
make clean
python generador.py
You can also compile and execute the program inside a Docker container:
From the root directory of the project:
cd <EJ>
docker build -t <EJ> .
docker run --rm -v <P>:/tp/tiempos <EJ> <I>
Where:
<EJ>
is the name of the exercise folder<P>
is the absolute path to the directory where results should be saved<I>
(optional) is the name of the specific instance to run
cd ejercicio_2
docker build -t ejercicio_2 .
docker run --rm -v C:\Users\Lucas\tp\ejercicio_2:/tp/tiempos ejercicio_2
To free up space, remove old Docker images (~1.15 GB each) with:
docker rmi <EJ> && docker image prune