Skip to content
Snippets Groups Projects
Commit 189c8cf3 authored by 13518104 Kevin Austin Stefano's avatar 13518104 Kevin Austin Stefano
Browse files

quick sort with openmpi main done

parent f7357763
Branches
No related merge requests found
......@@ -43,9 +43,9 @@ void makeStruct(MPI_Datatype *mpi_edge_type)
//Connect
MPI_Type_create_struct(3, block, offset, types, &(*mpi_edge_type));
MPI_Type_commit(&(*mpi_edge_type));
}
}
// Create new Graph based on V vertices and E edges
......@@ -296,6 +296,38 @@ int compare_src(const void *a, const void *b)
return a1->src > b1->src;
}
void PreQuickSort (Edge result[], int size, int rank) {
if (rank==0) {
//Implementasi quicksort disini
} else {
MPI_Datatype mpi_edge_type;
makeStruct(&mpi_edge_type);
int idxcnt = 0;
Edge arr;
MPI_Status status;
while (rank >= pow(2, idxcnt)) {
idxcnt = idxcnt+1;
}
int source = MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
source = MPI_Get_count(&status, mpi_edge_type, &arr);
int src = status.MPI_SOURCE;
temp = (Edge *) malloc (sizeof(Edge) *arr);
source = MPI_Recv(temp, arr, mpi_edge_type, src, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
//Impementasiquicksort disini
source = MPI_Send(temp, arr, mpi_adge_type, src, 1, MPI_COMM_WORLD);
free(arr);
}
}
// Minimum Spanning Tree using Kruskal's Algorithm
void KruskalMST(Graph *graph, Edge result[], int *e, int size, int rank)
{
......@@ -304,8 +336,10 @@ void KruskalMST(Graph *graph, Edge result[], int *e, int size, int rank)
// Step 1: Sort all the edges into correspendent sorted edges
// bubbleSort(graph->edge, graph->E, 1);
QuickSortWeight(graph->edge, 0, graph->E, size, rank);
// QuickSortWeight(graph->edge, 0, graph->E, size, rank);
// Step 2: Allocate memory for creating V subsets
Subset *subsets = CreateSubset(V);
......@@ -322,7 +356,7 @@ void KruskalMST(Graph *graph, Edge result[], int *e, int size, int rank)
}
}
QuickSortSrc(graph->edge, 0, graph->E, size, rank);
// QuickSortSrc(graph->edge, 0, graph->E, size, rank);
return;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment