+ All Categories
Home > Documents > Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d),...

Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d),...

Date post: 17-Jan-2018
Category:
Upload: bernard-martin
View: 244 times
Download: 0 times
Share this document with a friend
Description:
adjacency matrix:
21
Graph Theory
Transcript
Page 1: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

Graph Theory

Page 2: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

undirected grapha

b c

e f

d

node: a, b, c, d, e, fedge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f)

a

b c

e d

subgraph

Page 3: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

adjacency matrix:

A

abcdef

a b c d e f

0 1 1 0 0 01 0 1 0 1 01 1 0 1 0 10 0 1 0 1 10 1 0 1 0 10 0 1 1 1 0

a

b c

e f

d

Page 4: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

directed graph ( digraph)

a b

d c

Aabcd

a b c d

0 1 0 00 0 1 10 0 0 01 0 1 0

Page 5: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

weighted graph

v0 v1

v4 v2

v3

6

53

8

9

1 4

7

weight matrix

01234

0 1 2 3 40 6 0 8 16 0 5 3 00 5 0 4 78 3 4 0 91 0 7 9 0

Page 6: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

a

b c

e f

d

pathcycle

Page 7: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

C

1 1 1 11 1 1 10 0 1 01 1 1 1

connectivity matrix CCjk= 1 if there is a path of length 0 or more from vj to vk

0 otherwiseC: reflexive and transitive closure of G.

a b

d c

Page 8: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

How to compute the connectivity matrix?Matrix multiplication

﹡ → (AND)+ → (OR)e. g. Z = X‧Y

Zij= (xi1y1j)(xi2y2j)…(xinynj)

Page 9: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

the algorithm:matrix B

bjk=ajk for jkbjj=1

that is,

bjk=1 if there is a path of length 0 or 1 from vj to vk vj to vk 0 otherwiseB2 represents paths of length 2 or less.B4

…Bn

Page 10: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

B

1 1 0 00 1 1 10 0 1 01 0 1 1

B B2 4

1 1 1 11 1 1 10 0 1 01 1 1 1

complexity: O(logn) matrix multiplications

a b

d c

Aabcd

a b c d

0 1 0 00 0 1 10 0 0 01 0 1 0

Page 11: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

Connected components

v5v0

v1

v3

v2

v4

Page 12: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

Assign each vertex a component number which is the smallest vertex label in the same component.

Step 1: Compute the connectivity matrix.

1 1 0 0 0 11 1 0 0 0 10 0 1 1 0 00 0 1 1 0 00 0 0 0 1 01 1 0 0 0 1

Page 13: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

Step 2: In each row, find the smallest label. component 0: v0, v1, v5 component 2: v2, v3

component 4: v4

Page 14: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

complexity: same as that for computing the connectivity matrix.e. g. on hypercubes

time: O(log2n)processor: n3

Page 15: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

All pairs shortest path

v0

v2

v1

6

4

2113A

0 4 116 0 23 0

Page 16: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

a sequential method — dynamic programming

aijk

for k=0 to n-1 do for i=0 to n-1 do for j=0 to n-1 do

111,min kkj

kik

kij

kij aaaa

: the length of a shortest path from vi to vj going through no vertex of label greater than k.

kjikijij aaaa ,min

Page 17: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

A 00 4 116 0 23 7 0

A 10 4 66 0 23 7 0

073205640

2A ←shortest pathstime: O(n3)

v0

v2

v1

6

4

2113 A

0 4 116 0 23 0

Page 18: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

a parallel method matrix multiplication an algorithm similar to

that computes the connectivity matrix.

d d dijk

l ilk

ljk min / /2 2

in matrix multiplication:* → + + →min

Page 19: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

We can compute D1, D2, D4, D8,…, Dn.complexity: O(log n) matrix multiplicationse.g. on hypercubes

time: O(log2n)processor: n3

Page 20: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

Minimum spanning trees

1

3

62

9

1 6

9

1 2

9

Page 21: Graph Theory. undirected graph node: a, b, c, d, e, f edge: (a, b), (a, c), (b, c), (b, e), (c, d), (c, f), (d, e), (d, f), (e, f) subgraph.

Recommended