Graph Theory in Networks
Lecture 3, 9/7/04EE 228A, Fall 2004
Rajarshi Gupta
University of California, Berkeley
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
2
Plan for Graph Segment
Lecture 3 – Tue (Sep 7, 2004) Paths and Routing Cycles and Protection Matching and Switching
Lecture 4 – Thu (Sep 9, 2004) Coloring and Capacity Trees and Broadcast, Multicast
Lecture 5 – Tue (Sep 14, 2004) Complete example: Capacity in Ad-Hoc
Networks Lectures 9 & 10
Student Presentations (have you signed up ?)
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
3
Network looks like Graph !
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
4 Using Graph Theory in Networking
Modeling Appropriate underlying graph Captures required behavior Warning: slight difference entirely changes
results Analysis
Proofs/results from relevant graph theoretic technique
Reality Check Does in make sense ? Perhaps ignored some important feature
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
5
Routing: Dijkstra Dijkstra, E.W., “A Note on Two Problems in Connexion with
Graphs,” Numerische Mathematik, vol. 1, pp. 269-271, 1959. Given a graph G = (V, E)
Finds weighted shortest path from a single source to all other nodes
Works with non-negative edge weights Applications
OSPF routing (edge weight = 1) Mapquest (edge weight = traversal time) Many, many, many more …
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
6
Dijkstra Review
Initialize
while
end while
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
7
Proof of Correctness Need to show that this is correct ! Thm: Label v(i) is the shortest path cost to i Lemma: Labels in P are the shortest path involving
nodes in P. Then when P = V, the theorem holds Proof of Lemma
Suppose we have a shorter path using node in T Let be two nodes in path, with in
between But if Then we would have picked t before q
(Contradicton)
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
8
Principle of Optimality Partial paths of SP are also shortest Proof:
Let P={s,…,p,…i,…q,…d} be the SP from s to d Suppose {p,…i,…q} as above is not SP from p
to q i.e. Cost {p,…i,…q} > Cost {p,…j,…q} Then, P’={s,…,p,…j,…q,…d} has lesser cost
than P So P is not the SP (contradiction)
Allows computing partial path and extending hop by hop
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
9 General Principle of Optimality
In general, hope that partial paths of “optimal” paths are also optimal. E.g. Minimum Delay Paths Widest path
If true, amenable to distributed algorithms If not, often NP-hard
E.g. Shortest Widest Path Both types of cases found in networking
Will cover in Lecture 5
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
10 Optimality Counter-example
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
11
Dijkstra Complexity
Initialize
while
end while
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
12 Dijkstra Complexity (contd)
True metric of algorithm usefulness n = # of nodes, m = # of edges Dijkstra
Main loop runs n times Finding min takes O(n) Then, updating values is O(m) So, total algo is O(n2+m)
Can improve loop+min (using binary heap) to give O(nlogn+m)
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
13
Other Routing Algorithms Bellman Ford
single source shortest path, negative wts O(mn)
Floyd Warshall all pairs shortest path O(n3)
Johnson all pairs shortest path O(n(m+nlogn)) obvious for +ve edge weights
All-pairs shortest path reqd to set up routing tables
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
14 Directed Acyclic Graph (DAG)
Generalization of the tree concept to directed graphs
Special Features Cannot have cycles Always exists one node with in-degree 0 (Quick Proof) Allows topological ordering of nodes
Applications Tournaments, Games Scheduling problems
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
15
SP in DAG Due to lack of
cycles, topological ordering of nodes (check up)
Can be done in O(m)
Correctness Since no cycles, we
have checked every possible path over the for loop
Algorithm Initialize
for j = (s+1) to n
next j
Complexity We only check each
edge once, so O(m)
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
16
Protection Paths In many situations, we need two paths
Normal Path Protection Path
Types of protection Path Protection Span Protection Link Protection
Type of protection paths Node disjoint Link Disjoint
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
17
4
10
106
2 4
1
6
1
4
10
106
2 4
1
6
1
Min Cost Protection Paths Common Algorithm
Find Shortest Path Make G’ = (V, E\) Find shortest path ’ in G’
Advantages Computationally simple Two Dijkstra/BF Shortest Normal Path, which
is used much Backup path used rarely
Problems Cost (+’) may not be
optimal may block off all possible
’
4
10
106
2 4
1
6
1
Normal Cost =4+2+4=10
4
10
106
2 4
1
6
1
Normal Cost =4+2+4=10
Backup Cost =6+10=16
4
10
106
2 4
1
6
1
Normal &Backup Cost =
11+11=22
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
18
P-Cycle
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
19
P-Cycle (contd)
P-Cycle Algorithm Want to find set of elementary cycles Minimizes total capacity on these cycles All working links must be protected Integer programming solution
Followup: Given two nodes i,j, find min cost cycle in G that covers i and j
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
20
What are you Protecting ?
IP Layer
Optical Layer
Normal Path
Protection Path
When modeling with a graph, remember Present structure Underlying behavior
In this case, unclear Edge costs are IP
layer costs Protection guarantee
is lower layer phenomenon
Perhaps need a different graph model
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
21
2
8
3
43
6
Matching M E s.t no two edges in
M share a common end node
A maximum cardinality matching is matching with a maximum number of edges
Max/min weighted matching chooses edges with max weight
Of special interest are matchings in Bi-Partite Graphs
Max CardinalityMatching
2
8
3
43
6
Max WeightedMatching
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
22 Matching in Bi-Partite Graph
Switching ! N ports (input &
output) Effectively, N input
and N output ports Packets (w priority) are
queued on input port Each port ‘ranks’ its
preferrence for output ports based on priority
Want optimal input-output match
Stable Marriage Look at M men and N
women, with partner preferences
For any pair Alice & Bob, one of following is true
Alice & Bob are married Alice prefers her partner to
Bob Bob prefers his partner to
Alice No pair (A,B) and (C,D)
such that (A,D) and (B,C) would both be preferred :-)
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
23
Stable Marriage Problem Stable Marriage always exists, for any preferences Girl-oriented Algorithm
Girls successively make proposals to boys (engaged or not) If a girl proposes to a boy who is free (not yet paired), the
boy ‘accepts’ the proposal. If the girl proposes to a boy who is already paired
If this proposal is a better proposal from the boy’s perspective, then the boy breaks the old proposal and accepts the new one.
If the proposal is not a better one, the boy rejects the proposal. Key of Proof
Consider arbitrary g. If g prefers b’ to b, then b’ must have rejected g and been paired with some g’ whom he prefers to g. As choice of g is arbitrary, there are no unstable pairs.
Algorithm completes within N2 iterations and is ‘girl-optimal’.
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
24
Vertex/Node Cover Definition
Set of nodes NC of G such that every edge of G has at least one node in NC
Observe: ‘Opposite’ of Matching Max cardinality of matching is at most the min
cardinality of node cover Equal in a bi-partite graph
Application Choose a min set of nodes in an ad-hoc
network to exercise control over all the links
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
25
Min Cost Cycle Cover Problem: Cover all
nodes with disjoint cycles
Want least total cost of these cycles
Formulate G’ Replicate V into U, W Join ui to wj if (vi,vj)E cost(ui,wj) = cost(vi,vj)
Observe G’ is bipartite Cycle Cover in G is
perfect matching in G’ Therefore
Evaluate min cost perfect matching in G’
Polynomial time (bi-partite)
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
26
Euler’s Formula For any convex polyhedron,
V-E+F=2 V = Vertices E = Edges F = Faces
Examples Tetrahedron: V=4, E=6, F=4 Cube: V=8, E=12, F=6 Octahedron: V=6, E=12, F=8 Dodecahedron: V=20, E=30,
F=12 Icosahedron: V=12, E=30, F=20 BuckyBall: V=60, E=90, F=32
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
27
Proof of Euler’s Formula
Proof by induction If no edges, its an isolated vertex. So
V=1, E=0, F=1 Else choose any edge
If it connects two vertices, contract it. This reduces V by 1 and E by 1
Else the edge must separate two faces (Jordan curve). Remove it. Reduces F by 1 and E by 1.
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
28
Multicast Trees Application: Want to
send packets from a source (e.g. internet radio station) to many hosts
Sending n copies of the stream is wasteful
Solution: Form tree rooted at source that spans all member nodes
rrr
r
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
29
Distributed Algorithm Need to know address of group First Join
First member sends route request Request will be forwarded all the way to source Confirmation flows back to member All routers in path will add entry (mc_addr | port)
Subsequent Join New member send route request Request forwarded to router that has mc_addr entry Send confirmation from this point on Augment route entry (mc_addr | port1, port2)
Think: Optimal multicast tree
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
30 Multicast Algorithm (contd)
Leave/Pruning Node leaving sends leave message to
router Router removes port from route entry If last port entry deleted, send prune
message to parent Multi-source multicast tree
Less optimal: packets between two branches travel long distance
But need to minimize state in routers
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
31 Lessons from Today’s Lecture
Path algorithms useful for routing Prove correctness
Principle of Optimality allows distributedness
Matching useful in Switching etc
Key Analyses Correctness Optimality Complexity
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
32
Papers to read Coloring (one of the two)
H. Luo, S, Lu, and V. Bhargavan, “A New Model for Packet Scheduling in Multihop Wireless Networks,” Proceedings ACM Mobicom 2000, pp.76-86.
M. Kodialam, and T. Nandagopal, “Characterizing the Achievable Rates in Multihop Wireless Networks,” Proceedings ACM Mobicom 2003, San Diego, CA, September 2003.
Routing M. Kodialam and T. Lakshman, “Minimum Interference Routing with
Applications to MPLS Traffic Engineering,” Proceedings IEEE INFOCOM 2000.
S. Deering and D. Cheriton, "Multicast Routing in Internetworks and Extended LANs", SIGCOMM'88, Stanford, CA, Aug 1988, 55-64.
Matching Nick McKeown and Thomas E. Anderson, "A Quantitative Comparison
of Scheduling Algorithms for Input-Queued Switches", Computer Networks and ISDN Systems, Vol 30, No 24, pp 2309-2326, December 1998.
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
33
References
Graph Theory, by Frank Harary
Integer and Combinatorial Optimization, by G.L. Nemhauser and L.A. Wolsey
Network Flows: Theory, Algorithms and Applications by Ravindra K. Ahuja, Thomas L. Magnanti and James B. Orlin
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
34
Words of Wisdom (1) Graph Theory is an old field
Konigsberg Bridge problem: Euler 1736 Lots of famous people
18th and 19th Century: Euler, Hamilton, Gauss 20th Century: Erdos, Lovasz, Harary
It is a very deep field. Takes years to get to cutting edge
Replete in terminology – names for everything ! hole, cut, tree, forest, cycle, walk, degree,
girth, face, cover, heredity, clique, independence, animal
Lecture 3, 9/7/04
EE 228A, Fall 2004
Rajarshi Gupta
35
Words of Wisdom (2)
Searching for results in Graph Theory is tricky
E.g. “Clique Algorithms” yielded nice list of referrences … 150 pages long !!!
Need to have some understanding of Graph Theory to be able to utilize its results
Take IEOR 266: Network Flows and Graphs