Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
π λ¬Έμ λ§ν¬
2150λ² Strongly Connected Component
β¨ λ¬Έμ νμ΄
SCC, κ°ν μ°κ²° μμλ μ ν₯ κ·Έλνμμ λͺ¨λ μ μ μ΄ λͺ¨λ λ€λ₯Έ μ μ μ λν΄ λλ¬ κ°λ₯ν κ²½μ°λ₯Ό λ»νλ€.
μ λ°©ν₯ κ·Έλνλ₯Ό μλ₯Ό λ€μ΄ μ€λͺ νλ©΄
{a, b, c}, {d}, {e}λ‘ κ°ν μ°κ²° μμ κ·Έλνλ₯Ό λλ μ μλ€.
aμμ bμ cλ‘ κ° μ μκ³
bμμ aμ cλ‘ κ° μ μκ³
cμμ aμ bλ‘ κ° μ μλ€
cμμ dλ‘λ κ° μ μμ§λ§ dμμ cλ‘λ λͺ»κ°λ€.
μ΄λ°κ²λ€μ μ½ν μ°κ²°μ΄λΌκ³ νλ€.
μ£Όμ΄μ§ λ°©ν₯ κ·Έλνμμ SCCλ₯Ό ꡬνλ μκ³ λ¦¬μ¦μΌλ‘ Kosaraju(μ½μ΄λΌμ£Ό)μ Tarjan(νμ) μκ³ λ¦¬μ¦μ΄ μλ€.
μ΄ λ¬Έμ λ μ½μ¬λΌμ£Ό μκ³ λ¦¬μ¦μ νμλ€.
μ£Όμ΄μ§ λ°©ν₯ κ·Έλνμ μλ°©ν₯ κ·Έλνμ μ€νμ μ¬μ©νμ¬ SCCλ₯Ό ꡬνλ μκ³ λ¦¬μ¦μ΄λ€.
μ΄ μκ³ λ¦¬μ¦μ μλ°©ν₯ κ·Έλν(λͺ¨λ κ°μ λ€μ λ°©ν₯μ λ€μ§μ κ·Έλν)κ° μλ κ·Έλνμ μ νν κ°μ κ°ν μ°κ²° μμλ₯Ό κ°λλ€λ μ¬μ€μ μ΄μ©νλ€.
β μ£Όμ΄μ§λ λ°©ν₯ κ·Έλνμ κ·Έ κ·Έλνμ μλ°©ν₯ κ·Έλνλ₯Ό λ§λ λ€.
β‘ μ μ μ λ΄μ μ€νμ λ§λ€κ³ μμμ μ μ λΆν° λ°©ν₯ κ·Έλνμμ DFSλ₯Ό μννλ€.
β’ DFSκ° λλλ μμλλ‘ μ€νμ μ½μ νκ³ , μμ§ λ°©λ¬Ένμ§ μμ μ μ μ λν΄ DFSλ₯Ό μννλ€.
β£ λͺ¨λ μ μ μ΄ μ€νμ λ΄κΈ΄ νμλ μ€νμ popνμ¬ λμ€λ μ μ μ€ λ°©λ¬Ένμ§ μμ μ μ μ μλ°©ν₯ κ·Έλνμμ DFSλ₯Ό μννλ€.
β€ μ΄λ νμλλ λͺ¨λ μ μ μ SCCλ‘ λ¬Άλλ€.
μ΄κ²μ μ€νμ΄ λΉ λκΉμ§ μ§ννλ€
μμ μ€λͺ
μλμ κ°μ κ·Έλνκ° μλ€.
μ€ν, μλ°©ν₯ κ·Έλνλ₯Ό λ§λ€μ΄ μ€λ€.
μ£Όμ΄μ§ λ°©ν₯ κ·Έλνμμ DFS
κ·Έλ¬λ©΄
d, g, c, b, a, f, h, e μμλλ‘ μ€νμ λ€μ΄κ°λ€.
μ€νμμ popνλ©΄μ μλ°©ν₯ κ·Έλνμμ dfs
κ²°κ³Ό
μλμ κ°μ 3κ°μ κ·Έλ£Ήμ΄ λ§λ€μ΄ μ§λ€.!