ProgramAlgTrain/20240919/CSP常考算法模板/最小生成树/最小生成树_Prim(稠密图)..cpp

63 lines
838 B
C++
Raw Normal View History

2024-09-19 02:22:41 +00:00
#include <bits/stdc++.h>
using namespace std;
struct edge {
int to, w;
} a[10001];
int dis[101];
int ans, cnt;
vector<edge> graph[101];
bool visit[101];
struct cmp //<2F>º<EFBFBD><C2BA><EFBFBD>
{
bool operator()(const edge &a, const edge &b) {
return a.w > b.w;
}
};
priority_queue<edge, vector<edge>, cmp> pq;
int main() {
int n,m,k;
cin>>n>>m;
for (int j = 1; j <= m; j++) {
int a,b,c;
cin>>a>>b>>c;
graph[a].push_back({b,c});
graph[b].push_back({a,c});
}
for (int i = 1; i <= n; i++) {
dis[i]=INT_MAX/2;
}
visit[1]=true;
for(int i=0;i<graph[1].size();i++)
{
edge e=graph[1][i];
dis[e.to]=e.w;
}
pq.push({1, 0});
while (!pq.empty()) {
//todo
}
cout << ans << endl;
return 0;
}
/*
6 9
2 4 11
3 5 13
4 6 3
5 6 4
2 3 6
4 5 7
1 2 1
3 4 9
1 3 2
*/