tcom 540/11 tcom 540 session 2. tcom 540/12 web page om540541.htm

62
TCOM 540/1 1 TCOM 540 Session 2

Upload: ferdinand-bryan

Post on 20-Jan-2016

237 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 1

TCOM 540

Session 2

Page 2: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 2

Web Page

• http://teal.gmu.edu/ececourses/tcom540/TCOM540541.htm

Page 3: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 3

Set Theory

• A set is a collection of (mathematical) objects– E.g., {A, B, C}– E.g., {1,2,3, …, 99}

• sS means “s is a member of S”• s ~ 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

Page 4: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 4

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

Page 5: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 5

Set Theory (3)

Intersection

Union

Page 6: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 6

Set Theory (4)

• Cartesian Product of two sets, S and T, is the set SxT – Elements are (s,t) where s S and t T

• The graph of a function f:S T is the subset of SxT that consists of

{(s,t) f(s) = t)}

Page 7: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 7

Graphs

• A graph consists of a set of vertices (or nodes) V and a set of edges E

A

D

I

ZC

B

Page 8: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 8

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

Page 9: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 9

Some Definitions for Graphs (2)

• A path between vertices v1 and vn is a set of edges (e1, e2, …, en) 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

Page 10: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 10

A Small (But Not Simple) Graph

A

D

I

ZC

B

Parallel edges

LoopNode degree 3

Adjacent nodes

(DZ), (ZB), (BI), (ID) is a cycle.

This graph is connected

Page 11: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 11

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

Page 12: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 12

Another Graph

A

D

I

ZC

N

K

M

J

e1

e2

e3

e4

e5

e6

e7

e8

( (D, Z, B, M, J), (e2, e8, e4)) is a subgraph

It is not a component.

The two right-hand components are isomorphic

X

Q

R H

e11

e99

Pe15

e16

e12B

e13

e9

Page 13: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 13

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

Page 14: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 14

Tree, Star, Chain

Page 15: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 15

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]

Page 16: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 16

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

Page 17: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 17

Node Locations

0

2000

4000

6000

8000

10000

0 2000 4000 6000 8000 10000

Page 18: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1

A Real Network (Backbone Not Shown)

Vendor A Cost: $1.159MVendor B Cost: $1.213M164 Hosts

Page 19: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 19

Real Network Detail (Atlanta, GA)

Stand Alone

Hosts

Page 20: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 20

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

Page 21: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 21

Kruskal’s Algorithm for MST

Is G connected?yes no stop

Sort edgesin ascending

order ofweight

Mark each node as Separate

component

Loop on edgesLet e be candidate edgeIf ends of e are in different components, accept e

Stop when number of edges = N(G) - 1

Page 22: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 22

Kruskal’s Algorithm for MST (2)

27

30

25

26

2129

31

Page 23: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 23

Kruskal’s Algorithm for MST (2)

27

30

25

26

21

1st add

21

29

31

Page 24: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 24

Kruskal’s Algorithm for MST (2)

27

30

25

26

21

1st add

21

2nd add

2521

29

31

Page 25: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 25

Kruskal’s Algorithm for MST (2)

27

30

25

26

21

1st add

21

2nd add 3rd add

2521

27

2521

29

31

Page 26: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 26

Kruskal’s Algorithm for MST (2)

27

30

25

26

21

1st add

21

2nd add 3rd add

2521

27

2521

29

4th add

27

2521

29

31

Page 27: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 27

Prim’s Algorithm for MSTStart with all nodesunconnected and

Label = infinity

Select rootnode

Scan neighbors, update Labels =min edge to tree

Add closest neighbor

(smallest Label)

Stop whenN(G) –1added

Page 28: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 28

Prim’s Algorithm for MST (2)

27

30

25

26

2129

31

Choose as root

Page 29: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 29

Prim’s Algorithm for MST (2)

27

30

25

26

2129

31

Choose as root

27

1st Add

Page 30: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 30

Prim’s Algorithm for MST (2)

27

30

25

26

2129

31

Choose as root

27

1st Add

27

21

2nd Add

Page 31: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 31

Prim’s Algorithm for MST (2)

27

30

25

26

2129

31

Choose as root

27

1st Add

27

21

2nd Add

27

2521

3rd Add

Page 32: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 32

Prim’s Algorithm for MST (2)

27

30

25

26

2129

31

Choose as root

27

1st Add

27

21

2nd Add

27

2521

3rd Add

27

2521

29

4th Add

Page 33: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 33

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

Page 34: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 34

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

= (n1,n2traffic(n1,n2)*hops(n1,n2))/n1,n2traffic(n1,n2)

Page 35: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 35

MSTs Do Not Scale (2)

0

2

4

6

8

10

12

14

16

0 20 40 60 80 100 120

Number of Nodes

Avera

ge H

op

s

Page 36: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 36

MSTs Do Not Scale (3)

0

20000

40000

60000

80000

100000

120000

140000

160000

0 50 100 150

Number of Nodes

Tra

ffic Total Traffic

Summed Traffic

Page 37: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 37

Definitions

• For a weighted graph (G,w), and nodes n1 and n2, the shortest path P from n1 to n2 minimizes ePw(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

Page 38: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 38

Dijkstra’s Algorithm for Shortest-Path Trees

1. Mark each node unscanned, assign label infinity2. Set label of root to 0, and predecessor to self3. 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

Page 39: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 39

Dijkstra ExampleChoose as root 1

2

5

3

27

30

25

1

214

29

31

Page 40: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 40

Dijkstra ExampleChoose as root

1 & 2. Nodes adjacent to root

1

2

527

30

Label = 27

Label = 30

1

2

5

3

27

30

25

1

214

29

31

Page 41: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 41

Dijkstra ExampleChoose as root

1

2

527

30

Label = 27

Label = 30

3. Nodes adjacent to 2

1

2

527Label = 28

1

2

5

3

27

30

25

1

214

29

31

1

1 & 2. Nodes adjacent to root

321Label = 48

Page 42: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 42

Dijkstra Example

1

2

5

3

27 1

4

31

Choose as root

4&5. Nodes adjacent to 5

1

2

5

3

27

30

25

26

214

29

31

Label = 59

1

2

527

30

Label = 27

Label = 30

3&4. Nodes adjacent to 2

1

2

527Label = 28

1

1 & 2. Nodes adjacent to root

321Label = 48

25

Label = 53

Page 43: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 43

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

Page 44: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 44

Prim-Dijkstra Trees

• We play with the definition of the Label

• Prim’s Label

= minneighborsdist(node, neighbor)

• Dijkstra’s Label

= minneighbors[dist(root, neighbor) + dist(neighbor, node)]

• Prim-Dijkstra Label =

= minneighbors[*dist(root, neighbor) + dist(neighbor, node)]

• Now is a parameter that we choose, between 0 and 1

Page 45: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 45

Varying Alpha

0.000

0.200

0.400

0.600

0.800

1.000

1.200

0 0.5 1

Alpha

No

rmali

zed

Valu

e

Normalized Avg Hops

Normalized delay

Normalized Cost

Page 46: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 46

Tours

• A tree design may be unreliable

• A tour adds one link to significantly increase reliability

• A tour of a set of vertices (v1, v2, …, vn) is a set of n edges such that each vertex has degree 2 and the graph is connected

Page 47: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 47

Tours (2)

• Leads to the (in)famous Traveling Salesman Problem (TSP)– Given a set of vertices (v1, v2, …, vn) and a

distance function d(vi,vj) between vertices, find the tour T(vti) such that d(vti,ti+1) is minimized

Page 48: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 48

Reliability of a Tree

• Reliability = probability that functioning nodes are connected by working links

• For a tree, reliability = (1-p)n-1, where– p = probability of a link failing– n = number of nodes

• P(failure) = 1- reliability = 1 - (1-p)n-1

(n-1)*p

Page 49: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 49

Reliability of a Ring

• A ring can tolerate one failure

• For a ring,

P(failure) = 1- (1-p)n – n*p*(1-p)n-1

0.5*n*(n-1)*p2 if p is small

X

Page 50: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 50

A Simple Algorithm for Building a Tour

• Denote a root node, set current node = root

• Loop through nodes– Find closest node (not in tour) to current node– Add an edge to it– Reset current node to be this node just added

• Create an edge between last node and root

Page 51: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 51

Creditable Solutions and Creditability Tests

• A solution is creditable if it is a local optimum– I.e., it is not creditable if, by some method, we

can manipulate the solution to a better one

• Cahn uses a crossing test to determine creditability of the simple tour-building algorithm– It does not do well ….

Page 52: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 52

A Better Tour-Building Algorithm

• Look for closest neighbor to any node in the partial tour (not just the last one added)

• Insert between two adjacent nodes in tour in “best” place– Minimum increase in partial tour length

• Also “farthest neighbor” heuristic – Avoids stranding distant nodes

Page 53: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 53

A Difficulty

• TSP tours do not scale– Similar to trees in this respect– Average number of hops increases O(n)

Page 54: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 54

2-Connectivity

• A vertex v of a connected graph G = (V, E) is an articulation point if removing the vertex and all attached edges disconnects the graph

• If a connected graph has no articulation points, it is said to be 2-connected

Page 55: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 55

Connecting 2-Connected Graphs

• Suppose G1 = (V1, E1) and G2 = (V2, E2) are two disjoint 2-connected graphs. Take v1 and v2 from G1 and v3 and v4 from G2 and add the edges (v1,v3) and (v2,v4). The resulting graph is 2-connected

Page 56: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 56

Connecting 2-Connected Graphs

• Suppose G1 = (V1, E1) and G2 = (V2, E2) are two disjoint 2-connected graphs. Take v1 and v2 from G1 and v3 and v4 from G2 and add the edges (v1,v3) and (v2,v4). The resulting graph is 2-connected

• Roughly, if you connect 2 pairs of vertices from two 2-connected graphs, the resulting graph is 2-connected

Page 57: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 57

Heuristic Based on Partitioning

• Divide set of nodes into multiple “clusters”

• Use nearest-neighbor algorithm to build TSP tour on each cluster

• Connect clusters, ensuring no connectors have a common vertex

• Resulting graph is 2-connected

Page 58: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 58

Heuristic Based on Partitioning

Page 59: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 59

Heuristic Based on Partitioning

Select clusters

Page 60: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 60

Heuristic Based on Partitioning

Select clustersDevelop TSPs

Page 61: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 61

Heuristic Based on Partitioning

Select clustersDevelop TSP toursJoin clusters

Page 62: TCOM 540/11 TCOM 540 Session 2. TCOM 540/12 Web Page  OM540541.htm

TCOM 540/1 62

Homework

• Read Chapter 4 of Cahn

• Do exercises 2.8, 2.9, 3.1, 3.8 (note: there seem to be typos here – use figure 3.9, and extend table 3.15)