Randomized Algorithms CS648 Lecture 21 Random Walk and Electric Networks 1 OVERVIEW AND MOTIVATION 2 What do we know about Random walk till now? We have discussed uniform random walk on • A line. • A complete graph. • Two complete graphs joined by an edge (Mid-sem Exam). We analyzed the random walk by writing equation for each case. We could solve these equations because of • Symmetry of the our graphs (line graph, complete graph). • Uniformity of random walk. Question: Is there a compact formula for expected duration of a random walk on any graph ? What if the random walk is not uniform ? 3 An answer from mathematics Let ๐ฎ = (๐ฝ, ๐ฌ) be an undirected graph on ๐ vertices and ๐ edges. Theorem: Let ๐, ๐ ∈ ๐ฝ. Expected length of a random walk that starts from ๐ and terminates on reaching ๐ is ๐ถ(๐๐). The above result is derived using theory of Markov Chains. Unfortunately, it is a loose result for many graphs ๏. Exercise: Show that for complete graph, the above result is very loose. 4 A surprising discovery • Random walk on a graph is closely related to electric networks. • A graph can be viewed as a electric network where each edge corresponds to a resistance of one ohm. • Various aspects of random walk are defined as a fundamental characteristics (resistance, power, voltage) of the corresponding electric network. Physics of electric network helps in mathematical theory of random walk ! Isn’t it surprising ? 5 A WARM UP EXAMPLE 6 Random walk on a line ½ ½ home bar ๐ ๐ ๐−๐ ๐ ๐+๐ ๐−๐ ๐ Question: Suppose the random walk starts at ๐. What is the probability that the drunkard reaches home before reaching bar ? Let ๐(๐) be the corresponding probability. ๐ ๐ = ?๐ ๐ ๐ = ?๐ ๐ ๐ ๐ ๐ =? ๐ ๐−๐ + ๐ ๐+๐ ๐ ๐ 7 Random walk on a line current ๐ ๐ ๐−๐ ๐ ๐+๐ ๐−๐ ๐ ๐ Volt Each resistance is 1 ohm. ๐ฝ ๐ : Potential at point ๐. ๐ฝ ๐ = ๐, ๐ฝ ๐ = ๐, Current entering ๐ = Current leaving ๐. ๏จ ๐ฝ ๐+๐ −๐ฝ ๐ ๐ = ๐ฝ ๐ −๐ฝ ๐−๐ ๐ ๐ ๏จ ๐ฝ ๐ =๐ ๐ฝ ๐−๐ + ๐ฝ ๐+๐ 9 Random walk on a line ½ ½ home bar ๐ ๐ ๐ = ๐, ๐ ๐−๐ ๐ ๐ = ๐, ๐ ๐ ๐ = ๐+๐ ๐ ๐ ๐ ๐−๐ ๐−๐ ๐ + ๐ ๐+๐ current ๐ ๐ ๐−๐ ๐ ๐+๐ ๐−๐ ๐ ๐ Volt ๐ฝ ๐ : Potential at point ๐ ๐ฝ ๐ = ๐, ๐ฝ ๐ = ๐, ๐ฝ ๐ = ๐ ๐ ๐ฝ ๐−๐ + ๐ฝ ๐+๐ Hence ๐ฝ ๐ and ๐ ๐ satisfy the same set of equations. ๏จ Since these equations have unique solution, therefore๐ฝ ๐ = ๐ ๐ for all ๐. Generalization to graphs ๐ ๐ bar ๐ home ๐ ๐ ๐ ๐ ๐ ๐ ๐ Question: What is ๐๐ , probability of reaching home before bar ? ๐๐ = ๐, ๐๐ = ๐, ๐๐ = ๐ deg(๐) ๐∈๐ต(๐) ๐๐ 11 Generalization to graphs ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ Question: What is relation between ๐ฝ๐ and ๐ฝ๐ ’s where ๐ ∈ ๐ต(๐) ? ๐ฝ๐ = ๐, ๐ฝ๐ = ๐, Net current leaving ๐ is 0. ๐∈๐ต(๐)(๐ฝ๐ −๐ฝ๐ ) =0 ๏จ๐ฝ๐ = ๐ deg(๐) ๐∈๐ต(๐) ๐ฝ๐ 12 Generalization to graphs ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ Question: What is relation between ๐ฝ๐ and ๐ฝ๐ ’s where ๐ ∈ ๐ต(๐) ? ๐ฝ๐ = ๐, ๐ฝ๐ = ๐, ๐ ๐ฝ๐ = deg(๐) ๐๐ = ๐, ๐๐ = ๐, ๐ฝ๐ ๐∈๐ต(๐) ๐ ๐๐ = deg(๐) ๐๐ ๐∈๐ต(๐) Hence ๐ฝ๐ and ๐๐ satisfy the same set of equations. ๏จ Since these equations have unique solution, therefore ๐ฝ๐ = ๐๐ for all ๐. 13 Generalization to graphs ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ Exercise: Use your knowledge of electric circuits to find exact value of ๐ฝ๐ in the above circuit. This will also be the value of ๐๐ . Try to realize that you would not have been able to calculate ๐๐ using other mathematical tools that you are aware of. Isn’t it surprising. Fully internalize it before proceed further for another more surprising result. We shall revise the theory of electric circuits which perhaps you might have forgotten by now. 14 REVISITING THEORY OF ELECTRIC CIRCUITS 15 Kirchoff’s Current Law ๐ ๐ ๐ ๐ ๐ ๐ For any node ๐ in the circuit, Current entering node ๐ = Current leaving node ๐ Note: This law holds for the entire circuit as well. For example, Let the above circuit is connected to outside circuit through wires at nodes ๐, ๐, ๐. Question: If 5 Amperes of current enters ๐ and 10 Amperes of current enters ๐ from outside, then what current leaves/enters ๐ ? Answer: 15 Amperes of current must leave ๐. 17 Notion of Resistance and Ohm’s Law ๐ฐ ๐ ๐น ๐ The current ๐ฐ passing through a piece of wire is proportional to the potential difference ๐ฝ applied across the two ends of it. The constant of proportionality is called “resistance”. ๐ฝ = ๐ฐ๐น Thus the resistance can be defined in terms of voltage and current as follows. The resistance of a wire is the potential difference that needs to be applied across its ends to pass a current of 1 ampere through it. 18 Notion of Resistance and Ohm’s Law ๐๐ ๐๐ ๐๐ ๐ ๐๐ ๐๐ ๐ What made you conclude that the resistance between ๐ and ๐ is ๐. ๐๐๐ ? • Series law • Parallel law This introduces the notion of effective resistance between two points ๐ and ๐ in a given circuit. Question : In a circuit, if we increase (decrease) the value of any resistance, what will be its effect on effective resistance between ๐ and ๐ ? Answer: the effective resistance between ๐ and ๐ may only increase(decrease). 19 Notion of Resistance and Ohm’s Law ๐ฐ ๐ ๐น ๐ If ๐ฐ amperes of current flows from ๐ to ๐, then • ๐ฝ๐๐ : the potential difference from ๐ to ๐ or the potential of ๐ relative to ๐ • Relation between ๐ฝ๐๐ and ๐ฝ๐๐ ? ๐ฝ๐๐ = − ๐ฝ๐๐ Question: What is ๐ฝ๐๐ if ๐ is not directly connected to ๐ in the circuit ? (see next slide) 20 Electric Potential is conservative ๐ ๐ ๐ ๐ ๐ ๐ Question: What is ๐ฝ๐๐ ? (the battery and other wires not shown in the figure above) Answer: Consider any path from ๐ to ๐. ๐ฝ๐๐ is the sum of the potential difference at each edge on this path. ๐ฝ๐๐ = ๐ฝ๐๐ + ๐ฝ๐๐ + ๐ฝ๐๐ = ๐ฝ๐๐ + ๐ฝ๐๐ + ๐ฝ๐๐ FACT: ๐ฝ๐๐ is path independent (electric potential is conservative). 21 Three simple principles Fully understand these principles so that you may apply them later on. 22 Reversibility Let ๐ฐ be a valid current flow in a circuit. Question: Let −๐ฐ be a flow obtained by reversing the direction of current flow in each branch of circuit. is −๐ฐ also a valid current flow in the circuit ? Answer: Yes. Question: Let • ๐ฝ๐๐ be potential of ๐ relative to ๐ for the flow ๐ฐ. • ๐ฝ′๐๐ be potential of ๐ relative to ๐ for the flow −๐ฐ. What is relation between ๐ฝ๐๐ and ๐ฝ′๐๐ ? Answer: ๐ฝ๐๐ = ๐ฝ′๐๐ 23 Linearity of current flow Let ๐ฐ′ and ๐ฐ′′ be any two valid current flows in a circuit. Question: Is ๐ฐ′+ ๐ฐ′′ a valid current flow ? Answer: Yes. Question: Let • ๐ฝ′๐๐ be potential of ๐ relative to ๐ for the flow ๐ฐ′. • ๐ฝ′′๐๐ be potential of ๐ relative to ๐ for the flow ๐ฐ′′. What is potential of ๐ relative to ๐ in ๐ฐ′+ ๐ฐ′′ ? Answer: ๐ฝ′๐๐ +๐ฝ′′๐๐ 24 Uniqueness ๐ ๐ ๐ ๐ ๐ ๐ If we assign any assignment of potential to nodes in the above circuit, there exists a unique and valid current flow in the circuit satisfying these potential. However, note that, this will require that you connect external wires to allow residual current to enter/leave a node to satisfy Kirchoff’s law. Interestingly the converse of the above rule is also true ๏. 25 Uniqueness ๐ ๐ ๐ ๐ ๐ ๐ If we inject and extract any arbitrary amount of current into a circuit from outside, then provided that the current satisfies Kirchoff’s law (net current into circuit is 0), the current distributes itself within the circuit to give a unique and valid assignment of potentials to all nodes. The reason behind this uniqueness principle lies in the fact that there is a set of linear equations for each circuit on the basis of Kirchoff’s law and Ohm’s law. These equations have a unique solution. Interested students might like to explore this fact. But for this course, it is fine if you just understand this principle of uniqueness. 26 Random walk and electric networks 27 Notations ๐ฎ = (๐ฝ, ๐ฌ) ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ • Hitting time ๐ฏ๐๐ : Expected no. of steps of the walk that starts from ๐ and finishes as soon as it reaches ๐. Question: Any relation between ๐ฏ๐๐ and ๐ฏ๐๐ ? NO • Commute time ๐ช๐๐ : Expected no. of steps of the walk that starts from ๐ and finishes at ๐ after visiting ๐ at least once. ๐ช๐๐ = ๐ฏ๐๐ + ๐ฏ๐๐ 28 Expressing ๐ฏ๐๐ through a circuit ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ฏ๐๐ = ๐ + ๐ deg(๐) ๐ ๐∈๐ต(๐) ๐ฏ๐๐ 29 Expressing ๐ฏ๐๐ through a circuit ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ When there is no external current into ๐, Question: What is relation between ๐ฝ๐๐ and ๐ฝ๐๐ ’s where ๐ ∈ ๐ต(๐) ? ๐ฝ๐๐ = • • • ๐ deg(๐) ๐∈๐ต(๐) ๐ฝ๐๐ ๐ฏ๐๐ = ๐ + ๐ deg(๐) ๐∈๐ต(๐) ๐ฏ๐๐ An additive term of ๐ in equation of ๐ฏ๐๐ is missing in the equation of ๐ฝ๐๐ . Why ? No numerical additive term appears in the equation of ๐ฝ๐๐ because we derived it assuming net current into ๐ is 0. So in order to make the two equations similar, we need to augment the above circuit with external wires. 30 Expressing ๐ฏ๐๐ through a circuit ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ Let ๐ฐ๐ be the current injected into ๐ from outside. Question: What be the new relation between ๐ฝ๐๐ and ๐ฝ๐๐ ’s where ๐ ∈ ๐ต(๐) ? ๐ฐ ๐ ๐ฝ๐๐ = deg(๐) + ๐ deg(๐) ๐∈๐ต(๐) ๐ฝ๐๐ ๐ฏ๐๐ = ๐ + ๐ deg(๐) ๐∈๐ต(๐) ๐ฏ๐๐ Question: What should be ๐ฐ๐ in order to equate equations of ๐ฝ๐๐ and ๐ฏ๐๐ ? ๐ฐ = deg(๐) ๐ Observation: To equate ๐ฝ๐๐ with ๐ฏ๐๐ for each ๐ ∈ ๐ฝ\{๐}, we need to inject current of deg(๐) into each node ๐. ๏จ We must extract 2๐ − deg(๐) current from ๐ to satisfy Kirchoff’s current law. 31 Expressing ๐ฏ๐๐ through a circuit ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ฏ๐๐ is the potential of ๐ relative to ๐ in circuit with the following current flow ๐ฐ: 1. Inject deg(๐) current into each ๐ ∈ ๐ฝ\{๐}, 2. Extract 2๐ − deg(๐) current from ๐. It follows from the uniqueness principle that ๐ฐ will be a valid current flow in the circuit. In a similar manner, could you express ๐ฏ๐๐ ? 32 Expressing ๐ฏ๐๐ through a circuit ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ฏ๐๐ is the potential of ๐ relative to ๐ in circuit with the following current flow ๐ฐ′: 1. Inject deg(๐) current into each ๐ ∈ ๐ฝ\{๐}, 2. Extract 2๐ − deg(๐) current from ๐. 33 ๐ฏ๐๐ + ๐ฏ๐๐ = ?? ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ฏ๐๐ = ๐ฝ๐๐ in circuit(๐ฎ) with current flow ๐ฐ. ๐ ๐ ๐ ๐ ๐ ๐ Apply principle of Reversibility ๐ ๐ ๐ ๐ ๐ฏ๐๐ = ๐ฝ๐๐ in circuit(๐ฎ) with current flow ๐ฐ′. 34 ๐ฏ๐๐ + ๐ฏ๐๐ = ?? ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ฏ๐๐ = ๐ฝ๐๐ in circuit(๐ฎ) with current flow ๐ฐ. ๐ ๐ ๐ ๐ ๐ ๐ Apply principle of Linearity ๐ ๐ ๐ ๐ ๐ฏ๐๐ = ๐ฝ๐๐ in circuit(๐ฎ) with current flow −๐ฐ′. 35 ๐ฏ๐๐ + ๐ฏ๐๐ = ?? ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ ๐ฏ๐๐ + ๐ฏ๐๐ = ๐ฝ๐๐ in circuit(๐ฎ) with current flow ๐ฐ − ๐ฐ′. Question: What does the circuit(๐ฎ) with current flow ๐ฐ − ๐ฐ′ look like ? Hint: External current cancels at each node except at ๐ and ๐. 36 ๐ฏ๐๐ + ๐ฏ๐๐ = ?? ๐ ๐ ๐ ๐ ๐ ๐ 2๐ ๐ ๐ 2๐ ๐ ๐ ๐ฏ๐๐ + ๐ฏ๐๐ = ๐ฝ๐๐ in circuit(๐ฎ) with 2๐ current entering ๐ and 2๐ current leaving ๐. = 2๐ ๐น๐๐ , where ๐น๐๐ is the effective resistance between ๐ and ๐. 37 Theroem: Given an undirected graph ๐ฎ = (๐ฝ, ๐ฌ) on ๐ edges, commute time between any pair of vertices ๐ and ๐ is 2๐ ๐น๐๐, where ๐น๐๐ is the effective resistance between ๐ and ๐ in the circuit associated with ๐ฎ. 38 Commute Time of some well studied graphs 39 Useful tips You may use one or more of the following principles to calculate effective resistance any pair of vertices ๐ and ๐. • Increasing resistance of some edges to infinity (equivalent to removal of those edges) will only increase the effective resistance between ๐ and ๐. • Apply series and parallel law of resistance can be a useful tool sometimes. • Any flow from ๐ to ๐ in the circuit will consume same or more amount of power than the corresponding current flow of same value from ๐ to ๐. So effective resistance between any pair of vertices is bounded by the power dissipated due to any flow of 1 ampere from ๐ to ๐ in the circuit. (This is called the least power law) 40 Two complete graphs joined by an edge Let ๐ฎ and ๐ฏ be two complete graphs on ๐ vertices. We add an edge between a vertex in ๐ฎ and a vertex in ๐ฏ. What is the maximum commute time in this combined graph ? 41 Grid Given ๐-by-๐ grid, calculate commute time between vertices ๐ and ๐. Use least power law, and distribute 1 ampere of current evenly from ๐ to ๐. ๐ ๐ (the solution was sketched in the lecture class) 42