#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TRUE 1
#define FALSE 0
#define MAX_VERTEX_NUM 6
typedef int* Type;
typedef int Status;
//邻接矩阵
typedef struct ArcCell{
int adj;
}ArcCell, AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];
//每个十进制数转换四位二进制
void convert(char* num,Type &stuNo){
int i,j,k,t;
int length = strlen(num);
for(i = 0;i<length;i++){
t = num[i]-'0'; //将字符变成数字
k = 0;
for(j=3; j>=0; j--){
stuNo[4*i+k] = (t>>j)&1;
k++;
}
}
}
void ReachableMatrix(Type stuNo,AdjMatrix &A,AdjMatrix &G){
int i,j,k,n;
int m = 0;
AdjMatrix An,Bn; // An,Bn交替求矩阵的幂
//邻接矩阵初始化
for(i=0;i<MAX_VERTEX_NUM;i++){
for(j=0;j<MAX_VERTEX_NUM;j++){
A[i][j].adj = stuNo[m];
An[i][j].adj = stuNo[m];
G[i][j].adj = stuNo[m];
m++;
}
}
//求可达矩阵
离散数学判断图的连通性
最新推荐文章于 2025-03-22 23:40:22 发布