ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ Αλγόριθμοι και πολυπλοκότητα Maximm Flo Ιωάννης Τόλλης Τμήμα Επιστήμης Υπολογιστών
Maximm Flo χ 3/5 4/6 4/7 1/9 3/5 5/11/2008 11:05 PM Maximm Flo 1
Oline and Reading Flo neork Flo ( 8.1.1) C ( 8.1.2) Maximm flo Agmening pah ( 8.2.1) Maximm flo and minimm c ( 8.2.1) Ford-Flkeron algorihm ( 8.2.2-8.2.3) 5/11/2008 11:05 PM Maximm Flo 2
Flo Neork A flo neork (or j neork) N coni of A eighed digraph G ih nonnegaie ineger edge eigh, here he eigh of an edge e i called he capaciy c(e) of e To diingihed erice, and of G, called he orce and ink, repeciely, ch ha ha no incoming edge and ha no ogoing edge. Example: 5 6 3 1 1 2 3 7 9 5 5/11/2008 11:05 PM Maximm Flo 3
Flo A flo f for a neork N i i an aignmen of an ineger ale f(e) o each edge e ha aifie he folloing properie: Capaciy Rle: For each edge e, 0 f (e) c(e) Coneraion Rle: For each erex, here E () and E + () are he incoming and ogoing edge of, rep. The ale of a flo f, denoed f, i he oal flo from he orce, hich i he ame a he oal flo ino he ink Example: 3/5 2/6 f ( e) = + 5/11/2008 11:05 PM Maximm Flo 4 1/3 3/7 2/9 e E ( ) 4/5 e E ( ) f ( e)
Maximm Flo A flo for a neork N i aid o be maximm if i ale i he large of all flo for N The maximm flo problem coni of finding a maximm flo for a gien neork N 1/3 2/6 3/7 2/9 4/5 3/5 Flo of ale 8 = 2 + 3 + 3 = 1 + 3 + 4 Applicaion 4/6 Hydralic yem 3/7 Elecrical circi Traffic moemen 2/9 4/5 3/5 Freigh ranporaion Maximm flo of ale 10 = 4 + 3 + 3 = 3 + 3 + 4 5/11/2008 11:05 PM Maximm Flo 5
C A c of a neork N ih orce and ink i a pariion χ = (V,V ) of he erice of N ch ha V and V Forard edge of c χ: origin in V and deinaion in V Backard edge of c χ: origin in V and deinaion in V Flo f(χ) acro a c χ: oal flo of forard edge min oal flo of backard edge Capaciy c(χ) of a c χ: oal capaciy of forard edge Example: c(χ) = 24 f(χ) = 8 5/11/2008 11:05 PM Maximm Flo 6 5 3/5 6 2/6 χ χ 3 1 1 2 3 1/3 7 9 3/7 2/9 5 4/5
Flo and C Lemma: The flo f(χ) acro any c χ i eqal o he flo ale f Lemma: The flo f(χ) acro a c χ i le han or eqal o he capaciy c(χ) of he c Theorem: The ale of any flo i le han or eqal o he capaciy of any c, i.e., for any flo f and any c χ, e hae f c(χ) 3/5 2/6 χ 1 χ 2 1/3 3/7 2/9 4/5 c(χ 1 ) = 12 = 6 + 3 + 1 + 2 c(χ 2 ) = 21 = 3 + 7 + 9 + 2 f = 8 5/11/2008 11:05 PM Maximm Flo 7
Agmening Pah Conider a flo f for a neork N Le e be an edge from o : Reidal capaciy of e from o : Δ f (, ) = c(e) f (e) Reidal capaciy of e from o : Δ f (, ) = f (e) Le π be a pah from o The reidal capaciy Δ f (π) of π i he malle of he reidal capaciie of he edge of π in he direcion from o A pah π from o i an agmening pah if Δ f (π) > 0 5/11/2008 11:05 PM Maximm Flo 8 2/5 2/6 π 1/3 2/7 2/9 Δ f (,) = 3 Δ f (,) = 1 Δ f (,) = 1 Δ f (,) = 2 Δ f (π) = 1 f = 7 4/5
Flo Agmenaion Lemma: Le π be an agmening pah for flo f in neork N. There exi a flo f for N of ale f = f + Δ f (π) Proof: We compe flo f by modifying he flo on he edge of π Forard edge: f (e) = f(e) + Δ f (π) Backard edge: f (e) = f(e) Δ f (π) 5/11/2008 11:05 PM Maximm Flo 9 2/5 3/5 2/6 2/6 π π 1/3 2/7 2/9 Δ f (π) = 1 2/3 2/7 2/9 4/5 4/5 f = 7 f = 8
Ford-Flkeron Algorihm Iniially, f(e) = 0 for each edge e Repeaedly Search for an agmening pah π Agmen by Δ f (π) he flo along he edge of π A pecialiaion of DFS (or BFS) earche for an agmening pah An edge e i raered from o proided Δ f (, ) > 0 Algorihm FordFlkeronMaxFlo(N) for all e G.edge() eflo(e, 0) hile G ha an agmening pah π { compe reidal capaciy Δ of π } Δ for all edge e π { compe reidal capaciy δ of e } if e i a forard edge of π δ gecapaciy(e) geflo(e) ele { e i a backard edge } δ geflo(e) if δ < Δ Δ δ { agmen flo along π } for all edge e π if e i a forard edge of π eflo(e, geflo(e) + Δ) ele { e i a backard edge } eflo(e, geflo(e) Δ) 5/11/2008 11:05 PM Maximm Flo 10
Max-Flo and Min-C Terminaion of Ford-Flkeron algorihm There i no agmening pah from o ih repec o he crren flo f Define V e of erice reachable from by agmening pah V e of remaining erice C χ = (V,V ) ha capaciy c(χ) = f Forard edge: f(e) = c(e) Backard edge: f(e) = 0 Th, flo f ha maximm ale and c χ ha minimm capaciy Theorem: The ale of a maximm flo i eqal o he capaciy of a minimm c 3/5 4/6 χ 4/7 1/9 c(χ) = f = 10 3/5 5/11/2008 11:05 PM Maximm Flo 11
5/11/2008 11:05 PM Maximm Flo 12 Example (1) 0/3 0/9 0/3 1/7 0/6 0/5 0/2 1/3 0/9 0/3 1/7 0/6 1/2 1/3 0/9 0/3 2/7 1/6 1/2 2/3 0/9 1/3 2/7 1/6 1/2
Example (2) 3/6 2/3 1/2 2/7 0/9 4/6 3/7 1/9 2/5 1/2 o ep 3/6 4/6 2/7 1/9 2/5 3/5 1/2 4/7 1/9 3/5 5/11/2008 11:05 PM Maximm Flo 13
Analyi In he or cae, Ford- Flkeron algorihm perform f* flo agmenaion, here f* i a maximm flo Example The agmening pah fond alernae beeen π 1 and π 2 The algorihm perform 100 agmenaion Finding an agmening pah and agmening he flo ake O(n + m) ime The rnning ime of Ford- Flkeron algorihm i O( f* (n + m)) 5/11/2008 11:05 PM Maximm Flo 14 0/50 0 0/50 0 π 1 π 2 0 0 0 0
Τέλος Ενότητας
Χρηματοδότηση Το παρόν εκπαιδευτικό υλικό έχει αναπτυχθεί στα πλαίσια του εκπαιδευτικού έργου του διδάσκοντα. Το έργο «Ανοικτά Ακαδημαϊκά Μαθήματα στο Πανεπιστήμιο Κρήτης» έχει χρηματοδοτήσει μόνο τη αναδιαμόρφωση του εκπαιδευτικού υλικού. Το έργο υλοποιείται στο πλαίσιο του Επιχειρησιακού Προγράμματος «Εκπαίδευση και Δια Βίου Μάθηση» και συγχρηματοδοτείται από την Ευρωπαϊκή Ένωση (Ευρωπαϊκό Κοινωνικό Ταμείο) και από εθνικούς πόρους.
Σημειώματα
Σημείωμα αδειοδότησης Το παρόν υλικό διατίθεται με τους όρους της άδειας χρήσης Creaie Common Αναφορά, Μη Εμπορική Χρήση, Όχι Παράγωγο Έργο 4.0 [1] ή μεταγενέστερη, Διεθνής Έκδοση. Εξαιρούνται τα αυτοτελή έργα τρίτων π.χ. φωτογραφίες, διαγράμματα κ.λ.π., τα οποία εμπεριέχονται σε αυτό και τα οποία αναφέρονται μαζί με τους όρους χρήσης τους στο «Σημείωμα Χρήσης Έργων Τρίτων». [1] hp://creaiecommon.org/licene/by-nc-nd/4.0/ Ως Μη Εμπορική ορίζεται η χρήση: που δεν περιλαμβάνει άμεσο ή έμμεσο οικονομικό όφελος από την χρήση του έργου, για το διανομέα του έργου και αδειοδόχο που δεν περιλαμβάνει οικονομική συναλλαγή ως προϋπόθεση για τη χρήση ή πρόσβαση στο έργο που δεν προσπορίζει στο διανομέα του έργου και αδειοδόχο έμμεσο οικονομικό όφελος (π.χ. διαφημίσεις) από την προβολή του έργου σε διαδικτυακό τόπο Ο δικαιούχος μπορεί να παρέχει στον αδειοδόχο ξεχωριστή άδεια να χρησιμοποιεί το έργο για εμπορική χρήση, εφόσον αυτό του ζητηθεί.
Σημείωμα Αναφοράς Copyrigh Πανεπιστήμιο Κρήτης, Ιωάννης Τόλλης 2015. «Αλγόριθμοι και πολυπλοκότητα. Maximm Flo». Έκδοση: 1.0. Ηράκλειο 2015. Διαθέσιμο από τη δικτυακή διεύθυνση: hp://opencore.oc.gr/core/core/ie.php?id=368
Διατήρηση Σημειωμάτων Οποιαδήποτε αναπαραγωγή ή διασκευή του υλικού θα πρέπει να συμπεριλαμβάνει: το Σημείωμα Αναφοράς το Σημείωμα Αδειοδότησης τη δήλωση Διατήρησης Σημειωμάτων το Σημείωμα Χρήσης Έργων Τρίτων (εφόσον υπάρχει) μαζί με τους συνοδευόμενους υπερσυνδέσμους.