Graph Theory Flashcards
1
Q
What is a tree?
A
An undirected graph with no cycles
2
Q
What is a rooted tree?
A
Tree with a designated root node where every edge either points away from or towards the root node
3
Q
what is an adjacency list?
A
a way to represent a graph as a map from nodes to lists of edges
4
Q
write generic dis for a graph
A
function dis(at): if visited[at]: return true visited[at] = true
neighbors = graph[at]
for next in neighbors: dfs(next)
# Start DFS at node zero start_node = 0 dfs(start_node)