codeintuition-logo

Exploring a possible solution


Now that we know that linear data structures cannot efficiently store many-to-many relationships, let's look at a data structure designed to solve this problem efficiently. A graph is a non-linear data structure comprising one or more nodes connected via links called edges. Each connection between nodes represents the relationship between the nodes. A graph data structure stores and manipulates many-to-many relationships between data.

Loading Image

Logical representation of a graph

Each edge in the graph can hold data, often called the edge's weight. Depending on what the graph represents, the weight could be anything.

Liking the course? Check our discounted plans to continue learning.