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

📄 algraph.h

📁 树的操作中的邻接表。。解压即可。。直接上交
💻 H
字号:
// 有向图
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -