algraph.h
来自「树的操作中的邻接表。。解压即可。。直接上交」· C头文件 代码 · 共 47 行
H
47 行
// 有向图
#ifndef ALGraph_H
#define ALGraph_H
#include <vector>
#include <string>
#include <iostream>
#include <queue>
using namespace std;
struct Edge
{ int v1,v2;
double weight;
};
struct ArcNode
{ int adjvex;
double weight;
ArcNode *nextarc;
};
template<class T>
struct VexNode
{ T data;
ArcNode *firstarc;
};
template<class T>
class ALGraph
{ int m_N;
vector<VexNode<T> > m_Data;
public:
ALGraph(vector<T> vs);
~ALGraph();
void Append(vector<Edge> &es);
void Output();
int OutDegree(int i);
int InDegree(int i);
vector<T> DFSTraverse();
vector<T> BFSTraverse();
private:
void Clear(ArcNode *head);
void DoDFSTraverse(int v,vector<bool>& visited,vector<T>& vs);
void DoBFSTraverse(int v,vector<bool>& visited,vector<T>& vs);
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?