exam8-1.cpp

来自「数据结构c++-书的一些源代码」· C++ 代码 · 共 31 行

CPP
31
字号
#include <iostream.h>
#include <stdlib.h>

typedef char VerT;						//定义邻接矩阵图类中的VerT
typedef char DataType;					//定义顺序表类中的DataType
const int MaxVertices = 100;			//定义最大顶点个数
const int MaxWeight = 10000;			//定义权值的无穷大
//const int MaxQueueSize = 10000;

#include "AdjMWGraph.h"					//包含邻接矩阵的图类
#include "CreatAdjMWGraph.h"			//包含邻接矩阵图的创建函数

void main(void)
{
	AdjMWGraph g;
	char a[] = {'A','B','C','D','E'};
	RowColWeight rcw[] = {{0,1,10},{0,4,20},{1,3,30},{2,1,40},{3,2,50}};
	int n = 5, e = 5;

	CreatGraph(g, a, n, rcw, e);		//创建图8-8

	cout << "顶点个数为:" << g.NumOfVertices() << endl;
	cout << "边的条数为:" << g.NumOfEdges() << endl;

	g.DeleteVertex(3);					//删除顶点3
	g.DeleteEdge(0, 4);					//删除边<0, 4>

	cout << endl << "顶点个数为:" << g.NumOfVertices();
	cout << endl << "边的条数为:" << g.NumOfEdges()<< endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?