Open In App

What is Graph Data Structure?

Last Updated : 07 Jul, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

A Graph is a non-linear data structure consisting of vertices and edges. The vertices are sometimes also referred to as nodes and the edges are lines or arcs that connect any two nodes in the graph. More formally a Graph is composed of a set of vertices( V ) and a set of edges( E ). The graph is denoted by G(E, V).

What is Graph in Data Structure & Algorithms

Components of a Graph

  • Vertices: Vertices are the fundamental units of the graph. Sometimes, vertices are also known as vertices or nodes. Every node/vertex can be labeled or unlabelled.
  • Edges: Edges are drawn or used to connect two nodes of the graph. It can be ordered pair of nodes in a directed graph. Edges can connect any two nodes in any possible way. There are no rules. Sometimes, edges are also known as arcs. Every edge can be labeled/unlabelled.

Types Of Graph

  1. Null Graph: A graph is known as a null graph if there are no edges in the graph.
  2. Trivial Graph: Graph having only a single vertex, it is also the smallest graph possible.
  3. Undirected Graph: A graph in which edges do not have any direction. That is the nodes are unordered pairs in the definition of every edge. 
  4. Directed Graph: A graph in which edge has direction. That is the nodes are ordered pairs in the definition of every edge.
  5. Connected Graph: The graph in which from one node we can visit any other node in the graph is known as a connected graph. 
  6. Disconnected Graph: The graph in which at least one node is not reachable from a node is known as a disconnected graph.
  7. Regular Graph: The graph in which the degree of every vertex is equal to K is called K regular graph.
  8. Complete Graph: The graph in which from each node there is an edge to each other node.
  9. Cycle Graph: The graph in which the graph is a cycle in itself, the degree of each vertex is 2. 
  10. Cyclic Graph: A graph containing at least one cycle is known as a Cyclic graph.
  11. Directed Acyclic Graph: A Directed Graph that does not contain any cycle. 
  12. Bipartite Graph: A graph in which vertex can be divided into two sets such that vertex in each set does not contain any edge between them.
  13. Weighted Graph: A graph in which the edges are already specified with suitable weight is known as a weighted graph. Weighted graphs can be further classified as:
    1. directed weighted graphs and
    2. undirected weighted graphs. 

Similar Reads

Static Data Structure vs Dynamic Data Structure
Data structure is a way of storing and organizing data efficiently such that the required operations on them can be performed be efficient with respect to time as well as memory. Simply, Data Structure are used to reduce complexity (mostly the time complexity) of the code. Data structures can be two types : 1. Static Data Structure 2. Dynamic Data
4 min read
Applications of Graph Data Structure
A graph is a non-linear data structure, which consists of vertices(or nodes) connected by edges(or arcs) where edges may be directed or undirected. In Computer science graphs are used to represent the flow of computation.Google maps uses graphs for building transportation systems, where intersection of two(or more) roads are considered to be a vert
3 min read
Graph terminology in data structure
Graphs are fundamental data structures in various computer science applications, including network design, social network analysis, and route planning. Understanding graph terminology is crucial for effectively navigating and manipulating graph data structures. In this article, we will discuss the graph terminology used in the data structure. Table
6 min read
Graph Data Structure And Algorithms
Graph Data Structure is a collection of nodes connected by edges. It's used to represent relationships between different entities. Graph algorithms are methods used to manipulate and analyze graphs, solving various problems like finding the shortest path or detecting cycles. Table of Content What is Graph Data Structure?Components of a GraphBasic O
6 min read
Introduction to Graph Data Structure
Graph Data Structure is a non-linear data structure consisting of vertices and edges. It is useful in fields such as social network analysis, recommendation systems, and computer networks. In the field of sports data science, graph data structure can be used to analyze and understand the dynamics of team performance and player interactions on the f
15+ min read
Is array a Data Type or Data Structure?
What is Data Type? In computer programming, a data type is a classification of data that determines the type of values that can be stored, manipulated, and processed. It tells the computer what kind of data a particular variable or constant can hold, and what operations can be performed on that data. Common data types include integers, floating-poi
8 min read
Data Structure Alignment : How data is arranged and accessed in Computer Memory?
Data structure alignment is the way data is arranged and accessed in computer memory. Data alignment and Data structure padding are two different issues but are related to each other and together known as Data Structure alignment. Data alignment: Data alignment means putting the data in memory at an address equal to some multiple of the word size.
4 min read
Difference between data type and data structure
Data Type A data type is the most basic and the most common classification of data. It is this through which the compiler gets to know the form or the type of information that will be used throughout the code. So basically data type is a type of information transmitted between the programmer and the compiler where the programmer informs the compile
4 min read
Detect cycle in the graph using degrees of nodes of graph
Given a graph, the task is to detect a cycle in the graph using degrees of the nodes in the graph and print all the nodes that are involved in any of the cycles. If there is no cycle in the graph then print -1. Examples: Input: Output: 0 1 2 Approach: Recursively remove all vertices of degree 1. This can be done efficiently by storing a map of vert
11 min read
Convert the undirected graph into directed graph such that there is no path of length greater than 1
Given an undirected graph with N vertices and M edges and no self loops or multiple edges. The task is to convert the given undirected graph into a directed graph such that there is no path of length greater than 1. If it is possible to make such a graph then print two space-separated integers u and v in M lines where u, v denotes source and destin
10 min read
Article Tags :
Practice Tags :
three90RightbarBannerImg