📄 graph.h
字号:
#ifndef GRAPH_H#define GRAPH_H
#include <iostream.h>#define DefaultSize 20
#define NULL 0
typedef int NameType;
typedef int DistType;//template<class NameType,class DistType>class Graph;//template<class DistType>class Edge{public: friend class Graph; Edge(){} Edge(int D,DistType C):dest(D),cost(C),link(NULL) {} int operator !=(Edge &E) const { return E.dest!=dest; }private: int dest; DistType cost; Edge *link;};//template<class NameType,class DistType>class Vertex{ friend class Graph; friend class Edge; NameType data; Edge *adj;};//template<class NameType,class DistType>class Graph{private: Vertex *nodeTable; int numVertexs;
int maxNumVertexs;
int *status; int numEdges; int GetVertexPos(const NameType &ver);public: Graph(int sz); ~Graph();
friend ostream& operator<<(ostream &out,Graph &ref); int GraphEmpty()const {return numVertexs==0;} int GraphFull()const {return numVertexs==maxNumVertexs;} int NumberOfVertexs()const {return numVertexs;} int NumberOfEdges() const {return numEdges;} NameType GetValue(int i) { return i>=0 && i<numVertexs ? nodeTable[i].data : NULL; } void InsertVertex(const NameType &vertex); void InsertEdge(int v1,int v2,DistType weight); void RemoveEdge(int v1,int v2); void RemoveVertex(int v); DistType GetWeight(int v1,int v2); int GetFirstNeighbor(int v); int GetNextNeighbor(int v1,int v2);
void DFS(int start);
};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -