Representation of Graphs

The lesson elaborates on how a graph can be represented using the Adjacency List and Adjacency Matrix.

Ways to Represent a Graph

Here are the two most common ways to represent a graph :

  1. Adjacency Matrix
  2. Adjacency List

Adjacency Matrix

The adjacency matrix is a two-dimensional matrix where each cell can contain a 0 or 1. The row and column headings represent the vertices.

If a cell contains 1, there exists an edge between the corresponding vertices, e.g., Matrix[0][1]=1Matrix[0][1]=1 shows that an edge exists between vertex 0 and 1.

Create a free account to view this lesson.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy