Arian Soleimanzadeh
  • 홈
  • 블로그
  • 팟캐스트
  • 비디오
  • 라이브러리
  • 문의
العربيةArabic
DeutschGerman
EnglishEnglish
فارسیPersian
한국어Korean
中文Chinese
패널•빠른 문의

Languages

Choose your interface locale

ar

العربية

Arabic

de

Deutsch

German

en

English

English

fa

فارسی

Persian

ko

한국어

Korean

zh

中文

Chinese

상담 예약

짧은 메시지를 남겨주세요 — 가능한 한 빠르게 답변드리겠습니다.

LinkedIn빠른 응답
홈/아티클/그래프 Cycle Detection: DFS, Union-Find와 Kahn
AlgorithmsGraph Algorithms아티클

그래프 Cycle Detection: DFS, Union-Find와 Kahn

Directed와 Undirected Graph에서 DFS 상태, Parent Tracking, Union-Find, Kahn을 사용한 Cycle Detection을 설명합니다.

2026년 8월 21일9 분 읽기16 조회수
#Graph#Algorithms#Cycle Detection#DFS#Union-Find#JavaScript#TypeScript

Arian Soleimanzadeh

Software Engineer & Researcher

그래프 Cycle Detection 시각 가이드

Arian Soleimanzadeh

AI · 코드 · 제품

연구 + 엔지니어링
이 페이지에서
방향 그래프무방향 그래프Kahn AlgorithmUnion-Find실제 활용Floyd복잡도정리

Cycle Detection은 현재 탐색 경로에 이미 포함된 정점으로 다시 돌아갈 수 있는지 확인하는 문제입니다.

Dependency Graph, Workflow, Build System, DAG Validation에서 매우 중요합니다.

방향 그래프

보통 세 상태를 사용합니다.

Code
123
0 = unvisited
1 = visiting
2 = finished

visiting 상태의 정점으로 가는 Edge는 Back Edge이며 Cycle을 의미합니다.

무방향 그래프

Parent를 추적해야 합니다.

방문한 이웃이 현재 정점의 Parent라면 Cycle이 아닙니다.

Code
12
visited neighbor != parent
→ cycle

Kahn Algorithm

Topological Sort 과정에서 모든 정점을 처리하지 못하면 Directed Graph에 Cycle이 존재합니다.

Union-Find

Undirected Graph에서 새로운 Edge의 두 끝점이 이미 같은 Set에 있다면 그 Edge는 Cycle을 만듭니다.

실제 활용

  • Circular Dependency
  • Package Dependency
  • Workflow Validation
  • Course Prerequisite
  • Build Graph
  • Spreadsheet Circular Reference
  • Service Dependency

Floyd

Floyd Cycle Detection은 일반 그래프보다는 Linked List나 Functional Graph에 적합합니다.

복잡도

DFS와 Kahn:

Code
1
O(V + E)

정리

Directed Graph는 recursion state가 핵심이고, Undirected Graph는 Parent tracking 또는 Union-Find가 핵심입니다.

이 페이지에서
방향 그래프무방향 그래프Kahn AlgorithmUnion-Find실제 활용Floyd복잡도정리

아티클 정보

게시 정보, 읽기 시간 및 조회 데이터입니다.

게시일

2026년 8월 21일

업데이트

2026년 11월 2일

읽기 시간

9 분 읽기

조회수

16

작성자

Arian Soleimanzadeh

이전 아티클

Depth-First Search(DFS): 깊이 우선 탐색의 기초부터 실전까지

다음 아티클

그래프 Connected Components: DFS, BFS와 Union-Find

Arian Soleimanzadeh

현대적인 웹 엔지니어링, UI 시스템, 실용적인 AI 제품에 집중한 개인 포트폴리오 — 깨끗한 코드, 명확한 디자인.

빠른 링크

  • 소개
  • 블로그
  • 라이브러리
  • 문의

문의

  • soleimanzadeh.a.work@gmail.com
  • soleimanzadeh.uni@gmail.com

가능 시간: 평일

보통 다음 시간 내에 답변합니다 24시간.

뉴스레터

글, 프로젝트, 새 릴리스에 대한 업데이트를 받아보세요.

© 2026 ariansoleimanzadeh.dev — 모든 권리 보유.

LinkedIn