首页 > 其他 > 详细

图的存储与遍历

时间:2021-06-15 16:13:32      阅读:11      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <vector>
using namespace std;

const int N=1e5+10,M=1e5+10;
int n,m,x,y,w;
bool v[N];
vector< pair<int,int> > head[N];

void dfs(int t){
	for(int i=0;i<head[t].size();i++){
		if(v[head[t][i].first]) continue;
		v[head[t][i].first]=true;
		dfs(head[t][i].first);
	}
}

int main() {
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x>>y>>w;
		head[x].push_back(make_pair(y,w));
	}
	
    return 0;
}

图的存储与遍历

原文:https://www.cnblogs.com/syqwq/p/14885024.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!