Graph
Download
1 / 15

- PowerPoint PPT Presentation


  • 286 Views
  • Updated On :

V = { a, b, c, d, e, f, g, h, i, j, k, l }. E = { ( a, b ) , ( a, e ) , ( b, e ) , ( b, f ) , ( c, j ) , ( c, g ) , ( c, h ) , ( d, h ) , ( e, j ) , ( g, k ) , ( g, l ) , ( g, h ) , ( i, j ) }. Graph. A graph G is a set V ( G ) of vertices ( nodes ) and a set E ( G ) of

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about '' - jacob


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Graph l.jpg

V = { a, b, c, d, e, f, g, h, i, j, k, l }

E = { (a, b), (a, e), (b, e), (b, f), (c, j), (c, g), (c, h), (d, h), (e, j),

(g, k), (g, l), (g, h), (i, j) }

Graph

A graphG is a set V(G) of vertices (nodes) and a set E(G) of

edges which are pairs of vertices.

a

b

c

d

e

f

g

h

i

j

k

l


A directed graph l.jpg

TW 45

BOS

NW 35

ORD

SFO

DL 247

JFK

AA 903

DL 335

UA 877

AA 1387

UA 120

MIA

AA 49

AA 523

LAX

DFW

AA 411

A Directed Graph

In a directed graph (digraph), edges are ordered pairs.

From Goodrich and Tamassia (1998)


Applications of graphs l.jpg

George

Paul

Linda

Ringo

Yoko

John

Applications of Graphs

Graphs describe relationships

The Internet

Streets / Highways (Roadmaps)

Molecules

Flow Charts

Social Networks

Geometric Surfaces (CAD)

Circuits

Parts in an Assembly


More general graphs l.jpg

A pseudograph is a multigraph that allows self-loops (edges

from a vertex to itself).

2

1

3

5

6

4

More General Graphs

A multipgraphallows multiple edges between two vertices.

a

c

b

d

f


Edges degrees l.jpg

deg(w) = 1

e

2

degree(u) = 2

e

1

incident on

u and v

c

source

b

a

e

destination

d

Edges & Degrees

w

u

u and v are adjacent

endpoint

v

in-degree(b) = 3

out-degree(b) = 4


Handshaking theorem l.jpg

deg(v) = 2 | E |

v V

4

2

K has ( ) = 6 edges

4

If G is directed:

indeg(v) = outdeg(v) = | E |

v V

v V

Handshaking Theorem

Let G = (V, E) be an undirected simple graph.

| E | ≤ | V | · (| V | – 1) / 2

| E | ≤ | V | · (| V | – 1)


Slide7 l.jpg

a

b

c

d

Simple path:

a, e, k, p, l, q

m, h, d, c, g

e

f

h

g

(no repeated

vertices)

m

j

k

l

p

q

n

o

Path

A path of length k is a sequence v , v , …, v of vertices such

that (v , v ) for i = 0, 1, …, k – 1 is an edge of G.

0 1 k

i i+1

b, c, d not a path

Non-simple path:

a, b, e, f, g, b, g, l


Cycle l.jpg
Cycle

A cycle is a path that starts and ends at the same vertex.

A simple cycle has no repeated vertices.

a

b

c

d

e

f

h

g

m

j

k

l

k, j, n, k, p, o,k

is not simple.

p

q

n

o


Subgraph l.jpg
Subgraph

A subgraphH of G

is a graph;

its edges and vertices are subsets of those of G.

a

b

c

d

e

f

h

g

m

j

k

l

p

q

n

o

V(H) = {b, d, e, f, g, h, l, p, q} E(H) = {(b, e), (b, g), (e, f), (d, h), (l, p), (l, q)}


Connectivity l.jpg

a

d

f

g

b

c

f

e

C

3

C

2

a

C

d

e

1

b

c

Connectivity

G is connected if there is a path between every pair of vertices.

If G is not connected, the maximal connected subgraphs are the

connected componentsof G.


Strong weak connectivity l.jpg

It is weakly connected if the underlying undirected graph is

connected.

c

f

a

b

e

d

Strong & Weak Connectivity

A directed graph is strongly connected if every two vertices

are reachable from each other.

b

a

e

f

d

c


Property of connectivity l.jpg

If G is connected, then | E | ≥ | V | – 1.

If G is a tree, then | E | = | V | – 1.

If G is a forest, then | E | ≤ | V | – 1.

Property of Connectivity

Let G = (V, E) be an undirected graph.


Adjacency lists l.jpg

Adj

1

2

2

3

5

2

1

3

1

3

3

1

2

4

5

4

3

5

5

4

5

1

3

4

Adjacency Lists

If G is directed, the total length of all the adjacency lists is | E |.

If G is undirected, the total length is 2 | E |.

Space requirement: (|V| + |E|). Preferable representation.


Adjacency matrix l.jpg

A = (a )

ij

2

1 if (i, j)  E(G)

a =

1

3

ij

0 otherwise

1 2 3 4 5

5

4

  • 0 1 1 0 1

  • 1 0 1 0 0

  • 1 1 0 1 1

  • 0 0 1 0 1

  • 1 0 1 1 0

2

Space: (|V| ).

Adjacency Matrix

Preferred when the graph is small or dense.


Operation time l.jpg

Test adjacency

of u and v

(min(deg(u), deg(v)) (1)

2

Space (|V|+|E|) (|V| )

Lecture notes modified over Dr. Fernandez-Baca’s

Operation Time

Operation Adjacency List Adjacency Matrix

Scan incident edges (deg(v)) (|V|)

Scan outgoing edges (outdeg(v)) (|V|)

Scan incoming edges (indeg(v)) (|V|)


ad