Graphs

Post on 20-Jan-2016

28 views 0 download

Tags:

description

Denver. Chicago. LA. Miami. Tampa. Graphs. A Graph G = (V, E) consists of V, a nonempty set of vertices (or nodes ) and E, a set of edges . Each edge has either one or two vertices associated with it, called its endpoints. An edge is said to connect its endpoints. - PowerPoint PPT Presentation

transcript

Graphs

A Graph G = (V, E) consists of V, a nonempty set of vertices (or nodes) and E, a set of edges. Each edge has either one or two vertices associated with it, called its endpoints. An edge is said to connect its endpoints.

A very simple Computer Network : An example of a simple graph

It is also an undirected graph (edges have no direction).

Tampa

Chicago

Miami

Denver

LA

No two different edge connect the same pair of vertices

Tampa

Chicago

Miami

Denver

LA

Now each edge has a direction associated to it. The edges are called directed edges and the graph is called a directed graph.

A directed edge is associated with an ordered pair of vertices (u, v). The edge is said to start at u and end at v.

Note that e = (u, v) and f = (v, u) are two different directed edges

Chicago

Miami

Denver

LA

There are multiple edges (edges connecting the same pair of vertices).

The graph is not simple and is called (undirected) multigraphs.

Tampa

Chicago

Miami

Denver

LA

There are loops in the graph, and the graph is sometimes called a pseudograph.

Example: Acquaintanceship Graph

Use graph to represent various relationships between people.

John

Mary

Helen

Charles

Doug

Edge connecting two people when they know each other.

The graph is undirected with no multiple edges, or loops.

Example: Call Graphs

Use graph to model telephone calls made in a network (say a long distance telephone network).

352-343-3424

352-343-1453

352-343-6745

352-343-2563

Each directed edge (u, v) represents a call from u to v.

Vertices are phone numbers.

A directed graph

Example: The Web Graph

The World Wide Web can be modeled as a directed graph.

A vertex represents a web page and a directed edge (u, v) represents a link on u pointing to v.

WebCT

Cot3100Homepage

Slides

Extra Credit Assignment

Each directed edge (u, v) represents a link on u pointing to v.

Vertices are web pages.

A directed graph

Graph Terminology

Two vertices u and v in an undirected graph G are called adjacent (or neighbors) in G if u and v are endpoints of an edge of G.

If e is associated with { u, v }, the edge e is called incident with the vertices u and v. The edge e is also said to connect u and v, and u and v are endpoints of e.

The degree of a vertex in an undirected graph is the number of edges incident with it (a loop contributes twice to the degree of that vertex).

John

Mary

Helen

Charles

Doug

deg ( Mary) = 3, deg(John) = 1, deg(Charles)=2, deg(Doug)= 2 and

deg(Helen) = 2.

The Handshaking Theorem

Let G = (V, E) be an undirected graph with e edges. Then

2 e = Σv deg(v)

If we add all the degrees (of vertices), each edge will be counted twice. Hence the result.

Corollary: An undirected graph has an even number of vertices of odd degree.

2 e = Σv deg(v) = Σ v:odd deg(v) + Σ v:even deg(v)

John

Mary

Helen

Charles

Doug

deg ( Mary) = 3, deg(John) = 1, deg(Charles)=2, deg(Doug)= 2 and

deg(Helen) = 2.

The sum of all degrees is 10

There are 5 edges.

There are two vertices with odd degree.

352-343-3424 out-degree=1, in-dgree=2

352-343-1453In-degree=3out-degree=2

352-343-6745 out-degree=4

352-343-2563 in-degree = 3, out-degree=1

Cycles n vertices, v1, v2, ….., vn and edges

{ v1, v2 }, …, {vn-1, vn }

e

f

g

a bc

d

{a, b, d }, {c, e, f, g}

K3, 4

Males, or warehouses

females, or suppliers

If a is in V1, then, b, d, e must be in V2 (why?)

Then, c is in V1 and there is no inconsistency.

So we can rearrange the graph as follows: