其他分享
首页 > 其他分享> > 图的存储与遍历

图的存储与遍历

作者:互联网

#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;
}

标签:10,存储,遍历,int,head,1e5,pair,include
来源: https://www.cnblogs.com/syqwq/p/14885024.html