用向量来存储一条邻接链表,存储可连通值。实现了判断是否连通,添加边,添加顶点的功能。
UnDirectGraph.h
#pragma once
include “stdafx.h”
include
using namespace std;
class UnDirectGraph
{
private:
int vCount;
vector
public:
int GetVCount();
UnDirectGraph(int vCount);
void AddEdge(int v,int w);
vector
bool IsConnected(int v,int w);
};
UnDirectGraph.cpp
#pragma once
include “stdafx.h”
include “UnDirectGraph.h”
using namespace std;
UnDirectGraph::UnDirectGraph(int _vCount)
{
this->vCount=_vCount;
adj=new vector
for (int i=0;i<vCount;i++)
{
adj[i].clear();
}
}
void UnDirectGraph::AddEdge(int v,int w)
{
adj[v].push_back(w);
adj[w].push_back(v);
}
vector
{
return adj[v];
}
bool UnDirectGraph::IsConnected(int v,int w)
{
for (vector
{
if (*iter==w)
{
return true;
}
}
return false;
}
int UnDirectGraph::GetVCount()
{
return vCount;
}
代码还算清晰,就不解释了,相信学习C++的同学都看得懂。
罚罪1+2在哪看?罚罪1+2全80集高清未删减在线观看入口地址
韩剧再婚皇后1080p迅雷磁力链接分享-韩剧再婚皇后高清完整版迅雷云盘下载1080P(4k)资源
如果我不曾见过太阳高清无删减夸克在线看-如果我不曾见过太阳蓝光高清1080p无删减资源夸克免费转存
如果我不曾见过太阳阿里云盘全集高清1080P资源链接-如果我不曾见过太阳免费阿里云盘资源下载4K高清无删减版链接
罚罪1+2全80集阿里云盘全集资源链接-罚罪1+2全集高清1080P/4K阿里云盘资源下载无删减
邵氏精品禁品未删减资源在线看-必看的50部邵氏电影无删减观看入口