- node js
- springμΌλ‘ https μ μ©
- Quick Sort
- merge sort
- SSL
- κ΅¬κΈ μμ λ‘κ·ΈμΈ
- Rp2κΈ°
- java error
- RP 2κΈ°
- μμ€ν μννΈμ¨μ΄
- spring μμ λ‘κ·ΈμΈ
- 리λ μ€ λͺ λ Ήμ΄
- @CreatedDate
- Unity
- MethodArgumentNotValidException
- MAKE US
- datagrip
- C++
- mysql
- OpenAPI
- Java
- DATABASE
- Data Structure
- GIT
- ν¨μ€νΈμΊ νΌμ€XμΌλμ
- docker
- spring κ΅¬κΈ μμ λ‘κ·ΈμΈ
- aligoapi
- SQL
- Spring
YS's develop story
Graph (κ·Έλν) μ 리 λ³Έλ¬Έ
π¨πΌπ» Graph (κ·Έλν) μ 리 With Python
π₯ Graph λ?
μ€μ μΈκ³μ νμμ΄λ μ¬λ¬Όμ Vertex(μ μ )μ Edge(κ°μ )λ‘ νννκΈ° μν΄ μ¬μ©ν©λλ€.
Vertex : μμΉλ₯Ό λ§ν©λλ€. NodeλΌκ³ νκΈ°λ ν©λλ€.
Edge : μμΉ κ°μ κ΄κ³λ₯Ό νμν μ μ λλ€.
Degree : λ°©ν₯μ΄ μλ κ·Έλνμμ νλμ μ μ μ μΈμ ν μ μ μ μμ λλ€.
Simple Path : μ²μ μ μ κ³Ό λ μ μ μ μ μΈνκ³ μ€λ³΅λ μ μ μ΄ μλ κ²½λ‘μ λλ€. (A-B-Cλ Simple Path)
Cycle : Simple Pathμ μμ μ μ κ³Ό μ’ λ£ μ μ μ΄ λμΌν κ²½μ°μ λλ€.
π κ·Έλνμ μ’ λ₯
Undirected Graph
λ°©ν₯μ΄ μλ κ·Έλνμ λλ€.
Edgeλ₯Ό ν΅ν΄ Vertex μ λ°©ν₯μΌλ‘ κ° μ μμ΅λλ€.
Directed Graph
λ°©ν₯μ΄ μλ κ·Έλνμ λλ€.
Weighted Graph
Edgeμ λΉμ© λλ κ°μ€μΉκ° ν λΉλ κ·Έλνμ λλ€.
Connected Graph λλ Disconnected Graph
Connected Graph
Undirected Graphμ μλ λͺ¨λ λ Έλμ λν΄ νμ κ²½λ‘κ° μ‘΄μ¬νλ κ²½μ°μ λλ€.
Disconnected Graph
Undirected Graphμ μλ λͺ¨λ λ Έλμ λν΄ κ²½νΈκ° μ‘΄μ¬νμ§ μλ κ²½μ°μ λλ€.
μ κ·Έλνλ Disconnected Graphμ λλ€.
Complete Graph
κ·Έλνμ λͺ¨λ λ Έλκ° μλ‘ μ°κ²°λμ΄ μλ κ·Έλνμ λλ€.
π Graph ꡬν With Python
νμ΄μ¬μμ μ 곡νλ λμ λ리μ 리μ€νΈ μλ£κ΅¬μ‘°λ₯Ό νμ©ν΄μ κ·Έλνλ₯Ό μ½κ² ννν μ μμ΅λλ€.
μ κ·Έλνλ₯Ό μ½λλ‘ κ΅¬νν΄ λ΄ μλ€.
graph = dict()
graph['A'] = ['B', 'C']
graph['B'] = ['A', 'D']
graph['C'] = ['A', 'G', 'H', 'I']
graph['D'] = ['B', 'E', 'F']
graph['E'] = ['D']
graph['F'] = ['D']
graph['G'] = ['C']
graph['H'] = ['C']
graph['I'] = ['C', 'J']
graph['J'] = ['I']
print (graph) μ€ν κ²°κ³Ό
{ 'A': ['B', 'C'],
'B': ['A', 'D'],
'C': ['A', 'G', 'H', 'I'],
'D': ['B', 'E', 'F'],
'E': ['D'], 'F': ['D'],
'G': ['C'],
'H': ['C'],
'I': ['C', 'J'],
'J': ['I'] }
'Data Structure' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
Heap (ν) μ 리 (0) | 2021.07.28 |
---|---|
Tree (νΈλ¦¬) μ 리 (0) | 2021.07.27 |
Hash Table (ν΄μ ν μ΄λΈ) μ 리 (0) | 2021.07.23 |
Linked List (λ§ν¬λ 리μ€νΈ) μ 리 (0) | 2021.07.23 |
Stack (μ€ν) μ 리 (0) | 2021.07.22 |