Is Graph an ADT or Data Structure?


Larry Thompson

Is Graph an ADT or Data Structure?

A graph is a data structure that consists of a set of nodes (vertices) and a set of edges that connect these nodes. It is a powerful tool used to represent relationships between various entities. However, when it comes to classifying graphs, there is often confusion about whether they should be considered as abstract data types (ADTs) or data structures.

Abstract Data Types (ADTs)

An abstract data type is a logical description of how data can be organized and the operations that can be performed on it. It defines the behavior of the data without specifying its implementation. ADTs are used to encapsulate complex data structures and provide a clear interface for interacting with them.

Graphs can indeed be viewed as ADTs because they describe the properties and operations that define them. We can specify the basic functionalities such as adding or removing vertices, adding or removing edges, and traversing the graph using different algorithms like breadth-first search (BFS) or depth-first search (DFS). By defining these operations, we create an abstract model of a graph.

Data Structures

Data structures, on the other hand, are concrete implementations of abstract data types. They determine how the data is stored in memory and provide algorithms to manipulate this stored data efficiently. Data structures allow us to organize and access our data in specific ways, optimizing for different types of operations.

In this sense, graphs can also be considered as data structures since we have different ways to store them in memory. Some commonly used representations include adjacency matrix, adjacency list, incidence matrix, and edge list. Each representation has its advantages and disadvantages depending on the type of graph and the operations we want to perform on it.

The Relationship Between Graphs, ADTs, and Data Structures

Graphs can be seen as a combination of both ADTs and data structures. The ADT perspective focuses on the logical behavior of the graph and the operations that can be performed on it. It defines how we interact with the graph without specifying how it is implemented.

On the other hand, data structures provide concrete implementations of graphs using different representations. They outline how the graph is stored in memory and offer efficient algorithms for performing operations on it.


In summary, graphs can be viewed as both abstract data types (ADTs) and data structures. From an ADT perspective, we define the behavior of a graph by specifying its properties and operations. From a data structure perspective, we implement graphs using various representations to efficiently store and manipulate them in memory.

Understanding the distinction between ADTs and data structures helps us appreciate the different levels of abstraction involved in designing and working with graphs. By leveraging this knowledge, we can choose appropriate implementations based on our specific requirements and optimize our algorithms accordingly.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy