Jotto Frosh Sophs Jrs Srs audio 2 audio
- Slides: 28
Jotto! Frosh Sophs Jrs Srs audio 2 audio 1 graze 2 graze 3 graze 1 alloy 2 fresh 1 alloy 1 fresh 2 armor 2 brave 2 wreak 2 fjord 2 armor 1 brave 3 brave 1 wreak 3 wreak 1 wreak 2 fjord 1 fjord 5 This term's first class to guess another's word earns 1 problem. . . This term's last class to have its word guessed earns 1 problem. . .
Course Schedule Jan 25 Welcome! DP + other problems ~ 4 problems Feb 1 Lab session ~ 4 problems Feb 8 Discussion session on bin search problems ~ 4 problems Feb 15 Paul Dorsey ~ 4 problems Feb 22 Lab session plus a FW "reminder"! ~ 4 problems Mar 1 Discussion session on other graph algs. ~ 4 problems Mar 8 Lab session on graph + geometry problems ~ 4 problems Mar 15 Spring break. . . – no CS 189 class Mar 22 Discussion session on something new. . . ~ 4 problems Mar 29 Lab session ~ 4 problems. . . we don't meet through April. . . ≥ 32 problems total You may submit problems until the end of exams…
IOCCC example of the day. . . International Obfuscated C Coding Contest one program to rule them all! http: //www. ioccc. org/2004/anonymous. hint
IOCCC. . . ?
Max Flow ! B 16 10 s 12 4 D 9 4 C 14 E capacity What's the maximum flow possible, from src to sink? Ford-Fulkerson algorithm sink or target t 7 source 13 20
TO Capacity Graph Max Flow (Step #1) Use depth- or breadth-first search to find any path from s to t. B 16 10 s 12 4 D 9 B s B C FROM D - 16 13 - 10 12 4 - 14 - - 9 - - 20 E t - - - 7 - - 4 - 20 4 C 14 E sink t 7 source 13 s C D E t -
TO Capacity Graph Max Flow (Step #1) Use depth- or breadth-first search to find any path from s to t. B 16 10 s 12 4 D 9 What's left ? B s B C FROM D - 16 13 - 10 12 4 - 14 - - 9 - - 20 E t - - - 7 - - 4 - 20 4 C 14 E sink t 7 source 13 s C D E t -
TO Old capacities Max Flow (Step #1) Use depth- or breadth-first search to find any path from s to t. B 4/16 10 s 0/12 4 s B C FROM D - 16 13 - 10 12 4 - 14 - - 9 - - 20 E t - - - 7 - - 4 - D 9 8/20 - 4 C 14 E TO s B C FROM D E t Residual capacities! What are the red edges? E t sink s What's left ! D t 7 source 13 C 12 - B C D E t 4 13 - 10 4 12 9 0 - - - 14 - 8 - - 7 12 - 4 -
TO Max Flow (Step #1) Use depth- or breadth-first search to find any path from s to t. B 4 12 s 10 0 D 12 B s B C FROM D - 16 13 - 10 12 4 - 14 - - 9 - - 20 E t - - - 7 - - 4 - 8 9 C D E t - sink 12 4 t 7 source 13 s 4 C 14 E TO s (Step #2) Continue with the remaining capacities until no path exists! s B C FROM D E t 12 - B C D E t 4 13 - 10 4 12 9 0 - - - 14 - 8 - - 7 12 - 4 -
Max Flow (Step #1) Use depth- or breadth-first search to find any path from s to t. B 11/16 s 12/12 D 19/20 sink 0/10 1/4 0/9 t 7/7 source 12/13 4/4 C 11/14 (Step #2) Continue with the remaining capacities until no path exists! E max flow: 23
Get into the flow! A little bit of name contention… This is the edmonds_karp algorithm. def max_flow(C, source, sink): n = len(C) # C is the capacity matrix F = [[0] * n for i in range(n)] # F is the flow matrix # residual capacity from u to v is C[u][v] - F[u][v] while True: path = BFS(C, F, source, sink) if not path: break # no path - we're done! # find the path's flow, that is, the "bottleneck" edges = [C[u][v]-F[u][v] for u, v in path] path_flow = min( edges ) print "Augmenting by", path_flow for u, v in path: # traverse path to update flow F[u][v] += path_flow # forward edge up F[v][u] -= path_flow # backward edge down return sum([F[source][i] for i in range(n)]) # out from source
Useful alone, too A brief BFS algorithm using the Capacity matrix def BFS(C, F, source, sink): queue = [source] # the BFS queue paths = {source: []} # stores 1 path per graph node while queue: u = queue. pop(0) # next node to explore (expand) for v in range(len(C)): # for each possible next node # path from u to v? and not yet at v? if C[u][v] - F[u][v] > 0 and v not in paths: paths[v] = paths[u] + [(u, v)] if v == sink: return paths[v] queue. append(v) return None # go from v in the future
Setting up… And the code needed to run it… if __name__ == "__main__": # make a capacity graph # node A B C D C = [ [ 00, 16, 13, 00, [ 00, 10, 12, [ 00, 04, 00, [ 00, 9, 00, [ 00, 00, 7, [ 00, 00, E 00, 14, 00, 00, F 00 00 00 20 4 00 ], ], ], ] ] # # # A B C D E F print "C is", C source = 0 # A sink = 5 # F max_flow_value = max_flow( C, source, sink ) print "max_flow_value is", max_flow_value Linked at the ACM website by the slides…
But is max flow good for anything? that is, beyond solving "max flow" problems. . .
Matching! and some acceptable possibilities. . . we have four brides and six grooms a bipartite graph
Matching! and some acceptable possibilities. . . we have four brides a maximal matching and six grooms == no more matchings without rearrangement
Matching! and some acceptable possibilities. . . we have four brides a maximum matching and six grooms == no rearrangements will yield more matchings
Maximum matching is max flow. . . connect a source to the left side. . . make all capacities = 1 put a sink on the right 1 all 1 s 1 sink 1 s t source 1 1 what do the source and sink constraints ensure?
Max flow thought experiment. . . Suppose this is the flow so far (3 units): 1 all 1 s 1 sink 1 s t source 1 1 Draw what happens in the next step of the max-flow algorithm!
Max flow thought experiment. . . the path it finds. . . 1 all 1 s 1 sink 1 s source 1 1 What is this single path doing? t
Max flow thought experiment. . . Done! 1 all 1 s 1 sink 1 s source 1 1 Maximum matching == 4 t
This week's problems… this one is maximum matching! Try one or more of this week's problems!
Stake Height and width of the field 4 1 0 0 1 0 1 1 0 0 0 1 1 Output 3 the pattern Input Maximum number of cows such that no two share a column and no two share a row.
Stake as matching who are the brides? and the grooms? and the constraints?
This week's problems… this one is from last week. . . ? Try one or more of this week's problems!
Dijkstra, for single-source shortest paths S shortest dist from S For all nk , track <nk, Inf> Put <S, 0> into your queue Q. While Q not empty: Remove Q's nearest node <nc, dc> For each edge [nc, nk, dc 2 k]: Let dk be nk's distance: <nk, dk> If dc + dc 2 k < dk: set dk = dc + dc 2 k Put <nk, dk> into Q. . .
Dijkstra, for single-source shortest paths S shortest dist from S For all nk , track <nk, Inf> Put <S, 0> into your queue Q. While Q not empty: Remove Q's nearest node <nc, dc> For each edge [nc, nk, dc 2 k]: Let dk be nk's distance: <nk, dk> If dc + dc 2 k < dk: set dk = dc + dc 2 k Put <nk, dk> into Q. . .
Jotto! Frosh Sophs Jrs Srs audio 2 audio 1 graze 2 graze 3 graze 1 alloy 2 fresh 1 alloy 1 fresh 2 armor 2 brave 2 wreak 2 fjord 2 armor 1 brave 3 brave 1 wreak 3 wreak 1 wreak 2 fjord 1 fjord 5 This term's first class to guess another's word earns 1 problem. . . This term's last class to have its word guessed earns 1 problem. . .
- R&s jotto
- Srs timing
- Resolución 830
- Srs in software engineering
- What is srs
- Which phase transforms srs document
- What is srs in software engineering
- Srs.le.ac.uk
- Analysis models in srs
- State chart diagram for hospital management system
- Analysis models in srs
- Pengertian srs
- Srs philjobnet
- The srs is said to be consistent if and only if
- Srs agency
- Autacoids
- Vmm2
- Comparaciones quick check
- Srs elevator
- User characteristics in srs
- The gallup poll once asked an srs
- Siprec recording
- Güç aktarma organları
- Srs itech
- Srs prototype outline
- Udin verification
- Seagate srs tracker
- Tamu srs
- Specialized recovery services