AdjacencyMatrix

This commit is contained in:
e2hang
2025-08-28 13:45:08 +08:00
parent 357d37b72a
commit b97f348a51
4 changed files with 206 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#pragma once
#include "vertexIterator.h"
template <class T>
struct edge {
int from, to;
T weight;
edge(int _from, int _to, T _weight) : from(_from), to(_to), weight(_weight) {}
};
template <class T>
class Graph {
public:
virtual ~Graph() {}
//ADT Methods
virtual int numberOfVertices() const = 0;
virtual int numberOfEdges() const = 0;
virtual bool existsEdge(int, int) const = 0;
virtual void insertEdge(edge<T>*) = 0;
virtual int degree(int) const = 0;
virtual int inDegree(int) const = 0;
//Other Methods
virtual bool directed() const = 0; //<2F><><EFBFBD><EFBFBD>ͼ
virtual bool weighted() const = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩͼ
virtual vertexIterator<T>* iterator(int) = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
};