📄 graph1.h
字号:
#ifndef GRAPH1_H
#define GRAPH1_H
//****************
#include<iostream>
using namespace std;
//***********************
const int DefaultSize = 6;
template <class NameType, class DistType> class Graph;
//------------------------------------------------------------
template <class DistType> class Edge {
friend class Graph <class NameType, DistType>;
int dest;
public:
Edge<DistType> *link;
Edge(int D):dest(D),link(NULL){}
Edge<DistType> * Getlink(){return link;}
void Value(int S){dest = S;}
int Getdest(){return dest;}
};
//--------------------------------------------------------
template <class NameType,class DistType> class Vertex {
friend class Graph <NameType, DistType>;
friend class Edge <DistType>;
NameType data;
Edge<DistType> *adj;
public:
Vertex():adj(NULL){};
};
//--------------------------------------------------------------
template <class NameType,class DistType> class Graph {
Vertex <NameType,DistType> * NodeTable;
int *count1;
int *count2;
int NumVertex;
int NumEdge;
int GetVertexPos(const NameType &vertex);
void DFS(int v,int visited[]);
public:
Graph(int sz);
void InsertVertex(NameType & vertex);
void InsertEdge(int v1,int v2);
void Count();
int GetFirstNeighbor(int v);
int GetNextNeighbor(int v1,int v2);
void DFS();
void BFS(int v);
void TopologicalSort();
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -