Skip to content

Commit 165437d

Browse files
committed
Fixed readme
1 parent 7beb300 commit 165437d

4 files changed

Lines changed: 34 additions & 12 deletions

File tree

1/dijkstra.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
using ListItem = std::pair<uint32_t, uint16_t>;
88
using Graph = std::vector<std::vector<std::pair<uint32_t, uint16_t>>>;
99

10-
template <size_t K> class MinHeap {
11-
public:
10+
template <size_t K>
11+
class MinHeap {
12+
public:
1213
constexpr explicit MinHeap(size_t max_nodes) : node_indexes(max_nodes, UINT32_MAX) {}
1314

1415
[[nodiscard]] constexpr bool empty() const { return heap.empty(); }
@@ -45,7 +46,7 @@ template <size_t K> class MinHeap {
4546
size_t sift_down_count = 0;
4647
size_t sift_up_count = 0;
4748

48-
private:
49+
private:
4950
constexpr void sift_down(size_t index) {
5051
using namespace std;
5152

@@ -102,7 +103,8 @@ struct Result {
102103
size_t sift_down = 0;
103104
};
104105

105-
template <size_t K> Result dijkstra(const Graph &graph, uint32_t origin, uint32_t destination) {
106+
template <size_t K>
107+
Result dijkstra(const Graph& graph, uint32_t origin, uint32_t destination) {
106108
using namespace std;
107109

108110
auto n = graph.size();

1/main.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#include "dijkstra.hpp"
21
#include <iostream>
32
#include <sstream>
43
#include <string>
4+
#include "dijkstra.hpp"
55

66
using namespace std;
77

8-
int main(int argc, char *argv[]) {
8+
int main(int argc, char* argv[]) {
99
if (argc < 3) {
1010
cerr << "Usage: dijkstra <origin> <destination>\n";
1111
return EXIT_FAILURE;
@@ -37,9 +37,7 @@ int main(int argc, char *argv[]) {
3737
}
3838
}
3939

40-
41-
4240
auto result = dijkstra<2>(graph, origin, destination);
4341

4442
return EXIT_SUCCESS;
45-
}
43+
}

1/scaling_dijkstra.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "mimalloc-new-delete.h"
21
#include "dijkstra.hpp"
2+
#include "mimalloc-new-delete.h"
33

44
#include <chrono>
55
#include <iostream>
@@ -64,4 +64,4 @@ int main() {
6464
cout << "Average duration: " << avg_duration << '\n';
6565

6666
return EXIT_SUCCESS;
67-
}
67+
}

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
# advanced_algorithms
1+
# Advanced Algorithms
2+
3+
This repository is for the Advanced Algorithms course, thaught by professor Marcus Ritt at UFRGS. It is divided upon 5 tasks, corresponding to directories listed here. All of them were implemented in C++.
4+
5+
## Task 1
6+
7+
Implements the Disjkstra algorithm using a min heap and tests it with varios lenghts of heaps.
8+
9+
## Task 2
10+
11+
Implements BFS, DFS and the fastest path algorithm and compares them when tracing a path between two vertices.
12+
13+
## Task 3
14+
15+
Implements the max flow algorithm to solve the tournament problem.
16+
17+
## Task 4
18+
19+
Implements the Hungarian algorithm that solves the assignment problem.
20+
21+
## Task 5
22+
23+
Solves the knapsack problem using DP and the algorithm proposeed by He & Xu (https://epubs.siam.org/doi/10.1137/1.9781611977936.6), comparing the number of updates required.

0 commit comments

Comments
 (0)