Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MPI Program You are supposed to use the given template for implementing each of the problems. Additionally, your program will be given two arguments, path

MPI Program

You are supposed to use the given template for implementing each of the problems. Additionally, your program will be given two arguments, path to an input file and an output file from which your program will obtain the input and output the result into respectively, like the following (for C++): mpirun -np 11 ./a.out .

Given an undirected binary weighted graph G, find the number of cliques (of all possible weights) in the graph with sizes 3 and 4 (Refer to the sample input and output for clear understanding). Input: The first line contains two integers N and E, representing the number of vertices and the number of edges in the graph, respectively. Following E lines contain 3 integers (2 vertices and a weight) each, representing an edge between these two vertices with a binary weight (0 or 1). Note : 2 cliques are different if they have at least 1 vertex which is not common. There will be only 1 edge between any 2 vertices.

Output: Print a total of 11 lines. Each line should contain 3 space separated integers - size of clique weight of clique number of such cliques Constraints: 2 <= N <= 102, 1 <= E <= 103

Example: Sample Input: 7 11 1 2 0 2 3 0 2 4 1 3 4 0 3 5 1 1 5 1 1 6 0 6 7 1 7 5 1 7 1 0 6 5 1 1 3 0 2 5 1 2 Sample Output: 3 0 1 3 1 2 3 2 5 3 3 1 4 0 0 4 1 0 4 2 0 4 3 1 4 4 1 4 5 0 4 6 0

Code should be written in the middle of the template given below, where it is written as "Enter your code here"

# include # include using namespace std ; int main ( int argc , char ** argv ) { int rank , numprocs ; // initiate MPI MPI_Init ( &argc , & argv ); // get size of the current communicator MPI_Comm_size ( MPI_COMM_WORLD , & numprocs ); // get current process rank MPI_Comm_rank ( MPI_COMM_WORLD , & rank ); /* synchronize all processes */ MPI_Barrier ( MPI_COMM_WORLD ); double start_time = MPI_Wtime (); // enter your code here MPI_Barrier ( MPI_COMM_WORLD ); double end_time = MPI_Wtime () - start_time ; double maxTime ; // get max program run time for all processes MPI_Reduce ( & end_time , & maxTime , 1, MPI_DOUBLE , MPI_MAX , 0, MPI_COMM_WORLD ); if ( rank == 0 ) { cout <<" Total time (s): " <

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Apache Cassandra Development

Authors: Vivek Mishra

1st Edition

1484201426, 9781484201428

More Books

Students also viewed these Databases questions