25
Graph Theoretic Concepts

Graph Theoretic Concepts. What is a graph? A set of vertices (or nodes) linked by edges Mathematically, we often write G = (V,E) V: set of vertices,

Embed Size (px)

Citation preview

Graph Theoretic Concepts

What is a graph?

• A set of vertices (or nodes) linked by edges

• Mathematically, we often write G = (V,E)V: set of vertices, so |V| = number of verticesE: set of edges, so |E| = number of edges

13

4

2 5

Graphs

• A graph G (sometimes called networks) consists of two things:

(i) A set V = V(G) whose elements are called vertices, points, or nodes of G.

(ii) A set E = E(G) of unordered pairs of distinct vertices called edges of G.

• Vertices “u” and “v” are said to be adjacent if there is an edge e = {u, v} joining them.

• the edge “e” is said to be incident on each of its vertices u and v.

3

Example of a graph

4

Examples

e3

v2

v1

v3

e2e1

e4

1. Vertex set = {v1, v2, v3, v4, v5, v6}

2. Edge set = {e1, e2, e3, e4, e5, e6, e7}

3. e1, e2, and e3 are incident on v1

4. v2 and v3 are adjacent to v1

5. e2,, e3 and e4 are adjacent to e1

6. e6 and e7 are loops

7. e2 and e3 are parallel

8. v5 and v6 are adjacent to themselves

9. v4 is an isolated vertex

10. Endpoint(e5) = (v5, v6)

v4

v6

v5

e5

e7

e6

Degree of vertices in a graph

• The degree of a vertex “v” in a graph G, written deg (v), is equal to the number of edges in G incident on a vertex “v”.

• Each edge is counted twice in counting the degrees of the vertices of G.

• Therefore, sum of the degrees of the vertices of a graph G is equal to twice the number of edges in G.

• A vertex is said to be even or odd according as its degree is an even or an odd number. A vertex of degree zero is called an isolated vertex.

6

Various types of graphs

• Connected/disconnected graphs

• The circled subgraphs are also known as connected components

Various types of graphs

• Weighted/unweighted graphs

• You may treat unweighted edges to be weighted edges of equal weights

5

-2

7

4

0

Multigraphs

• The edges “e4” and “е5” are called multiple edges since they connect the same endpoints, and the edge “e6” is called a loop since its endpoints are the same single vertex.

9

Complete, regular and bipartite graphs

• A graph G is said to be complete if every vertex in G is connected to every other vertex in G.

A graph G is regular of degree k or k-regular if every vertex has degree k. (I.e every vertex has equal number of edges)

• A graph G is said to be bipartite if its vertices V can be partitioned into two subsets M and N such that each edge of G connects a vertex of M to a vertex of N.

• By a complete bipartite graph, we mean that each vertex of M is connected to each vertex of N.

10

Graphs.G1

11

Graph G1 is complete, 3-regular and G2 bipartite graphs

Graphs.G2

Directed(digraphs)/undirected graphs

• You may treat each undirected edge as two directed edges in opposite directions

Directed graphs or digraphs

• Directed graphs are graphs in which the edges are one-way or arrows. A directed graph G or digraph consists of two things:

• (i) A set V whose elements are called vertices, nodes, or points.

• (ii) A set of ordered pairs (u, v) of vertices called arcs or directed edges.

14

Directed graphs

15

Degrees of digraph

• The outdegree of a vertex v of G, written outdeg(v), is the number of arcs beginning at v, and the indegree of v, written indeg(v), is the number of arcs ending at v. each arc begins and ends at a vertex.

• Theorem: The sum of the outdegrees of the vertices of a digraph G equals the sum of the indegrees of the vertices, which equals the number of edges in G.

16

Adjacency matrix of digraph

X Y Z W

17

XYZW

No. of 1’s in A is equal to no. of edges, row total and col. Gives the indegree and outdegree, resp.

Adjacency list

In graph theory, an adjacency list is the representation of all edges or arcs in a graph as a list.

Connectivity of digraphs• There are three types of connectivity in a directed graph G:

• (i) G is strongly connected or strong if, for any pair of vertices u and v in G, there is a path from u to v; and a path from v to u, that is, each is reachable from the other.

• (ii) G is unilaterally connected or unilateral if, for any pair of vertices u and v in G, there is a path from u to v or a path from v to u, that is, one of them is reachable from the other.

• (iii) G is weakly connected or weak if there is a undirected path between any pair of vertices u and v in G.

19

Digraphs and relations

• The relation R is reflexive if every node has a loop.• The relations R is symmetric if arcs are bidirectional.• The relation R is transitive if for any sequence of

consecutive arcs, there is a single arc from the first to the last node.

20

Digraphs and relations

21

Paths and connectivity• A path in a graph G consists of an alternating sequence

of vertices and edges of the form;

v0, e1, v1, e2, v2, ………., en-1, vn-1 , еn, vn

• where each edge ei contains the vertices vi-1 and vi (which appear on the sides of edge ei in the sequence).

• The path is said to be closed if v0 = vn. Otherwise, we say the path is from v0 to vn, or between v0 and vn, or connects v0 to vn. A simple path is a path in which all vertices are distinct.

• Length of a path is the number of edges in the path.

• A graph G is connected if there is a path between any two of its vertices

22

Eulerian circuit vs Hamiltonian circuit

• A Hamiltonian circuit in a graph G, named after the nineteenth-century Irish mathematician William Hamilton A805-1865), is a closed path that visits every vertex in G exactly once.

• Eulerian circuit traverses every edge exactly once, but may repeat vertices, while a Hamiltonian circuit visits each vertex exactly once but may repeat edges.

• An Euler circuit for G is a circuit that contains every vertex and every edge of G. That is, an Euler circuit is a sequence of adjacent vertices and edges in G that starts and ends at the same vertex, uses every vertex of G at least once, and every edge exactly once.

23

■ A Hamilton path in a graph is a path that includes each vertex of the graph once and only once.

■ A Hamilton circuit is a circuit that includes each vertex of the graph once and only once. (At the end, of course, the circuit must return to the starting vertex.)

HAMILTON PATHS & CIRCUITS

Euler Paths and Circuits

Euler path- a continuous path that passes through every edge once and only once.

Euler circuit- when a Euler path begins and ends at the same vertex