Graphs are an essential component of data structure, providing a versatile way to organize and represent relationships between various elements. From analyzing social networks to optimizing transportation routes, graphs play a crucial role in solving complex problems. But did you know that there are different types of graphs in data structure? What makes these graphs unique and how are they used?
In this article, we will delve into the fascinating world of graph data structures. We will explore the various types of graphs, their properties, and realworld examples. By the end, you will have a deeper understanding of how different types of graphs can be utilized to tackle diverse challenges.
Table of Contents
 Directed Graph
 Undirected Graph
 Weighted Graph
 Unweighted Graph
 Bipartite Graph
 Connected Graph
 Tree
 Forest
 Complete Graph
 Eulerian Graph
 Hamiltonian Graph
 Planar Graph
 Conclusion
 FAQ
 What are the different types of graphs in data structure?
 What is a directed graph?
 What is an undirected graph?
 What is a weighted graph?
 What is an unweighted graph?
 What is a bipartite graph?
 What is a connected graph?
 What is a tree in data structure?
 What is a forest in data structure?
 What is a complete graph?
 What is an Eulerian graph?
 What is a Hamiltonian graph?
 What is a planar graph?
Key Takeaways:
 Graphs are used to represent and analyze relationships between elements in data structure.
 There are different types of graphs, including directed, undirected, weighted, and unweighted graphs.
 Bipartite graphs, connected graphs, trees, forests, complete graphs, Eulerian graphs, Hamiltonian graphs, and planar graphs are all variations of graphs with unique properties and applications.
 Each type of graph has specific characteristics that make it suitable for solving particular problems.
 Understanding the different types of graphs can enhance your problemsolving abilities in various domains.
Directed Graph
In the world of graph theory, a directed graph, also known as a digraph, is a powerful data structure that represents a collection of objects and the relationships between them. Unlike undirected graphs, which only show connections without any specific direction, directed graphs explicitly indicate the direction of each edge.
Directed graphs are widely used in various domains, including computer science, social networks, and transportation systems. They provide a rich framework for modeling complex relationships and capturing the flow of information or resources between different entities.
Properties of directed graphs:
 Vertex: The basic unit of a directed graph is a vertex, also known as a node. Each vertex represents an object or an entity in the graph.
 Edge: Edges in a directed graph represent the relationships between the vertices. Each edge has a specific direction, denoting the flow from one vertex to another.
 Directed Acyclic Graph (DAG): A directed acyclic graph is a special type of directed graph that contains no directed cycles. In other words, it is impossible to start at any vertex and follow a sequence of edges, eventually returning to the same vertex.
Examples of directed graphs:
Graph  Description 

A social network graph where the vertices represent individuals and the directed edges represent friendships.  
A flowchart representing the steps in a complex manufacturing process.  
A website navigation graph where the vertices represent web pages and the directed edges represent links. 
Directed graphs are a fundamental concept in graph theory and have numerous applications in various fields. They offer a versatile and intuitive way to model and analyze relationships between objects, making them a valuable tool for understanding complex systems.
Undirected Graph
An undirected graph is a type of graph that does not have any associated direction or orientation. In an undirected graph, the edges do not have a specific direction and can be traversed in either direction.
Undirected graphs have several characteristics that make them useful in various applications. Some key features of undirected graphs include:
 Connectivity: In an undirected graph, it is possible to move from any vertex to any other vertex by following a series of edges.
 Symmetry: The absence of direction in undirected graphs means that edges connecting two vertices are bidirectional, reflecting a symmetric relationship between the two vertices.
 Pathfinding: Undirected graphs are commonly used in pathfinding algorithms, such as breadthfirst search and depthfirst search, to find the shortest path or explore all possible paths between two vertices.
Here is an example of an undirected graph:
Nodes  Edges 

A  B 
B  C 
C  A 
D  E 
In the example above, the undirected graph consists of five nodes (A, B, C, D, and E) and four edges (AB, BC, CA, and DE). The edges between the nodes do not have a specific direction, allowing for movement in both directions.
Applications of Undirected Graphs
Undirected graphs are widely used in various domains and applications, including:
 Social networks: Undirected graphs can represent relationships between individuals in social networks, where the absence of direction reflects the mutual connection between users.
 Transportation networks: Undirected graphs can model transportation routes, where the absence of direction indicates that vehicles can travel in either direction along a road or route.
 Computer networks: Undirected graphs can represent the connections between devices in a computer network, where the absence of direction signifies bidirectional communication.
Undirected graphs provide a flexible and intuitive way to represent relationships and connections between entities, making them a fundamental concept in graph theory and data structure.
Weighted Graph
A weighted graph is a type of graph where each edge is assigned a numerical value, known as a weight or cost. These weights represent the significance or cost associated with traversing the edge. By incorporating weights into the graph, we can better model realworld scenarios that involve varying degrees of importance or expense.
Weighted graphs have numerous applications across different fields, including transportation, logistics, network analysis, and finance. For example, in a transportation network, the weights on edges can represent distances, travel times, or fuel consumption. In financial analysis, weights can represent investment returns or risk associated with different assets or portfolios.
With weighted graphs, algorithms and techniques can be employed to solve optimization problems such as finding the shortest path, the minimum spanning tree, or the most efficient allocation of resources. These algorithms take into account both the connectivity and the weights of the edges in the graph, allowing for more accurate and efficient solutions.
“Weighted graphs provide a valuable tool for representing and analyzing complex systems that involve varying degrees of importance or cost.”
By assigning weights to graph edges, we can capture the intricacies of realworld relationships and dependencies. The weights add another layer of information to the graph, enabling us to make informed decisions and gain deeper insights into the underlying data.
Unweighted Graph
An unweighted graph is a type of graph in which all edges have equal weight. In other words, there is no distinction between the edges in terms of their importance or cost. Each edge is simply a connection between two vertices, with no additional information attached.
Unweighted graphs are widely used in data structure due to their simplicity and ease of implementation. They are particularly suitable for representing relationships between objects or entities that do not have varying degrees of significance or influence. For example, in a social network, an unweighted graph can be used to represent connections between users, where each connection carries the same level of importance.
One key characteristic of unweighted graphs is that the shortest path between two vertices is determined solely by the number of edges in the path, rather than the weights assigned to those edges. This makes computations involving unweighted graphs more efficient compared to weighted graphs.
Here is an example of an unweighted graph:
Vertices  Edges 

A  B 
B  C 
A  C 
C  D 
In this graph, each edge represents a connection between two vertices, with no associated weight. This means that all edges are considered equally important or significant in the graph.
Unweighted graphs find applications in various fields, ranging from computer science and network analysis to social network analysis and recommendation systems. By understanding the characteristics and significance of unweighted graphs, data structure practitioners can effectively model and analyze complex networks and relationships.
Bipartite Graph
In the world of graphs, a bipartite graph holds a special place. It is a graph that can be divided into two distinct sets of vertices, such that all the edges only connect vertices from different sets.
One way to conceptualize a bipartite graph is to imagine it as a graph that represents the relationships between two different types of entities. For example, consider a graph that represents the relationships between students and the courses they are enrolled in. Here, the vertices can be divided into two sets: the set of students and the set of courses. The edges in the graph will only connect students to courses, never connecting students to other students or courses to other courses.
Properties of Bipartite Graphs
Bipartite graphs exhibit interesting properties that make them useful in various applications. Some key properties of bipartite graphs include:
 Two disjoint sets: Bipartite graphs consist of two distinct sets of vertices, with no vertices shared between the sets.
 No edges within sets: All edges in a bipartite graph connect vertices from different sets. There are no edges connecting vertices within the same set.
Bipartite Graph Example
To better understand bipartite graphs, let’s consider a realworld example. Imagine a social media platform where users can follow celebrities. The graph representation of this scenario can be a bipartite graph, where one set of vertices represents the users and the other set represents the celebrities. The edges in this graph will connect users to the celebrities they follow, ensuring that only users are connected to celebrities and not to other users.
Here is a visual representation of the bipartite graph:
Users  Celebrities 

User A  Celebrity 1 
User B  Celebrity 2 
User C  Celebrity 3 
In the given example, we can see that the vertices (users and celebrities) are divided into two sets, and the edges only connect vertices from different sets, demonstrating the essence of a bipartite graph.
To summarize, bipartite graphs are graphs that can be divided into two sets of vertices, with all edges connecting vertices from different sets. These special graphs find applications in various fields, such as social media networks, recommendation systems, and matching problems.
Connected Graph
In the world of data structure, connected graphs play a crucial role. A connected graph is defined as a graph where there is a path between every pair of vertices. This means that no matter which two vertices you choose, there is always a way to reach one from the other.
Connected graphs are widely used in various applications such as network analysis, social media algorithms, and transportation systems. They are instrumental in understanding the relationships and connections between different entities.
Consider the following example of a connected graph:
Vertex  Adjacent Vertices 

A  B, C, D 
B  A, C 
C  A, B, D 
D  A, C 
In this example, we can see that all vertices (A, B, C, and D) are connected to each other, forming a connected graph.
Connected graphs are often used to analyze the flow of information, identify clusters or subgroups within a larger network, and optimize various processes. They provide valuable insights into the interconnectedness of data points.
In summary, connected graphs are an essential concept in data structure that enables the analysis of relationships and connections in various systems. They facilitate deep analysis and optimization, making them a fundamental building block for many realworld applications.
Tree
Trees are hierarchical data structures that consist of a root node and a set of connected nodes. In a tree, each node has only one parent, except for the root node, and can have multiple child nodes. The tree structure is widely used in computer science and data structure due to its efficient organization and fast retrieval capabilities.
“A tree structure is perfect for representing hierarchical relationships and organizing data in a logical manner.”
Properties of Trees
Trees possess several key properties that make them valuable in data structure:
 Hierarchical Structure: Nodes in a tree are organized in a hierarchical structure, with each level representing a different level of abstraction or detail. This allows for a clear representation of relationships between elements.
 Root Node: The root node is the topmost node in a tree and does not have a parent. It serves as the starting point for traversing the tree.
 Connected Nodes: Nodes in a tree are connected by edges, which represent the relationships between them.
 Child Nodes: Child nodes are the nodes directly below a parent node. Each node can have multiple child nodes, but each child node can only have one parent.
 Leaf Nodes: Leaf nodes, also known as terminal nodes, are the nodes that do not have any child nodes. They represent the end points of the tree structure.
Applications of Trees
Trees are widely used in various applications, including:
 File Systems: Trees provide the foundation for file system structures, allowing for efficient organization and navigation of files and directories.
 Database Indexing: Trees are utilized to create efficient indexing structures in databases, enabling fast search and retrieval operations.
 Hierarchical Data Representation: Trees are perfect for representing hierarchical relationships, such as organizational charts, family trees, and category hierarchies.
 Network Routing: Tree structures are employed in network routing algorithms to determine the most efficient path for data transmission.
 Artificial Intelligence: Trees form the basis of decision trees, which are widely used in machine learning algorithms for classification and regression tasks.
Overall, trees are indispensable in data structure due to their versatile nature, efficient organization, and wide range of applications.
Forest
Forests are collections of disjoint trees. In the context of data structure, a forest is a set of individual trees that are not connected. Each tree within a forest can have its own root node and a set of connected nodes. This arrangement allows for hierarchical organization and representation of data.
Forests play an important role in various applications, such as hierarchical data storage, network topology, and decision trees. They offer a flexible way to organize data with different levels of hierarchy, allowing for easy navigation and retrieval.
Unlike other types of graphs where all vertices are interconnected, forests provide a more decentralized structure where individual trees can exist independently from each other. This can be particularly useful in scenarios where modularity and separation of data are desired.
Let’s take a closer look at the characteristics and usage of forests in data structure:
 Disjoint Trees: A forest consists of multiple disjoint trees, where each tree has its own set of connected nodes.
 Hierarchical Organization: Forests enable hierarchical organization of data, with each tree representing a distinct level of hierarchy.
 Modularity and Separation: The disjoint nature of trees in a forest allows for modularity and separation of data, making it easier to manage and retrieve specific sets of information.
 Scalability: Forests can be easily scaled by adding or removing trees, allowing for efficient growth and adaptation to changing data requirements.
In summary, forests are collections of disjoint trees that offer hierarchical organization and modularity in data structure. They are widely used in various domains, including hierarchical data storage, network topology, and decision trees.
Complete Graph
A complete graph is a type of graph in which every pair of distinct vertices is connected by exactly one edge. In other words, a complete graph is a graph that is fully connected, with each vertex directly connected to every other vertex.
Complete graphs are often represented by the symbol K_{n}, where n represents the number of vertices in the graph. For example, a complete graph with 3 vertices would be denoted as K_{3}.
Properties of complete graphs:
 A complete graph with n vertices has n(n1)/2 edges.
 Complete graphs are regular graphs, meaning that each vertex has the same degree, which is equal to n1.
 Complete graphs are connected graphs, as there is a path between every pair of vertices.
 Complete graphs are simple graphs, with no selfloops or multiple edges.
 Complete graphs are planar graphs for n=2 and n=3, but they are not planar for n>3.
Here’s an example of a complete graph with 5 vertices:
Vertex  Adjacent Vertices 

1  2, 3, 4, 5 
2  1, 3, 4, 5 
3  1, 2, 4, 5 
4  1, 2, 3, 5 
5  1, 2, 3, 4 
A complete graph is a fundamental concept in graph theory and has applications in various fields, including computer science, network analysis, and social network analysis. Understanding the properties and examples of complete graphs is essential for gaining a deep understanding of their role in data structure.
Eulerian Graph
An Eulerian graph is a type of graph that contains an Eulerian path or an Eulerian circuit. In this section, we will explore the concept of Eulerian graphs and explain the difference between Eulerian paths and circuits. Realworld examples will be provided to help readers better understand the applications of Eulerian graphs.
Eulerian Path
An Eulerian path is a path in a graph that visits each edge exactly once. It starts and ends at different vertices. This means that every vertex in the graph must have an even degree, except for the starting and ending vertices, which have an odd degree. An example of an Eulerian path is shown below:
Graph  Eulerian Path 

AB   CD 

Eulerian Circuit
An Eulerian circuit is a closed path in a graph that visits each edge exactly once. It starts and ends at the same vertex. In an Eulerian circuit, every vertex in the graph must have an even degree. An example of an Eulerian circuit is shown below:
Graph  Eulerian Circuit 

AB   CD 

Eulerian graphs have various applications in realworld scenarios. For example, in network analysis, Eulerian circuits can be used to optimize the routing of delivery vehicles or ensure the efficient transmission of data. In transportation planning, Eulerian paths can help determine the most costeffective routes for public transportation systems. By studying Eulerian graphs, researchers and practitioners can uncover insights and make informed decisions in diverse fields.
Hamiltonian Graph
A Hamiltonian graph is a type of graph that contains a Hamiltonian circuit, which is a path that visits every vertex exactly once. These graphs have several interesting properties and find application in various domains.
“A Hamiltonian circuit is like a magical tour that covers every stop exactly once. It takes you on a journey through all the vertices of a Hamiltonian graph, allowing you to explore and connect with every element in the graph.” – Graph Guru
Hamiltonian graphs are studied extensively in graph theory due to their unique characteristics. They provide insights into the connectivity and structure of a graph, making them valuable tools in network analysis, transportation planning, and DNA sequencing.
One famous example of a Hamiltonian graph is the Knight’s Tour problem, where a knight must visit every square on a chessboard exactly once. The knight’s movements represent the edges of the Hamiltonian graph, and finding a Hamiltonian circuit in this scenario would solve the puzzle.
Properties of Hamiltonian Graphs:
 A Hamiltonian graph must have a minimum of three vertices.
 Each vertex in a Hamiltonian graph has a degree of at least two.
 Removing any vertex and its incident edges from a Hamiltonian graph will not result in a disconnected graph.
Understanding Hamiltonian graphs and their circuits is crucial in solving optimization problems and analyzing complex systems. Whether it is planning the most efficient route for a delivery driver or unraveling the mysteries of the human brain’s neural connections, Hamiltonian graphs provide a powerful framework for analysis.
Realworld Applications of Hamiltonian Graphs  Description 

Transportation Planning  Optimizing delivery routes or finding the shortest path for public transportation. 
Electrical Circuit Design  Designing circuits with minimal wire intersections, reducing signal interference. 
Genome Sequencing  Mapping and sequencing the DNA of organisms to reveal genetic connections. 
Planar Graph
In the field of graph theory, a planar graph refers to a type of graph that can be represented on a plane without any of its edges crossing over one another. These graphs hold significant importance in various domains, including network design and geographic information systems.
Planar graphs are characterized by their ability to be drawn in such a way that its edges do not intersect, allowing for a clear and visually understandable representation. This property makes planar graphs highly useful in situations where visualization and clarity of connections are essential.
Here is an example of a planar graph:
Planar Graph Example 

In the given example, you can observe the clear and noncrossing edges that define the planar graph. This representation aids in understanding the relationships and connections between the different vertices of the graph.
Planar graphs find applications in various fields, including:
 Geographic Information Systems (GIS): Planar graphs can be used to represent geographical maps and networks, assisting in tasks such as route planning and optimizing transportation networks.
 Network Design: Planar graphs play a crucial role in designing efficient and manageable network topologies, ensuring that connections do not overlap or create conflicts.
By leveraging the properties of planar graphs, professionals in these fields can design and analyze complex systems with ease, enabling efficient decisionmaking and problemsolving.
Conclusion
In conclusion, this article has provided a comprehensive overview of the different types of graphs in data structure and their applications. Throughout the sections, we have explored various types of graphs, including directed graphs, undirected graphs, weighted graphs, unweighted graphs, bipartite graphs, connected graphs, trees, forests, complete graphs, Eulerian graphs, Hamiltonian graphs, and planar graphs.
Directed graphs, also known as digraphs, are graphs that have a defined direction for each edge. They are useful in representing relationships and dependencies between entities. Undirected graphs, on the other hand, do not have any associated direction and are often used to represent symmetric relationships.
Weighted graphs introduce the concept of assigning weights or costs to each edge, allowing for the representation of realworld scenarios more accurately. Unweighted graphs, on the contrary, assume that all edges have equal weight, simplifying the representation of certain data structures.
Bipartite graphs, connected graphs, trees, forests, complete graphs, Eulerian graphs, Hamiltonian graphs, and planar graphs each have their unique properties and applications. By understanding these different types of graphs, readers can leverage the power of data structure to organize, analyze, and represent data effectively.
FAQ
What are the different types of graphs in data structure?
The different types of graphs in data structure include directed graphs, undirected graphs, weighted graphs, unweighted graphs, bipartite graphs, connected graphs, trees, forests, complete graphs, Eulerian graphs, Hamiltonian graphs, and planar graphs.
What is a directed graph?
A directed graph, also known as a digraph, is a graph in which the edges have a specific direction. Each edge connects two vertices and represents a oneway relationship between them.
What is an undirected graph?
An undirected graph is a graph in which the edges do not have any associated direction or orientation. The edges in an undirected graph represent a twoway relationship between the vertices.
What is a weighted graph?
A weighted graph is a graph in which each edge has an associated weight or cost. The weights can represent measures like distance, time, or cost, adding an extra layer of information to the relationships between vertices.
What is an unweighted graph?
An unweighted graph is a graph in which all edges have the same weight. The edges in an unweighted graph represent equal relationships between the vertices, with no additional information attached to them.
What is a bipartite graph?
A bipartite graph is a graph that can be divided into two sets of vertices, such that all edges connect vertices from different sets. This division into two sets allows for the creation of a clear separation or distinction between the vertices.
What is a connected graph?
A connected graph is a graph in which there is a path between every pair of vertices. It means that there are no isolated or disconnected vertices, and every vertex can be reached from any other vertex by following the edges.
What is a tree in data structure?
A tree is a hierarchical data structure that consists of a root node and a set of connected nodes. The nodes are connected by edges, and each node can have zero or more child nodes.
What is a forest in data structure?
A forest is a collection of disjoint trees. It is made up of multiple trees where there is no connection between them. Each tree in the forest follows the same hierarchical structure as a regular tree.
What is a complete graph?
A complete graph is a graph in which there is an edge between every pair of vertices. It means that each vertex is directly connected to every other vertex in the graph, forming a fully interconnected network.
What is an Eulerian graph?
An Eulerian graph is a graph that contains an Eulerian path or an Eulerian circuit. An Eulerian path visits each edge exactly once, while an Eulerian circuit visits each edge exactly once and returns to the starting vertex.
What is a Hamiltonian graph?
A Hamiltonian graph is a graph that contains a Hamiltonian circuit, which is a path that visits every vertex exactly once. The Hamiltonian circuit does not have to traverse every edge, but it must visit every vertex in the graph.
What is a planar graph?
A planar graph is a graph that can be represented on a plane without any edges crossing. It means that the edges in a planar graph can be drawn on a flat surface such that they do not intersect with each other.