Graph Implementations Flashcards

1
Q

What are the two ways of implementing graphs ?

A

Adjacency matrix , adjacency list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an adjacency matrix

A

Two dimensional array that records the relationship between each node and all other nodes in the graph .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain the adjacency matrix between nodes in an unweighted graph?

A

1 is used if there is an edge existing between 2 nodes
0 is used when there is no edge between 2 nodes .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How would you determine the presence or absence of an edge ?

A

You can inspect using the row / column that represents the node.
You may need a dictionary to record which row is used for a specific nodes edge data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How are the values of weights stores in the adjacency matrix.?

A

If you don’t have an edge existing between two nodes , a very large number for example the Infinity sign is shown.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the role/ point of an adjacency list?

A

It records the existence of an edge between each node and all of its neighbours.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What happens with the adjacency list if they are unweighted?

A

Lists each nodes neighbours

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How could you store the information in an adjacency list?

A

Use an array , or a combination of an array of records and a dictionary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the adjacency list used for in a weighted graph ?

A

Used to record the connection between two nodes and their corresponding weights.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Name some differences between adjacency lists vs adjacency matrices ?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly