-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1260_DFS와_BFS.cpp
More file actions
55 lines (42 loc) · 872 Bytes
/
1260_DFS와_BFS.cpp
File metadata and controls
55 lines (42 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
1260 DFS와 BFS
실버 II
그래프(DFS, BFS)
2022.11.15
*/
// * 간선은 양방향
// * 정점의 개수 N, 간선의 개수 M, 탐색 시작 정점 번호 V
#include <bits/stdc++.h>
using namespace std;
int N, M, V;
vector<int> adj[1001]; // vector의 배열
void bfs(n){
int v[1001];
queue<int> q;
v[n] = 1; // 시작점 방문 표시
q.push(n);
while(!q.empty()){
for(p in q[n]){
}
}
}
void dfs(n){
int v[1005];
}
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
//initialize
cin >> N >> M >> V;
for(int i=0; i<M; i++){
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
// 작은 번호부터 순회하기 위해
for(int i=1; i<=n; i++)
sort(adj[i].begin(), adj[i].end());
bfs(V);
dfs(V);
}