Applications, Advantages and Disadvantages of Graph (original) (raw)

Last Updated : 23 Jul, 2025

**Graph is a non-linear data structure that contains nodes (vertices) and edges. A graph is a collection of set of vertices and edges (formed by connecting two vertices). A graph is defined as **G = {V, E} where **V is the set of vertices and **E is the set of edges.

Graphs can be used to model a wide variety of real-world problems, including social networks, transportation networks, and communication networks. They can be represented in various ways, such as by a set of vertices and a set of edges, or by a matrix or an adjacency list. The two most common types of graphs are directed and undirected graphs.

Terminologies of Graphs:

.An edge is one of the two primary units used to form graphs. Each edge has two ends, which are vertices to which it is attached.

.If two vertices are endpoints of the same edge, they are adjacent.

.A vertex's outgoing edges are directed edges that point to the origin.

.A vertex's incoming edges are directed edges that point to the vertex's destination.

.The total number of edges occurring to a vertex in a graph is its degree.

.A vertex with an in-degree of zero is referred to as a source vertex, while one with an out-degree of zero is known as sink vertex.

.A path is a set of alternating vertices and edges, with each vertex connected by an edge.

.The path that starts and finishes at the same vertex is known as a cycle.

.A path with unique vertices is called a simple path.

.A spanning subgraph that is also a tree is known as a spanning tree.

.A connected component is the unconnected graph's most connected subgraph.

.A bridge, which is an edge of removal, would sever the graph.

.Forest is a graph without a cycle.

**Graph Representation:

Graph can be represented in the following ways:

  1. **Set Representation: Set representation of a graph involves two sets: Set of vertices **V = {V 1 , V 2 , V 3 , V 4 } and set of edges E = {{V 1 , V 2 }, {V 2 , V 3 }, {V 3 , V 4 }, {V 4 , V 1 }}. This representation is efficient for memory but does not allow parallel edges.
  2. **Sequential Representation: This representation of a graph can be represented by means of matrices: Adjacency Matrix, Incidence matrix and Path matrix.
    • **Adjacency Matrix: This matrix includes information about the adjacent nodes. Here, **a ij = 1 if there is an edge from V i to **V jotherwise **0. It is a matrix of order **V×V.
    • **Incidence Matrix: This matrix includes information about the incidence of edges on the nodes. Here, **a ij = 1 if the j th edge **E jis incident on **i th vertex **V i otherwise 0. It is a matrix of order V×E.
    • **Path Matrix: This matrix includes information about the simple path between two vertices. Here, **P ij = 1 if there is a path from **V ito **V j otherwise **0. It is also called as reachability matrix of graph **G.
  3. **Linked Representation: This representation gives the information about the nodes to which a specific node is connected i.e. adjacency lists. This representation gives the adjacency lists of the vertices with the help of array and linked lists. In the adjacency lists, the vertices which are connected with the specific vertex are arranged in the form of lists which is connected to that vertex.

**Real-Time Applications of Graph:

**Advantages of Graph:

**Disadvantages of Graph: