#include <stdio.h>
#include <stdlib.h>
#include <string.h> /* for debugging */
#include <mpi.h>
#include<iostream>
#include<fstream>
#include<typeinfo>
#include <ctime>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<unistd.h>
#include <cstdlib>
#include <vector>
using namespace std;
#define INFINITY 10000
#define n 200 //顶点数
void Read_matrix(int local_mat[], int my_rank, int p,MPI_Comm comm);
void Print_matrix(int local_mat[], int my_rank, int p,MPI_Comm comm);
void Write_file(int local_mat[], int my_rank, int p, MPI_Comm comm);
void Floyd(int local_mat[], int my_rank, int p, MPI_Comm comm);
int Owner(int k, int p);
void Copy_row(int local_mat[], int p, int row_k[], int k);
void Ping(int *result,int flag[5]) {
char line[300];
FILE *fp;
string cmd = "cat /home/mpiuser/mpich/servers";
const char *sysCommand = cmd.data();
if ((fp = popen(sysCommand, "r")) == NULL) {
cout << "error" << endl;
return;
}
int row = 0;
int node[4]={0};
while (fgets(line, sizeof(line) - 1, fp) != NULL) {
if(line[4]!=' '){
node[row]=line[4]-48; //ascii码的数字(0)从48开始
}
row++;
}
pclose(fp);
//int flag[5]={0};
int alive=0;
for (int i = 0; i < 4; i++) {
if (node[i] != 0) {