Dr. Wonjun Lee will be interviewing next week for our open CS professor position.
I have to attend the Teaching Demo, so class is cancelled for Monday, 3/29. (Also office hours will end early on Tuesday.)
(See Jamboard)
Need to add some details to this to specify completely. \(O(V+E)\)?
Boruvka(G) {
initalize set edges_to_collapse
for each vertex v in G {
min_edge = null
min_weight = infinity
for each edge uv according to the adjacency list {
if uv.weight < min_weight {
min_edge = uv
min_weight = uv.weight
}
}
add min_edge to edges_to_collapse
}
for each edge uv in edges_to_collapse {
add new node x to adjacency list
for each neighbor n of u
add n to x's linked list
change "u" in n's linked list to "x"
for each neighbor n of v
if n is already in x's linked list
if nv.weight > nu.weight
nx.weight = nv.weight
else
add n to x's linked list
change "v" in n's linked list to "x"
remove u and v nodes from adjacency list
}
}
BoruvkaContraction(A[1..V]):
//iterate over all edges and mark those to be contracted
for i <- 1..V:
edges <- A[i] //has indices 1..n
min <- (edge with weight of infinity)
for j <- 1..n:
if edges[j].weight < min.weight:
min <- the edge from i to edges[j]
mark the edge min
for i <- 1..V:
if A[i] contains a marked edge uv:
//add v's out-edges to u
new <- A[u]
old <- A[v]
for j <- 1..n:
if old[j] is not in new:
add old to A[u] // new
else: //only add smallest parallel edge
parallel <- from new to old[j]
if old[j].weight < parallel.weight:
delete parallel from A[u] // new
add A[v][j] to A[u]
replace v in A[old[j]] with u
delete old
Theorem. Let \(F\) be an intermediate spanning forest of a weighted graph \(G\), and suppose \(e\) is a safe edge. Then the minimum spanning tree contains \(e\).
Exercise: Describe this completely, and verify its running time.
Kruskal(V, E):
sort E by increasing weight (e.g., MergeSort)
F <- (V, ∅)
for each vertex v ∈ V
MakeSet(v) // Set data structure partitioning V
for i <- 1 to |E|
uv <- ith lightest edge in E
if Find(u) != Find(v) // Are u and v in different partitions?
Union(u, v)
add uv to F
return F
Table #1 | Table #2 | Table #3 | Table #4 | Table #5 | Table #6 | Table #7 |
---|---|---|---|---|---|---|
Jordan | Blake | Logan | Josiah | Bri | Grace | Isaac |
Andrew | Kristen | Levi | Kevin | James | Drake | Claire |
Trevor | Talia | Graham | Ethan | Nathan | John | Jack |
On the Jamboard, step through JarnÃk’s algorithm on the given graph. Label the edges in the order they get added. Start at the vertex at the top.
On the Jamboard, step through Kruskal’s algorithm on the given graph. Label the edges in the order they get added.
Weighted graphs can be represented with \(V \times V\) matrix:
\[ \begin{bmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,V} \\ a_{2,1} & a_{2,2} & \cdots & a_{2,V} \\ \vdots & \vdots && \vdots \\ a_{V,1} & a_{V,2} & \cdots & a_{V,V} \end{bmatrix} \]