0% found this document useful (0 votes)
55 views

Graphs II: Great Theoretical Ideas in Computer Science

The document discusses graph theory concepts including: 1) The Matrix-Tree Theorem which states that the number of spanning trees of a graph is equal to the determinant of the graph's Laplacian matrix with one row and column removed. 2) Kruskal's algorithm for finding a minimum spanning tree (MST) of a weighted graph by greedily adding the lowest cost edge that avoids cycles. 3) How a minimum spanning tree can be used to approximate the optimal traveling salesman problem tour within a factor of 2. 4) The Marriage Theorem, which provides conditions under which a bipartite graph has a perfect matching, and its application to problems like assigning dance partners.

Uploaded by

James Yang
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Graphs II: Great Theoretical Ideas in Computer Science

The document discusses graph theory concepts including: 1) The Matrix-Tree Theorem which states that the number of spanning trees of a graph is equal to the determinant of the graph's Laplacian matrix with one row and column removed. 2) Kruskal's algorithm for finding a minimum spanning tree (MST) of a weighted graph by greedily adding the lowest cost edge that avoids cycles. 3) How a minimum spanning tree can be used to approximate the optimal traveling salesman problem tour within a factor of 2. 4) The Marriage Theorem, which provides conditions under which a bipartite graph has a perfect matching, and its application to problems like assigning dance partners.

Uploaded by

James Yang
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

13-2-13

15-251
Great Theoretical Ideas in Computer Science

Graphs II
Lecture 9, February 12, 2013

Cayleys Formula

Recap

The number of labeled trees on n nodes is nn-2

Spanning Trees
A spanning tree of a graph G is a tree that touches every node of G and uses only edges from G

Counting Spanning Trees How can we count the number of spanning trees in a graph? Brute force: try all e subsets of n-1 edges. (n-1 )

Theres a faster way. Every connected graph has a spanning tree

13-2-13

Counting Spanning Trees Efficiently Form the Laplacian of the graph. This is an n!n matrix L, where: Degree(i) if i=j Li j = -1 0
2 1 4 5 3

Counting Spanning Trees Efficiently Matrix-Tree Theorem: The number of spanning trees of a graph is the determinant of the Laplacian with one row and column removed. Proof: Beyond the scope of this course (See the book Graph Algorithms by Shimon Evan, pp 34-40.) Computing the determinant is O(n^3). This gives an O(n^3) algorithm for counting the number of spanning trees of a graph.

if (i,j)

otherwise 3 -1 0 -1 -1 -1 2 -1 0 0 0 -1 2 -1 0 -1 0 -1 3 -1 -1 0 0 -1 2

L=

2 1 4 5 3

L=

3 -1 0 -1 -1

-1 2 -1 0 0

0 -1 2 -1 0

-1 0 -1 3 -1

-1 0 0 -1 2

If G is the complete graph on n nodes what happens? We have this (n-1)!(n-1) det: n-1 -1 -1 n-1 . . . . . . -1 -1 -1 . . .
Subtract 1st column from every other column

2 -1 0 0 -1 2 -1 0 0 -1 3 -1 0 0 -1 2

-1 n-1

n-1 -n -n -n -1 n 0 0 . . . . . . . . . -1 0 0 n

= 11

(do in Mathematica)
Add every one of the rows to the first

Number of spanning trees = 11

1 -1 . . . -1

0 0 n 0 . . . . . . 0 n

= nn-2

Cayleys Formula!

Finding Minimum Spanning Trees


This is a beautiful example from Say that each edge in a graph has a cost. A very natural question to ask is: What is the cheapest subset of edges that connect the nodes? Which involves using linear algebra to study and compute things on graphs i.e: what is the minimum spanning tree of the graph?

13-2-13

Finding Optimal Trees


Problem: Find a minimum spanning tree, that is, a tree that has a node for every node in the graph, such that the sum of the edge weights is minimum

Minimum Spanning Trees


7 4 9 6 11 7 8 9 8 5

Kruskals Algorithm

Finding an MST: Kruskals Algorithm


Create a forest where each node is a separate tree Make a sorted list of edges S While S is non-empty: Remove an edge from S with minimal weight If it connects two different trees, add the edge. Otherwise discard it.

A simple algorithm for finding a minimum spanning tree

Applying the Algorithm


7 1 9 9 10 3 6 7 4 5

Proving the Algorithm Works


The algorithm outputs a spanning tree T. Suppose that its not minimal. (For simplicity, assume all edge weights in graph are distinct.) Let M be a minimum spanning tree. Let e be the first edge chosen by the algorithm that is not in M. If we add e to M, it creates a cycle. Since this cycle isnt fully contained in T, it has an edge f not in T. N = M+e-f is another spanning tree.

13-2-13

Proving the Algorithm Works


N = M+e-f is another spanning tree. Claim: e < f, and therefore N < M Suppose not: e > f Then f would have been visited before e by the algorithm, but not added, because adding it would have formed a cycle. But all of these cycle edges are also edges of M, since e was the first edge not in M. This contradicts the assumption M is a tree.

Greed is Good (In this case)


The greedy algorithm, by adding the least costly edges in each stage, succeeds in finding an MST But in math and life if pushed too far, the greedy approach can lead to bad results.

TSP from Trees TSP: Traveling Salesman Problem


Given a number of cities and the costs of traveling from any city to any other city, what is the cheapest round-trip route that visits each city at least once and then returns to the starting city? We can use an MST to derive a TSP tour that is no more expensive than twice the optimal tour. Idea: walk around the MST and take shortcuts if a node has already been visited. We assume that all pairs of nodes are connected, and edge weights satisfy the triangle inequality d(x,y) " d(x,z) + d(z,y)

Tours from Trees


Shortcuts only decrease the cost, so Cost(Greedy Tour) " 2 Cost(MST) " 2 Cost(Optimal Tour) This is a 2-competitive algorithm

Bipartite Graph
A graph is bipartite if the nodes can be partitioned into two sets V1 and V2 such that all edges go only between V1 and V2 (no edges go from V1 to V1 or from V2 to V2)

13-2-13

Dancing Partners
A group of 100 boys and girls attend a dance. Every boy knows 5 girls, and every girl knows 5 boys. Can they be matched into dance partners so that each pair knows each other?

Dancing Partners

Perfect Matchings
A matching is a set of edges, no two of which share a vertex. The matching is perfect if it includes every vertex. Regular Bipartite Matching Theorem: If every node in a bipartite graph has the same degree d # 1, then the graph has a perfect matching. Note: if degrees are the same then |A| = |B|, where A is the set of nodes on the left and B is the set of nodes on the right

A Matter of Degree
Claim: If degrees are the same then |A| = |B| Proof: If there are m boys, there are md edges If there are n girls, there are nd edges

The Marriage Theorem


Theorem: A bipartite graph has a perfect matching if and only if |A| = |B| = n and for all k ! [1,n]: for any subset S of k nodes of A there are at least k nodes of B that are connected to S. A bipartite graph has the matchability condition if for every S subset of A, |N(S)| # |S|, i.e., no neighbor set contracts. Marriage Thm: Graph G has perfect matching iff G has mathability condition.

The Marriage Theorem


Theorem: A d regular bipartite graph has the property that |A| = |B| and for all k ! [1,n]: for any subset S of k nodes of A there are at least k nodes of B that are connected to S. |N(S)| less than |S|, Kd edges out of S but N(S) can have at most (k-1)d edges into it.

13-2-13

The Marriage Theorem


For any subset of (say) k nodes of A there are at least k nodes of B that are connected to it.

The Feeling is Mutual


The condition of the theorem still holds if we swap the roles of A and B: If we pick any k nodes in B, they are connected to at least k nodes in A

A Proof by Contradiction: k>

B k

The condition fails for this graph

n-k<

n-k

Proof of Marriage Theorem


Call a bipartite graph matchable if it has the same number of nodes on left and right, and any k nodes on the left are connected to at least k on the right. Strategy: Break up the graph into two matchable parts, and recursively partition each of these into two matchable parts, etc., until each part has only two nodes In other words, apply induction.

Proof of Marriage Theorem


Select two nodes a ! A and b ! B connected by an edge Idea: Take G1 = (a,b) and G2 = everything else If G2 is matchable, were done. So lets assume that G2 is not matchable. If G2 is not matchable then there is a set of k nodes on the left in G2 that has < k neighbors.

Proof of Marriage Theorem


a k b k-1 The only way this could fail is due to b having been deleted Add this in to form G1 (shown in red) and take G2 to be everything else. This is a matchable partition!* G1 k a G2

Proof of Marriage Theorem


b k
G1 has k vertices on each side. G2 has n-k vertices on each side. The original graph G is matchable. There are no edges from Left(G1): To Right(G2): It follows that G1 and G2 are matchable. QED.

13-2-13

Example
Suppose that a standard deck of cards is dealt into 13 piles of 4 cards each Then it is possible to select a card from each pile so that the 13 chosen cards contain exactly one card of each rank
Proof: Form a bipartite graph as follows: Start with 52 cards on the left and the same 52 cards on the right, connected by 52 edges. Now group the cards on the left into 13 sets according to the given piles. Group the cards on the right into 13 groups according to rank. Let the edges be inherited from the original ones. This bipartite graph is matchable -- k groups on the left have to connect to 4k cards on the right, thus they connect to at least k groups on the right. And thus has a perfect matching.

Generalized Marriage: Halls Theorem


Let S = {S1, S2, Sn} be a set of finite subsets that satisfies: For any subset T of {1,2,,n} let U = the union of St for t in T, we have: |U| # |T|. I.E. any k subsets contain at least k elements

The proof of Halls Theorem is slightly more complicated (but not much) than our proof of the Marriage Theorem. You can find the proof on Wikipedia, or on pages 218 and 219 of Mathematical Thinking by DAngelo and West.

Then we can choose an element xi from each Si so that {x1, x2, } are all distinct

Minimum Spanning Tree - Definition Counting spanning trees - Matrix-Tree Theorem Kruskals Algorithm - Definition - Proof of Correctness Traveling Salesman Problem Heres What You Need to Know - Definition - Using MST to get an approximate solution The Marriage Theorem

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy