27 lines
675 B
C++
27 lines
675 B
C++
#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; //有向图
|
|
virtual bool weighted() const = 0; //有向加权图
|
|
virtual vertexIterator<T>* iterator(int) = 0; //迭代器
|
|
}; |