Graphs

G = (V,E) V: set of nodes(vertexes) E: set of Edges(arcs)

Untitled

Directed Graph

Representation

  1. Adjacency Matrix

    Mij=1 if (i,j) is edge

    Untitled

  1. Adjacency List

    linked list

    Untitled

DFS

Untitled

Untitled

<aside> 💡 증명: DFS를 통해 어떤 v에서 도달 가능한 모든 노드를 찾을 수 있다

</aside>

<aside> 💡 reachable 계산의 시간 복잡도는 O(V+E) 이다

</aside>