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.