Monday, 11 December 2017

Chapter 6: Data Structure -Graphs

Chapter 6: Graph Data Structure

What is graph ? Explain.

A graph is a pictorial representation of a set of objects called vertices (nodes or points), these vertices are connected by links called edges (arcs or lines).

A graph can also be defined as a pair of sets (V, E), where V is the set of vertices and E is the set of edges, connecting the pairs of vertices(V).

Fig 6.1 Graph

In the above graph, Vertices V = {A, B, C, D, E} and Edges E = {AB, BD, CD, DE, AE}

Terminologies Used in Graph:


Adjacency

Two node or vertices are adjacent if they are connected to each other through an edge.

Example : Vertices A and B are adjacent in the above picture.

Edge

Edge represents a path(or line) between two vertices.

Example: In the above picture the lines from A to B, B to C, and so on represents edges.

Path

Path represents a sequence of edges between the two vertices.

Example: In the above picture, ABD represents a path from A to D.

Vertex

Each node of the graph is represented as a vertex.

Example: In the above picture A, B, C, D, E are vertices.