Open In App

Types of Graphs with Examples

Last Updated : 21 Apr, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

A Graph is a non-linear data structure consisting of nodes and edges. The nodes are sometimes also referred to as vertices and the edges are lines or arcs that connect any two nodes in the graph. More formally a Graph can be defined as, A Graph consisting of a finite set of vertices(or nodes) and a set of edges that connect a pair of nodes

  1. Undirected Graphs: A graph in which edges have no direction, i.e., the edges do not have arrows indicating the direction of traversal. Example: A social network graph where friendships are not directional.
  2. Directed Graphs: A graph in which edges have a direction, i.e., the edges have arrows indicating the direction of traversal. Example: A web page graph where links between pages are directional.
  3. Weighted Graphs: A graph in which edges have weights or costs associated with them. Example: A road network graph where the weights can represent the distance between two cities.
  4. Unweighted Graphs: A graph in which edges have no weights or costs associated with them. Example: A social network graph where the edges represent friendships.
  5. Complete Graphs: A graph in which each vertex is connected to every other vertex. Example: A tournament graph where every player plays against every other player.
  6. Bipartite Graphs: A graph in which the vertices can be divided into two disjoint sets such that every edge connects a vertex in one set to a vertex in the other set. Example: A job applicant graph where the vertices can be divided into job applicants and job openings.
  7. Trees: A connected graph with no cycles. Example: A family tree where each person is connected to their parents.
  8. Cycles: A graph with at least one cycle. Example: A bike-sharing graph where the cycles represent the routes that the bikes take.
  9. Sparse Graphs: A graph with relatively few edges compared to the number of vertices. Example: A chemical reaction graph where each vertex represents a chemical compound and each edge represents a reaction between two compounds.
  10. Dense Graphs: A graph with many edges compared to the number of vertices. Example: A social network graph where each vertex represents a person and each edge represents a friendship.

Types of Graphs:

1. Finite Graphs

 A graph is said to be finite if it has a finite number of vertices and a finite number of edges. A finite graph is a graph with a finite number of vertices and edges. In other words, both the number of vertices and the number of edges in a finite graph are limited and can be counted. Finite graphs are often used to model real-world situations, where there is a limited number of objects and relationships between the

2. Infinite Graph: 

A graph is said to be infinite if it has an infinite number of vertices as well as an infinite number of edges. 

3. Trivial Graph: 

A graph is said to be trivial if a finite graph contains only one vertex and no edge. A trivial graph is a graph with only one vertex and no edges. It is also known as a singleton graph or a single vertex graph. A trivial graph is the simplest type of graph and is often used as a starting point for building more complex graphs. In graph theory, trivial graphs are considered to be a degenerate case and are not typically studied in detail

4. Simple Graph:

A simple graph is a graph that does not contain more than one edge between the pair of vertices. A simple railway track connecting different cities is an example of a simple graph. 

 

5. Multi Graph:

Any graph which contains some parallel edges but doesn’t contain any self-loop is called a multigraph. For example a Road Map. 

  • Parallel Edges: If two vertices are connected with more than one edge then such edges are called parallel edges that are many routes but one destination.
  • Loop: An edge of a graph that starts from a vertex and ends at the same vertex is called a loop or a self-loop.

6. Null Graph:

A graph of order n and size zero is a graph where there are only isolated vertices with no edges connecting any pair of vertices.A null graph is a graph with no edges. In other words, it is a graph with only vertices and no connections between them. A null graph can also be referred to as an edgeless graph, an isolated graph, or a discrete graph

7. Complete Graph:

A simple graph with n vertices is called a complete graph if the degree of each vertex is n-1, that is, one vertex is attached with n-1 edges or the rest of the vertices in the graph. A complete graph is also called Full Graph. 

 

8. Pseudo Graph:

A graph G with a self-loop and some multiple edges is called a pseudo graph. A pseudograph is a type of graph that allows for the existence of self-loops (edges that connect a vertex to itself) and multiple edges (more than one edge connecting two vertices). In contrast, a simple graph is a graph that does not allow for loops or multiple edges. 

9. Regular Graph:

A simple graph is said to be regular if all vertices of graph G are of equal degree. All complete graphs are regular but vice versa is not possible. A regular graph is a type of undirected graph where every vertex has the same number of edges or neighbors. In other words, if a graph is regular, then every vertex has the same degree. 

10. Bipartite Graph:

A graph G = (V, E) is said to be a bipartite graph if its vertex set V(G) can be partitioned into two non-empty disjoint subsets. V1(G) and V2(G) in such a way that each edge e of E(G) has one end in V1(G) and another end in V2(G). The partition V1 U V2 = V is called Bipartite of G. Here in the figure: V1(G)={V5, V4, V3} and V2(G)={V1, V2} 

11. Labeled Graph:

If the vertices and edges of a graph are labeled with name, date, or weight then it is called a labeled graph. It is also called Weighted Graph. 

12. Digraph Graph:

A graph G = (V, E) with a mapping f such that every edge maps onto some ordered pair of vertices (Vi, Vj) are called a Digraph. It is also called Directed Graph. The ordered pair (Vi, Vj) means an edge between Vi and Vj with an arrow directed from Vi to Vj. Here in the figure: e1 = (V1, V2) e2 = (V2, V3) e4 = (V2, V4) 

13. Subgraph:

A graph G1 = (V1, E1) is called a subgraph of a graph G(V, E) if V1(G) is a subset of V(G) and E1(G) is a subset of E(G) such that each edge of G1 has same end vertices as in G. 

 

14. Connected or Disconnected Graph:

Graph G is said to be connected if any pair of vertices (Vi, Vj) of a graph G is reachable from one another. Or a graph is said to be connected if there exists at least one path between each and every pair of vertices in graph G, otherwise, it is disconnected. A null graph with n vertices is a disconnected graph consisting of n components. Each component consists of one vertex and no edge. 

15. Cyclic Graph:

A graph G consisting of n vertices and n> = 3 that is V1, V2, V3- – – – Vn and edges (V1, V2), (V2, V3), (V3, V4)- – – – (Vn, V1) are called cyclic graph. 

16. Types of Subgraphs:

  • Vertex disjoint subgraph: Any two graph G1 = (V1, E1) and G2 = (V2, E2) are said to be vertex disjoint of a graph G = (V, E) if V1(G1) intersection V2(G2) = null. In the figure, there is no common vertex between G1 and G2.
  • Edge disjoint subgraph: A subgraph is said to be edge-disjoint if E1(G1) intersection E2(G2) = null. In the figure, there is no common edge between G1 and G2.

Note: Edge disjoint subgraph may have vertices in common but a vertex disjoint graph cannot have a common edge, so the vertex disjoint subgraph will always be an edge-disjoint subgraph.

17. Spanning Subgraph

Consider the graph G(V,E) as shown below. A spanning subgraph is a subgraph that contains all the vertices of the original graph G that is G'(V’,E’) is spanning if V’=V and E’ is a subset of E.

 

So one of the spanning subgraph can be as shown below G'(V’,E’). It has all the vertices of the original graph G and some of the edges of G.

This is just one of the many spanning subgraphs of graph G. We can create various other spanning subgraphs by different combinations of edges. Note that if we consider a graph G'(V’,E’) where V’=V and E’=E, then graph G’ is a spanning subgraph of graph G(V,E).

Advantages of graphs:

  1. Graphs can be used to model and analyze complex systems and relationships.
  2. They are useful for visualizing and understanding data.
  3. Graph algorithms are widely used in computer science and other fields, such as social network analysis, logistics, and transportation.
  4. Graphs can be used to represent a wide range of data types, including social networks, road networks, and the internet.

Disadvantages of graphs:

  1. Large graphs can be difficult to visualize and analyze.
  2. Graph algorithms can be computationally expensive, especially for large graphs.
  3. The interpretation of graph results can be subjective and may require domain-specific knowledge.
  4. Graphs can be susceptible to noise and outliers, which can impact the accuracy of analysis results.

Related article: Applications, Advantages and Disadvantages of Graph



Previous Article
Next Article

Similar Reads

Minimum spanning tree cost of given Graphs
Given an undirected graph of V nodes (V > 2) named V1, V2, V3, ..., Vn. Two nodes Vi and Vj are connected to each other if and only if 0 < | i - j | ? 2. Each edge between any vertex pair (Vi, Vj) is assigned a weight i + j. The task is to find the cost of the minimum spanning tree of such graph with V nodes. Examples: Input: V = 4 Output: 13
4 min read
Uniform-Cost Search (Dijkstra for large Graphs)
Uniform-Cost Search is a variant of Dijikstra's algorithm. Here, instead of inserting all vertices into a priority queue, we insert only the source, then one by one insert when needed. In every step, we check if the item is already in the priority queue (using the visited array). If yes, we perform the decrease key, else we insert it. This variant
12 min read
Count of distinct graphs that can be formed with N vertices
Given an integer N which is the number of vertices. The task is to find the number of distinct graphs that can be formed. Since the answer can be very large, print the answer % 1000000007.Examples: Input: N = 3 Output: 8Input: N = 4 Output: 64 Approach: The maximum number of edges a graph with N vertices can contain is X = N * (N - 1) / 2.The total
4 min read
Union and Intersection of two Graphs
Given two graphs G1 and G2, the task is to find the union and intersection of the two given graphs, i.e. (G1 ∪ G2) and (G1 ∩ G2). Examples: Input: G1 = { ("e1", 1, 2), ("e2", 1, 3), ("e3", 3, 4), ("e4", 2, 4) }, G2 = = { ("e4", 2, 4), ("e5", 2, 5), ("e6", 4, 5) }Output:G1 union G2 ise1 1 2e2 1 3e3 3 4e4 2 4e5 2 5e6 4 5G1 intersection G2 ise4 2 4Exp
12 min read
Class 8 RD Sharma Solutions - Chapter 27 Introduction to Graphs - Exercise 27.1
Question 1. Plot the points (5, 0), (5, 1), (5, 8). Do they lie on a line? What is your observation? Solution: Initially take a point O on the graph and draw horizontal and vertical lines OX and OY. In this graph x-axis and y axis 1 cm represents 1 unit. First plot point (5, 0), we start from the origin O and move 5 cm along X – axis. The point is
10 min read
Class 8 RD Sharma Solutions - Chapter 25 Data Handling III (Pictorial Representation Of Data As Pie Charts Or Circle Graphs) - Exercise 25.1 | Set 1
Question 1. The number of hours, spent by a school boy on different activities in a working day, is given below:Activity Sleep School Home Play Other Total Number of Hours 8742324Present the information in the form of a pie-chart. Solution: Given that, total number of hours = 24 Therefore, Central angle = (component value / 24) × 360° Now the centr
10 min read
Class 8 RD Sharma Solutions - Chapter 25 Data Handling III (Pictorial Representation Of Data As Pie Charts Or Circle Graphs) - Exercise 25.1 | Set 2
Question 11. The following table shows how a student spends his pocket money during the course of a month. Represent it by a pie diagram.ItemsFood Entertainment Other Expenditure Saving Expenditure (in %) 40252015 Solution: Given that, total Expenditure = 100% Therefore, Central angle = (component value/100) × 360° Now the central angle for each ac
7 min read
Java Program to Represent Graphs Using Linked List
Data structures are divided into two categories Linear data structures and Non-Linear data structures. The major disadvantage of the linear data structure is we cannot arrange the data of linear data structure in hierarchy manner that's why in the computer field we use Non-Linear data structures. The most commonly used Non-Linear data structure is
4 min read
Count of graphs formed by changing color of any red-colored node with black parent to black
Given a directed graph G consisting of N nodes and N-1 edges, and a positive integer K, and initially, all the nodes of the graph are red except for K, which is black, the task is to count the number of different possible graphs formed by changing the color of any red-colored node to black, only if their parent is colored black, any number of times
8 min read
Number of Triangles in Directed and Undirected Graphs
Given a Graph, count number of triangles in it. The graph is can be directed or undirected. Example: Input: digraph[V][V] = { {0, 0, 1, 0}, {1, 0, 0, 1}, {0, 1, 0, 0}, {0, 0, 1, 0} }; Output: 2 Give adjacency matrix represents following directed graph. We have discussed a method based on graph trace that works for undirected graphs. In this post a
10 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg