O documento descreve o algoritmo de busca em profundidade (DFS) para grafos. O DFS é executado em um grafo de exemplo com 15 vértices, percorrendo cada vértice e seus vizinhos de forma recursiva e adicionando-os à sequência de busca.
3. 3
Confidential
Agenda
1. What is a graph? Areas of application.
2. The main types of graphs.
3. Ways to represent graphs in memory.
4. Adjacency list
5. Depth first search (DFS)
6. Breadth first search (BFS).
7. Searching for connected components
8. Searching for the shortest path in an unweighted graph
5. 5
Confidential
G = (V, E, I)
• V a set of vertices (also called nodes or points);
• E a set of edges (also called links or lines);
• I: E → {{x, y} | (x, y) ∈ V2 ∧ x ≠ y} an incidence function mapping every
edge to an unordered pair of vertices (i.e., an edge is associated with
two distinct vertices).
What is a graph
v0
v1
v2
v3
v4
v5
v6
v7 v8 v11
v9
v12
v10
v13
v15
v14
e0
e1
e2
e3 e4
e6
e5 e7
e10
e11
e9
e12
e13 e14
e8
e15
e16
e17 e19
e18
V = { v0, v1, …, v15 }
E = { e0, e1, …, e19 }
I = { e0 → {v0, v1},
e1 → {v1, v2},
…
e19 → {v14, v15} }
48. 48
Confidential
The graph we are going to work with
A connected component or simply component of an undirected graph
is a subgraph in which each pair of nodes is connected with each
other via a path.
Let’s try to simplify it further, though. A set of nodes forms a
connected component in an undirected graph if any node from the set
of nodes can reach any other node by traversing edges. The main
point here is reachability.