In this lecture we looked at how to store the data from a graph in an adjacency matrix.

For your challenge, I asked you to store the following graph as a matrix, using the techniques we covered:

In this lecture we looked at how to store the data from a graph in an adjacency matrix.

For your challenge, I asked you to store the following graph as a matrix, using the techniques we covered:

```
A B C D E F
```

A 0 1 2 0 0 0

B 1 0 0 5 3 0

C 0 0 0 0 0 0

D 0 5 0 0 0 1

E 0 0 0 1 0 4

F 0 0 0 1 4 0

1 Like

Nice work @ajai.

You’ve transposed the matrix from how I presented it in the lecture but your answer still works provide you read it as the column node being connected to the row nodes.

You can construct your matrix either way, so long as you’re consistent.

If you look at it in the same way as we did in the lecture (with the row node being connected to the column nodes) then you’ll find that all of your directional connections have been flipped, so just something to watch out for.

1 Like

```
A B C D E F
```

A 0 1 0 0 0 0

B 1 0 0 5 0 0

C 2 0 0 0 0 0

D 0 5 0 0 1 1

E 0 3 0 0 0 4

F 0 0 0 1 4 0

1 Like

```
A B C D E F
```

A 0 1 0 0 0 0

B 1 0 0 5 0 0

C 2 0 0 0 0 0

D 0 5 0 0 1 1

E 0 3 0 0 0 4

F 0 0 0 1 4 0

1 Like

A B C D E F

A 0 1 0 0 0 0

B 1 0 0 5 0 0

C 2 0 0 0 0 0

D 0 5 0 0 1 1

E 0 3 0 0 0 4

F 0 0 0 1 4 0

1 Like

A | B | C | D | E | F | |
---|---|---|---|---|---|---|

A | 0 | 1 | 0 | 0 | 0 | 0 |

B | 1 | 0 | 0 | 5 | 0 | 0 |

C | 2 | 0 | 0 | 0 | 0 | 0 |

D | 0 | 5 | 0 | 0 | 1 | 1 |

E | 0 | 3 | 0 | 0 | 0 | 4 |

F | 0 | 0 | 0 | 1 | 4 | 0 |

1 Like

Here is mine:

1 Like

**A** **B C D E F**

**A** 0 1 0 0 0 0

**B** 0 0 0 5 0 0

**C** 2 0 0 0 0 0

**D** 0 5 0 0 1 1

**E** 0 3 0 0 0 4

**F** 0 0 0 1 4 0

. A B C D E F

A 0 1 0 0 0 0

B 1 0 0 5 0 0

C 2 0 0 0 0 0

D 0 5 0 0 1 1

E 0 3 0 0 0 4

F 0 0 0 1 4 0