⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graph1.h

📁 这个是我的大学作业哦 里面有些很经典的代码 出自清华大学的数据结构课本
💻 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 + -