摘要: 使用邻接矩阵存储加权图,无穷大使用常数MAXLEN代表,然后使用Dijkstra方法求取最短路径 1 #include <stdio.h> 2 3 #define MAXLEN 1000 4 int cost[7][7]; 5 int dist[7]; 6 7 void creategraph(in 阅读全文
posted @ 2021-01-02 22:21 互联星空 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 图的深度优先搜索 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 struct node 5 { 6 int vertex; 7 struct node* nextnode; 8 }; 9 10 typedef struct node* graph; 1 阅读全文
posted @ 2021-01-02 15:24 互联星空 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 使用数组导入边创建邻接矩阵表示法的图 1 #include <stdio.h> 2 3 int matrix[6][6]; 4 5 void creategraph(int *node,int num) 6 { 7 int from; 8 int to; 9 int i; 10 11 for(i = 阅读全文
posted @ 2021-01-02 01:21 互联星空 阅读(329) 评论(0) 推荐(0) 编辑