Learn C++ Online

Graph representations (part 1)

On this page
This lesson contains approximately 20 minutes of video content.

First, some additional terminology

Vertex naming and edge notation

Graph representation alternatives

Adjacency-matrix representation

Questions

Q1

QGraph representations (part 1), Q1

This question is ungraded.

If a graph has 4 vertices, what is the number of elements in the corresponding adjacency matrix?

Q2

QGraph representations (part 1), Q2

This question is ungraded.

Given the following adjacency matrix of an undirected graph,

   1   2   3   4
1 [0   1   0   1]
2 [1   0   0   1]
3 [0   0   0   0]
4 [1   1   0   0]

how many neighbors does vertex 2 have?

Q3

QGraph representations (part 1), Q3

This question is ungraded.

Given the following adjacency matrix of an undirected graph,

   1   2   3   4
1 [0   1   0   1]
2 [1   0   0   1]
3 [0   0   0   0]
4 [1   1   0   0]

is this graph a simple graph or multigraph?

Q4

QGraph representations (part 1), Q4

This question is ungraded.

Given the following adjacency matrix of an undirected graph,

   1   2   3   4
1 [0   1   0   1]
2 [1   0   0   1]
3 [0   0   0   0]
4 [1   1   0   0]

does at least one path exist between every pair of vertices?