邻接矩阵实现如下: /* 主题:用邻接矩阵实现 DFS(递归) 与 BFS(非递归) 作者:Laugh 语言:C++ ******************************************* 样例输出如下: 请选择图的类型(a - 无向图, b - 有向图):a 请输入总顶点数,总边数:8 9 请依次输入点的信息:a b c d e f g h 输入一条边依附的顶点及权值 (eg: a b 6): a b 1 a c 1 b d 1 b e 1 d h 1 e h 1 c f 1
Description A number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list of schools to which it distributes software (the "receiving schools"). Note that if B is in the
import java.util.*; public class Main{ static int MAX_VERTEXNUM = 100; static int [] visited = new int[MAX_VERTEXNUM]; public static void main(String [] args){ Graph G = new Graph(); creatGraph(G); output(G); for(int i=0;i<G.vertex_num;i++) visited[i