Graphs Introduction Graph Graph A graph G = ( V , E ) is a set V - - PowerPoint PPT Presentation

graphs introduction graph
SMART_READER_LITE
LIVE PREVIEW

Graphs Introduction Graph Graph A graph G = ( V , E ) is a set V - - PowerPoint PPT Presentation

Graphs Introduction Graph Graph A graph G = ( V , E ) is a set V of vertices connected by an edge set E . 2 / 13 Variations Multi-Graph: Multiple edges between two vertices. Directed: Edges have a direction. Weighted: Vertices and/or edges


slide-1
SLIDE 1

Graphs – Introduction

slide-2
SLIDE 2

Graph

Graph A graph G = (V, E) is a set V of vertices connected by an edge set E.

2 / 13

slide-3
SLIDE 3

Variations

Multi-Graph: Multiple edges between two vertices. Directed: Edges have a direction. Weighted: Vertices and/or edges have weights. Simple: No multiple edges, no loops. Simple Undirected Graph A simple undirected graph G = (V, E) is a set V of vertices connected by an edge set E ⊆

  • {u, v} | u, v ∈ V, u = v
  • . An edge {u, v} is usually

written as uv.

3 / 13

slide-4
SLIDE 4

Implementation: Adjacency List

For each vertex, there is an array storing “pointers” to all neighbours. (Usually, the vertex index is sufficient.)

1 2 3 4 5

G

1 2 3 4 5 1 3 4 2 5 1 3 2 4 3 5 1 4

4 / 13

slide-5
SLIDE 5

Adjacency

Adjacency Two vertices u and v are adjacent if there is an edge connecting them. This is sometimes written as u ∼ v.

v b a c

v is adjacent to b and c but not to a.

5 / 13

slide-6
SLIDE 6

Neighbourhood

Neighbourhood The open neighbourhood N(v) = { u ∈ V | u = v, u ∼ v} of a ver- tex v is the set of vertices adjacent to v (not including v). The closed neighbourhood N[v] = N(v) ∪ {v} includes v.

v b a c

N(v) = {b, c} N[v] = {v, b, c}

6 / 13

slide-7
SLIDE 7

Degree

Degree The degree deg(v) of a vertex v is the number of incident edges. Note that the degree is not necessarily equal to the cardinality of neighbours.

v b a c

deg(v) = 3 deg(a) = 1 deg(b) = 5 deg(c) = 1

7 / 13

slide-8
SLIDE 8

Path

Path A set P = {v0, v1, . . . , vk} of distinct vertices is called path (of length k) if

vi is adjacent to vi+1 for all i with 0 ≤ i < k.

a b c d e f g h i

P = {h, e, c, b, f , g, i} is a path of length 6.

8 / 13

slide-9
SLIDE 9

Cycle

Cycle A path P = {v0, v1, . . . , vk} is called cycle (of length k + 1) if v0 is adjacent to vk.

a b c d e f g h i

{h, e, c, b, f , g} is a cycle of length 6.

9 / 13

slide-10
SLIDE 10

Distance

Distance The distance d(u, v) of two vertices u and v is the length of the shortest path from u to v.

u v

d(u, v) = 3

10 / 13

slide-11
SLIDE 11

Subgraph

Subgraph A graph G′ = (V ′, E′) is a subgraph of a graph G = (V, E) if V ′ ⊆ V and

E′ ⊆ E. G G′

Note that u, v ∈ V ∩ V ′ and uv ∈ E does not imply uv ∈ E′.

11 / 13

slide-12
SLIDE 12

Induced Subgraph

Induced Subgraph For a graph G = (V, E) and a set U ⊆ V, the induced subgraph G[U] of G is defined as G[U] = (U, E′) with E′ = { uv | u, v ∈ U; uv ∈ E }

a b c d e f g h i

G

b c d e f g a h i

G

  • {b, c, d, e, f , g}
  • 12 / 13
slide-13
SLIDE 13

Connected Component

Connected Component A connected component of an (undirected) graph is a maximal subgraph in which any two vertices can be connected by a path. A graph with three connected components.

13 / 13