Math - Adjacency Matrix - Challenge

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:
16_VM_MFG

1 Like
 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
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:

image

1 Like

challengeAdjacentMatrix

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

      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

_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

THIS IS MY GRAPH for the challenge
ABCDEF
A0100 0 0
B1005 0 0
C2000 0 0
D0500 1 1
E0300 0 4
F0001 4 0

image


sorry If I did some mistake I took what I understood and applied it in the challenge

Privacy & Terms