运行结果正确
输出路径顶点竟然花了我最多的时间。。。。。。
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include<malloc.h>
//邻接矩阵表示图
typedef struct g_node *g_point;
struct g_node{
int ne;//边数
int nv;//节点数
int arr[100][100];
int data[100];
};
//边的数据结构
typedef struct e_node *e_point;
struct e_node{
int v1;
int v2;
int weight;
};
//遍历一个邻接矩阵的图
void tra_g(g_point g,int n){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
printf("%d ",g->arr[i][j]);
}
printf("\n");
}
}
//创建一个空图
void init(g_point &g,int v_num){
g=(g_point)malloc(sizeof(struct g_node));
g->nv=v_num;
g->ne=0