Graphs Flashcards

1
Q

What is a graph

A

Set of nodes connected by edges

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

What is a unweighted graph

A

All edges cost 0 to travel

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

What is a weighted graph

A

Each edge has a cost to travel

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

What is a undirected graph

A

Each edge is bi-directional

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

What is a directed graph

A

Each edge is one-way

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

How does an adjacency matrix represent a graph

A

Each row and column represent a node.
Item at [row, column] represents a connection.
In an unweighted graph this number is 1.
In a weighted graph the number is the weight

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

How does an adjacency list represent a graph

A

A list of nodes is created, and each node contains a list of connected nodes.

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

Advantage and disadvantage of using a adjacency matrix

A

Advantage: Easy to work with, adding an edge is easy

Disadvantage: Can have lots of wasted space if used with a sparse graph

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

Advantage and disadvantage of using a adjacency list

A

Advantage: Easy way to store large graphs as only stores information about connections that exist.

Disadvantage: It is slow to search through

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