这是AdjMatrix.h文件
#pragma once
#include <iostream>
#include <fstream>
#include <cassert>
#include <list>
using namespace std;
class AdjMatrix
{
private:
int V;
int E;
int** adj;
private:
void validateVertex(int v) {
if (v < 0 || v >= V) {
string str = ("vertex" );
str.append("" + v);
str.append("is invalid");
cout << str << endl;
}
}
public:
AdjMatrix(string filename) {
ifstream infile;
infile.open(filename.data()); //将文件流对象与文件连接起来
assert(infile.is_open()); //若失败,则输出错误消息,并终止程序运行
char c;
infile >> c;
V = c - '0';
infile >> c;
E = c - '0';
adj = new int* [V];// 动态申请一个二维数组
for (int i = 0; i < V; ++i) {
adj[i] = new int[V];
fo