Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
joaotgouveia committed Jan 1, 2023
1 parent a06cbf2 commit b466554
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/p2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct graph_t {

void make_set(graph_t* graph, int x) {
graph->parents[x] = x;
graph->ranks[x] = 0;
}

int find_set(graph_t* graph, int x) {
Expand Down Expand Up @@ -74,12 +75,11 @@ void radix_sort(graph_t* graph, int d_count) {
}

size_t get_maximum_cost_spanning_tree(graph_t* graph, int d_count) {
int i;
size_t result = 0;

radix_sort(graph, d_count);

while ((i = --graph->size) > -1) {
for (int i = graph->size - 1; i > -1; i--) {
if (find_set(graph, graph->data[i].u) != find_set(graph, graph->data[i].v)) {
node_union(graph, graph->data[i].u, graph->data[i].v);
result += graph->data[i].weight;
Expand All @@ -96,7 +96,7 @@ void read_input(graph_t *graph, size_t& max) {

max = 0;
graph->parents = std::vector<int>(v_count);
graph->ranks = std::vector<int>(v_count, 0);
graph->ranks = std::vector<int>(v_count);

for (int i = 0; i < e_count; i++) {
std::cin >> id1 >> id2 >> weight;
Expand Down

0 comments on commit b466554

Please sign in to comment.