Introduction to Graph Algorithms and Implementation
In this lesson, we learn about graphs and how we represent them.
We'll cover the following...
Before we begin, lets briefly discuss what are graphs?
A graph is an abstract notation used to represent the connection between pairs of objects. It can be used to represent networks: systems of roads, airline flights from city to city, how the Internet is connected, or social connectivity on facebook, twitter etc. We use some standard graph algorithms to solve these otherwise difficult problems.
Representing Graphs
Graphs represent pairwise relationships between objects. Graphs are mathematical structures
and therefore can be visualized by using two basic components, nodes
and edges
A node, also known as a vertex, is a fundamental part of a graph. It is the entity that has a name, known as the key
, and other information related to that entity. A relationship between nodes is expressed using edges. An edge between two nodes expresses a one-way or two-way relationship between the nodes.
Graphs can be represented as Adjacency Matrix and Adjacency List.
For the remainder of this course, we will be using Adjacency Lists because Algorithms can be performed more efficiently using this form of representation.
For example, the adjacency list representation allows you to easily iterate through the neighbors of a node. In the adjacency matrix representation, you will need to iterate through all the nodes to identify a node’s neighbors.
Mathematical Notation
The set of vertices of Graph is denoted by , or just if there is no ambiguity.
An edge between vertices and ...
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy