0% found this document useful (0 votes)
37 views2 pages

"General - IO - HPP" "General - Defs - HPP" "Maxchordal - Subgraph - HPP"

This C++ program uses MPI (Message Passing Interface) to parallelize finding the maximal chordal subgraph of an undirected graph. It takes a graph file as input, optionally makes the graph undirected, distributes the graph rows to processors, computes the chordal subgraph locally on each processor, and collects the results. It includes header files for general I/O, definitions, and the maximal chordal subgraph algorithm. The main function initializes MPI, reads the input graph, distributes rows to processors, computes the subgraph, and gathers results.

Uploaded by

Ruchi Kaur
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views2 pages

"General - IO - HPP" "General - Defs - HPP" "Maxchordal - Subgraph - HPP"

This C++ program uses MPI (Message Passing Interface) to parallelize finding the maximal chordal subgraph of an undirected graph. It takes a graph file as input, optionally makes the graph undirected, distributes the graph rows to processors, computes the chordal subgraph locally on each processor, and collects the results. It includes header files for general I/O, definitions, and the maximal chordal subgraph algorithm. The main function initializes MPI, reads the input graph, distributes rows to processors, computes the subgraph, and gathers results.

Uploaded by

Ruchi Kaur
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include "general_IO.

hpp"
#include "general_defs.hpp"
#include "maxchordal_subgraph.hpp"
#include <iostream>
#include <mpi.h>

using namespace std;

//Algorithm to Find the Maximal Chordal Subgraph in an Undirected Graph


int main(int argc, char *argv[])
{
int id; //Id of processor
int p; //Number of processors
int row_index=0;
float total_edge_wt; //Total weight of all edges
int b[500000];
MPI_Status status;
int fst;
double elapsed_time;
{

( argv[1] );
if ( !the_file.is_open() )
{
cout<<"Could not open file\n";
MPI_Abort(MPI_COMM_WORLD, MPI_ERR_ARG);
}

int m=atoi(argv[2]); //number of nodes


fst=atoi(argv[3]);
int undirected=atoi(argv[4]);
if(undirected==0) //Make the graph undirected
{
make_undirected(argv[1]);
cout << "before input \n";
row_index=graph_input("input.txt",fst,m,p,Allrows);
}
else
{
cout << "before input X\n";
row_index=graph_input(argv[1],fst,m,p,Allrows);
}
}
if(p>0)
{
MPI_Recv(&row_index,1, MPI_INT,0, 001, MPI_COMM_WORLD, &status);
MPI_Recv(&b, row_index, MPI_INT,0, 010, MPI_COMM_WORLD, &status);
}
MPI_Bcast(Allrows,p,MPI_INT,0,MPI_COMM_WORLD);
CSR C;
vector<int> myvals;
for(int k=0;k<row_index;k++)
{
myvals.push_back(b[k]); //Insert an element at the end of the
container (for 1D vectors/arrays).
}
create_CSR(myvals,&C);

You might also like