正在加载图片...
73.1相邻矩阵 【代码72】图的基类 class Edge i ∥边类 public int from,to, weight;∥from是边的始点to是终点, weight是边的权 edge i ∥缺省构造函数 from=-1; to=-1; weight=0; Edge(int f, int t, int w)( ∥给定参数的构造函数 from =f; to=t; weight=w; class graph i public: int num Vertex: ∥图中顶点的个数 int numEdge; ∥图中边的条数 int marks ∥标记图的顶点是否被访问过 int *Indegree; ∥存放图中顶点的入度 Graph(int num vert)i ∥图的构造函数 num Vertex num Vert num edge=0 “十一五”国家缀规划教材。张铭,王腾蛟,赵海£,《飙据结构与算法》,高教社,B0.6。“十一五”国家级规划教材。张铭,王腾蛟,赵海燕,《数据结构与算法》,高教社,2008. 6。 7.3.1 相邻矩阵 【代码7.2】 图的基类 class Edge { // 边类 public: int from, to, weight; // from是边的始点,to是终点,weight是边的权 Edge() { // 缺省构造函数 from = -1; to = -1; weight = 0; } Edge(int f,int t,int w) { // 给定参数的构造函数 from = f; to = t; weight = w; } }; class Graph { public: int numVertex; // 图中顶点的个数 int numEdge; // 图中边的条数 int *Mark; // 标记图的顶点是否被访问过 int *Indegree; // 存放图中顶点的入度 Graph(int numVert) { // 图的构造函数 numVertex = numVert; numEdge = 0;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有