[C언어 자료구조] Undirected Graph의 Connected Components, cycle 찾기 문제 : 개념 설명 및 코드 구현


[C언어 자료구조] Undirected Graph의 Connected Components, cycle 찾기 문제 : 개념 설명 및 코드 구현

주어진 Undirected graph에 대한 adjacency matrix를 파일 in.txt로 입력 받은 뒤, 다음 문제를 수행하라. in.txt는 처음에 vertex의 개수가 주어지고 matrix의 lower diagonal부분만 표시하고 있다. < 단계 1 > 이 graph에 있는 connected component의 개수를 화면에 출력하라. < 단계 2 > 이 graph에 있는 cycle이 있으면 yes, 없으면 no를 출력하라. < 실행 예제1 > in.txt 5 1 1 1 0 0 0 0 0 0 0 < 화면 출력 > 단계 1 : 3 단계 2 : yes < 실행 예제 2 > in.txt 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 < 화면 출력 > 단계 1 : 1 단계 2 : yes < 실행 예제 3 > in.txt 7 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1 < 화면 출력 > 단계 1 : 2 단계 2 : no < 개념 설명 > ...


#ConnectedComponent #Cycle #CycleDetection #C언어 #DFS #Graph #UndirectedGraph #자료구조

원문링크 : [C언어 자료구조] Undirected Graph의 Connected Components, cycle 찾기 문제 : 개념 설명 및 코드 구현