What is a Graph?
This lesson is a brief introduction to the graph data structure, its types, and the standard terminologies used to describe it.
We'll cover the following
Introduction #
When we talk about graphs, the first thing that comes to mind is the conventional graphs used to model data. In computer science, the term “graph” has a completely different meaning.
The graph data structure plays a fundamental role in several applications such as GPS, neural networks, peer to peer networks, search engine crawlers, garbage collection, and even social networking websites.
This section will explore its functionality and power. We will also look at how they are used to solve a diverse range of problems.
Now, let’s talk about what a graph really is.
Graph Structure #
A graph is a set of nodes that are connected to each other in the form of a network. First of all, we’ll define the two basic components of a graph.
Vertex #
A vertex is an essential part of a graph. A collection of vertices forms a graph. In that sense, vertices are similar to linked list nodes.
Edge #
An edge is a link between two vertices. It can be uni-directional or bi-directional, depending on your graph. An edge can also have a cost associated with it, which we will discuss in detail later.
Here is a visual representation of a graph:
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.