670 likes | 804 Views
TCOM 540. Session 2. Web Page. http://teal.gmu.edu/ececourses/tcom540/spring04/TCOM540541.htm. Agenda. Some set and graph theory Some algorithms for simple network design. Set Theory. A set is a collection of (mathematical) objects E.g., {A, B, C} E.g., {1,2,3, …, 99}
E N D
TCOM 540 Session 2 TCOM 540/1
Web Page http://teal.gmu.edu/ececourses/tcom540/spring04/TCOM540541.htm TCOM 540/1
Agenda • Some set and graph theory • Some algorithms for simple network design TCOM 540/1
Set Theory • A set is a collection of (mathematical) objects • E.g., {A, B, C} • E.g., {1,2,3, …, 99} • s e S means “s is a member of S” • s ~ e S means “s is not a member of S” • T is a subset of S if every member of T is also a member of S • It’s a proper subset if there is at least one member of S that is not a member of T TCOM 540/1
Set Theory (2) • The set of all subsets of S is denoted as 2s • If S has n members, then 2s has 2n members • Union of two sets is the set of all their members • Intersection of two sets is the set of common members TCOM 540/1
Set Theory (3) Intersection Union TCOM 540/1
Set Theory (4) • Cartesian Product of two sets, S and T, is the set SxT • Elements are (s,t) where s e S and t eT • The graph of a function f:S T is the subset of SxT that consists of {(s,t) f(s) = t)} TCOM 540/1
Graphs • A graph consists of a set of vertices (or nodes) V and a set of edges E D C Z B A I TCOM 540/1
Some Definitions for Graphs • Each edge connects two vertices (may be same – then it’s called a loop) • Two edges are called parallel if they connect the same vertices • A graph is simple if it has no loops or parallel edges • The degree of a vertex is the number of edges it has • Two nodes are adjacent if there is an edge that has them as endpoints TCOM 540/1
Some Definitions for Graphs (2) • A path between vertices v1 and vn is a set of edges (e1, e2, …, en-1) such that ei and ei+1 have a common endpoint, and v1 is an endpoint of e1 and vn is an endpoint of en • A cycle is a path from a vertex to itself • A graph is connected if for any two nodes there is a path between them TCOM 540/1
A Small (But Not Simple) Graph D Parallel edges Adjacent nodes C Z B A I Loop Node degree 3 (DZ), (ZB), (BI), (ID) is a cycle. This graph is connected TCOM 540/1
Definitions (3) • A subgraph G* of a graph G with vertices V and edges E is a pair (V*, E*) where • V* is a subset of V • E* is a subset of E • If an edge belongs to E* then both its endpoints must belong to V* • A component of a graph is a maximal connected subgraph • Two graphs G1, G2 are isomorphic if there is a 1-to-1 mapping f:V1 V2 such that (v1, v2) is a member of E1 iff (f(v1), f(v2)) is a member of E2 TCOM 540/1
Another Graph X P e7 e15 e5 D J C K e2 Z e99 e9 e4 e8 e11 e6 e1 e16 B M Q e12 A e13 N I e3 H R ( (D, Z, B, M, J), (e2, e8, e4)) is a subgraph It is not a component. The two right-hand components are isomorphic TCOM 540/1
Definitions (4) • A tree is a connected simple graph without cycles • A star is a tree in which exactly one node has degree >1 • A chain is a tree in which no node has degree greater than 2 • Define N(G) = number of nodes in G TCOM 540/1
Tree, Star, Chain TCOM 540/1
V&H Coordinates • V&H coordinate grid covers U.S. • Approx 10,000 x 10,000 • Distance between points (v1, h1) and (v2, h2) for tariff calculations is sometimes defined as: • A simpler formulation is: • Note V&H assumes earth is flat … Dist = 1+int{[(dv2+9)/10+(dh2 +9)/10]0.5} Where dv = v1-v2 and dh = h1-h2 Dist = 1 + int[(dv2+dh2)/10]0.5 TCOM 540/1
Latitude and Longitude • V&H used primarily in North America • Most of world uses latitude and longitude (L&L) • Distances between points in L&L coordinates are computed using spherical geometry TCOM 540/1
Some V&H Coordinates TCOM 540/1
Node Locations 3 4 5 1 2 TCOM 540/1
A Real Network (Backbone Not Shown) Vendor A Cost: $1.159M Vendor B Cost: $1.213M 164 Hosts
Real Network Detail (Atlanta, GA) Stand Alone Hosts TCOM 540/1
Weighted Graph • A weighted graph is a graph G where each edge e has a weight w(e) • Denoted by (G, w) • Generally w(e) > 0 • Weight of a subgraph G* is sum of weights of edges in G* • Real networks are weighted graphs • Weight may be cost, delay, or other parameter • Minimum spanning tree (MST) is a connected subgraph with minimum weight TCOM 540/1
Kruskal’s Algorithm for MST Sort edges in ascending order of weight Is G connected? stop no yes Mark each node as Separate component Loop on edges Let e be candidate edge If ends of e are in different components, accept e Stop when number of edges = N(G) - 1 TCOM 540/1
Kruskal’s Algorithm for MST (2) 30 27 26 31 25 21 29 TCOM 540/1
Kruskal’s Algorithm for MST (2) 30 27 26 31 25 21 29 1st add 21 TCOM 540/1
Kruskal’s Algorithm for MST (2) 30 27 26 31 25 21 29 1st add 2nd add 25 21 21 TCOM 540/1
Kruskal’s Algorithm for MST (2) 30 27 26 31 25 21 29 1st add 2nd add 3rd add 27 25 25 21 21 21 TCOM 540/1
Kruskal’s Algorithm for MST (2) 30 27 26 31 25 21 29 1st add 2nd add 3rd add 4th add 27 27 25 25 25 21 21 21 21 29 TCOM 540/1
Prim’s Algorithm for MST Start with all nodes unconnected and Label = infinity Scan neighbors, update Labels = min edge to tree Select root node Add closest neighbor (smallest Label) Stop when N(G) –1 added Note - Final tree is independent of choice of root node. TCOM 540/1
Prim’s Algorithm for MST (2) 30 Choose as root 27 26 31 25 21 29 TCOM 540/1
Prim’s Algorithm for MST (2) 30 Choose as root 27 26 31 25 21 29 1st Add 27 TCOM 540/1
Prim’s Algorithm for MST (2) 30 Choose as root 27 26 31 25 21 29 1st Add 2nd Add 27 27 21 TCOM 540/1
Prim’s Algorithm for MST (2) 30 Choose as root 27 26 31 25 21 29 1st Add 2nd Add 3rd Add 27 27 27 25 21 21 TCOM 540/1
Prim’s Algorithm for MST (2) 30 Choose as root 27 26 31 25 21 29 4th Add 1st Add 2nd Add 3rd Add 27 27 27 27 25 25 21 21 21 29 TCOM 540/1
Limitations of MSTs • No redundancy • One link failure separates the network into two disconnected components • Big problem for large networks • May involve very long paths in large networks TCOM 540/1
MSTs Do Not Scale • Number of hops between nodes n1 and n2 is the number of edges in the path chosen by the routing algorithm • Average number of hops is traffic-weighted = (Sn1,n2traffic(n1,n2)*hops(n1,n2))/Sn1,n2traffic(n1,n2) TCOM 540/1
MSTs Do Not Scale (2) TCOM 540/1
MSTs Do Not Scale (3) TCOM 540/1
Definitions • For a weighted graph (G,w), and nodes n1 and n2, the shortest path P from n1 to n2 minimizes SeePw(e) • The shortest-path tree (SPT) rooted at node n1 is a tree T such that for any other node n2 the path from n1 to n2 is a shortest path • Note – unlike MSTs, SPTs have a special root node – different choice of root gives rise to different trees TCOM 540/1
Dijkstra’s Algorithm for Shortest-Path Trees • Mark each node unscanned, assign label infinity • Set label of root to 0, and predecessor to self • Loop through nodes • Find node n with smallest label • Mark as scanned • Examine all adjacent nodes m, see if distance through n < label • If so, update label, update predecessor(m) = n • Note that a link may drop out of the tree if a shorter route is found TCOM 540/1
Dijkstra Example 1 30 Choose as root 1 27 26 5 31 25 2 21 3 4 29 TCOM 540/1
Dijkstra Example 1 30 Choose as root 1 27 26 5 31 25 2 21 3 4 29 1 & 2. Nodes adjacent to root 30 1 27 5 Label = 30 2 Label = 27 TCOM 540/1
Dijkstra Example 1 30 Choose as root 1 27 26 5 31 25 2 21 3 4 29 3. Nodes adjacent to 2 1 & 2. Nodes adjacent to root Label = 30 30 1 1 27 5 27 5 Label = 30 2 2 21 3 Label = 27 Label = 48 TCOM 540/1
Dijkstra Example 1 30 Choose as root 1 27 26 5 31 25 2 21 3 4 29 3&4. Nodes adjacent to 2 4&5. Nodes adjacent to 5 1 & 2. Nodes adjacent to root Label = 30 30 30 1 1 1 27 27 5 27 5 5 Label = 30 31 2 2 2 21 21 3 3 Label = 27 Label = 48 Label = 48 4 Label = 61 TCOM 540/1
Dijkstra Example 2 30 1 27 26 5 31 25 2 21 3 Choose as root 4 29 TCOM 540/1
Dijkstra Example 2 30 1 27 26 5 31 25 2 21 3 Choose as root 4 29 1, 2 & 3. Nodes adjacent to root label = 25 5 label = 21 2 21 3 label = 29 29 4 TCOM 540/1
Dijkstra Example 2 30 1 27 26 5 31 25 2 21 3 Choose as root 4 29 4 & 5. Nodes adjacent to 2 1, 2 & 3. Nodes adjacent to root 48 label = 25 1 25 5 5 label = 21 21 2 2 21 3 3 label = 29 29 4 4 29 TCOM 540/1
Characteristics of SPTs • In a complete graph, SPT is a star* • High performance and reliability • But likely implies low link utilization, high expense * Unless triangle inequality does not hold TCOM 540/1
Prim-Dijkstra Trees • We play with the definition of the Label to define a heuristic algorithm • Prim’s Label = minneighborsdist(node, neighbor) • Dijkstra’s Label = minneighbors[dist(root, neighbor) + dist(neighbor, node)] • Prim-Dijkstra Label = = minneighbors[a*dist(root, neighbor) + dist(neighbor, node)] • Now a is a parameter that we choose, between 0 and 1 • At one extreme we get an MST, at the other we get an SPT, in between we get a hybrid TCOM 540/1
Varying Alpha TCOM 540/1