DFS g int visitedMAXVERTICES FALSE dfsmatGraph Type g
- Slides: 22
DFS 코드 (인접 행렬) *g로 전달되지 않음에 유의할 것 int visited[MAX_VERTICES]; // FALSE로 초기화되었다고 가정 // 방문 여부를 기록 dfs_mat(Graph. Type g, int v) int w; visited[v] = TRUE; for (w = 0; w < g. n; w++) do #define MAX 50 typedef struct graph. Type { int n; // 정점 개수 int adj. Mat[MAX]; // 인접 행렬 } graph. Type repeat 0 end dfs_mat 8
DFS 코드 (인접 리스트) int visited[MAX_VERTICES]; // FALSE로 초기화되었다고 가정 dfs_list(Graph. Type g, int v) Graph. Node *w; visited[v] = TRUE; for (w = g. adj. List[v]; w != NULL; w = w. link) do repeat dfs_list #define MAX 50 typedef struct graph. Node { int vertex; // 정점 struct graph. Node *link; } graph. Node; typedef struct graph. Type { int n; // 정점 개수 graph. Node * adj. List[MAX]; } graph. Type; 9
BFS 알고리즘(2) bfs(v: vertex) visited[v] = true; init. Queue(q); // q is a queue add. Queue(q, v); while (not is_empty(q)) do repeat end bfs 14
BFS 코드 (인접 행렬) int visited[MAX_VERTICES]; // FALSE로 초기화되었다고 가정 bfs_mat(Graph. Type g, int v) int w; Queue. Type q; init(&q); visited[v] = TRUE; enqueue(&q, v); while (!is. Empty(q)) do repeat end bfs_mat #define MAX 50 typedef struct graph. Type { int n; // 정점 개수 int adj. Mat[MAX]; // 인접 행렬 } graph. Type 15
BFS 코드 (인접 리스트) int visited[MAX_VERTICES]; // FALSE로 초기화되었다고 가정 bfs_list(Graph. Type g, int v) Graph. Node *w; Queue. Type q; init(&q); visited[v] = TRUE; enqueue(&q, v); while (!is. Empty(q)) do repeat end bfs_list #define MAX 50 typedef struct graph. Node { int vertex; // 정점 struct graph. Node *link; } graph. Node; typedef struct graph. Type { int n; // 정점 개수 graph. Node * adj. List[MAX]; } graph. Type; 16
연결 성분 찾기 알고리즘 n 다음 그래프에 대해서 알고리즘을 적용한 결과는? void find_connected_component(Graph. Type g) Visited[] 원소 값이 true/false가 아닌 counter 값 저장 counter는 전 역 변수 int v; // visited[] = {0}으로 초기화되었다고 가정 count = 0; for(v=0; v<g. n; v++) do// 각 정점에 대해서 repeat end find_connected_component 22
- Int sum(int a int n) int sum=0 i
- Int max(int x int y)
- Inheritance calculator
- Public void drawsquare(int x, int y, int len)
- Divideint
- Interface myinterface int foo(int x)
- Int main int argc char argv
- 7팩토리얼
- Arduino int to const char
- Int main int num 4
- Void swap
- Int f(int n)
- Max int
- Include
- True or false true or false
- True/false
- Declare an array alpha of 15 elements of type int
- Bfs time complexity
- Dfs strongly connected components
- Arne kutzner
- Hdfs ls
- Xkcd dfs