Wk 5/6 : Graphs, MST's, Kruskal, Primm, BFS, DFS Flashcards
What is a path?
A
What is a cycle?
.
What is a subgraph?
.
What is degree?
.
What is min/max degree?
.
What is the max # of edges in an undirected graph?
.
What are connected components?
Can get from anyone node to another?
What is the definition of the shortest path of a weighted graph??
.
What is a tree? A rooted tree?
.
What is a spanning tree?
.
What is an acyclic graph?
.
What is a bipartite graph?
.
How do we store a graph? 2 options….
.
When would we choose to use an adjacency-list representation over an adjacency-matrix representation of a graph? Why? What are the positives and negatives of each one?
When a graph is sparse, the adjacency list makes more sense (|V|^2»_space; E.
If a graph is dense, or we need to quickly tell if there is an edge in between 2 vertices. (for ex. all pairs shortest paths)
Matrices use asympotically more memory than adj-lists, which use only Theta (E+V). But it provides a quick way to know if an edge is in the graph. It is also simpler and makes sense for small grapsh
Lists are easy to add data to, like weight functions and other variants.
Which algorithms lean heavily on BFS?
Primm, Dijkstra
What does BFS do in English?
Systematically explores the edges of G to find every vertex that is reachable from s.
Keeps track of the levels that each node is from s as it continually expands the frontier from s.
Creates a BFS tree that from s to any node reachable from s, hs the simple path which is the smallest number of edges.
What does BFS use to keep track along the way, and what are the meanings…
Colors, white, grey, black.
white is undiscovered
grey is discovered, unprocessed.
black is processed.
grey can be next to whites and blacks. Blacks will not be next to whites.
Also keeps track of predecessors, ancestors….if u is on simple path from s to v, then u is an ancestor of v.
What attributes of a node are stored in BFS?
u.d = distance from s.
u.pi = predecessor/parent
u.color = color.
( another )
How do we know that BFS finds the shortest path from s to v?
[INSERT] see proof in book….
How does DFS work in words?
searches all edges out of the current node until they’ve all been explored, then backtracks to the previous. process continues until we’ve discovered everything that’s discoverable from the source, then if there are still undiscovered vertices it makes additional calls.
How is the tree created by predecessors in DFS different from that created in BFS?
you can actually have multiple independent trees with DFS. Really its a DF forest. Every vertex will end up in its own tree and these trees are disjoint.
How is the coloring scheme of DFS similar to BFS? How does DFS coloring relate to d and f values.
Both use white - > gray - > black. d values are timestamps for discovery. f values are timestamps for being finished. a node is white when d is infinity. it is gray in between d and f and black after f.
What is the definition of a minimum spanning tree? How many does a graph have?
connected, undirected graph with weight in amount of wire needed to connect each node.
we want the acyclic subset that connects all.
that’s a spanning tree, the one with minimum weight is the MST.
Could have more than one MST, but only one MST weight.
What three things define a tree?
Connected, Acyclic, Undirected.