Skip to content

Adjacency Matrix: doc error for undirected graphs #323

@tesfabpel

Description

@tesfabpel

In the doc page for adjacency matrices there is an error for undirected graphs.
It says:

In the case of an undirected graph, the adjacency_matrix. class does not use a full V x V matrix but instead uses a lower triangle (the diagonal and below) since the matrix for an undirected graph is symmetric. This reduces the storage to (V²)/2. Figure 2 shows an adjacency matrix representation of an undirected graph.

In particular, This reduces the storage to (V²)/2 is wrong, since if you count the number of items in the Figure 2, you can see that there are 21 items for a graph of 6 vertices (instead of (6²)/2 = 36 / 2 = 18).

I believe the correct formula is (V² + V) / 2.

For n = 1: (1² + 1) / 2 = 2 / 2 = 1
For n = 2: (2² + 2) / 2 = 6 / 2 = 3
For n = 6: (6² + 6) / 2 = 42 / 2 = 21

boost-graph-doc-matrix-bug

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions