Chapter 9. Graphs Flashcards

1
Q

What is a list?

A

A linear data structure, where the elements are ordered in: A_1, A_2, A_3, … A_n. Order may or may not be relevant in this data structure.

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

What is a tree?

A

A generalization of a list, each branch is composed of lists.

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

What is a graph?

A

Essentially a graph is a collection of vertices (V) and edges (E).

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

What are the two main variations that we can have for a graph?

A

We can have a directed graph or an undirected graph.

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

What is an edge in a directed graph?

A

An edge from a directed graph is, a pair (v,w). Where v is the starting vertex and w is the ending vertex.

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

What is an edge in an undirected graph?

A

A pair (v,w) belonging to the set of edges. Such that v or w is the starting vertix and v or w but not both is the ending vertix.

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

What is the weight of an edge in a graph?

A

The cost associated with each edge. The cost of getting from one vertex to another.

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

Why are graph algorithms so important?

A

Because the algorithms can be used to solve many real world applications.

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

What is an edge?

A

A single path (v,w) from one vertex v to another vertex w.

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

What is the in-degree of a vertex v?

A

Indicates how many vertices go into v.

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

What is the out-degree of a vertex u?

A

Number of edges that go out of the vertex u.

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

When do we say that vertex w is adjacent to vertex v?

A

If and only if (v,w) is an element of the set of edges.

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

What is a path in a graph?

A

A sequence of vertices w_1, w_2, w_3, … w_n such that each pair (w_i, w_(i+1)) forms an edge.

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

What is the length of a path?

A

This is proportional to the number of edges in the path. Or to the number of vertices visited: N - 1.

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

What is a simple path?

A

Path in which all vertices are distinct, except that the first and last vertices can be the same. We don’t cross the same vertex more than once, unless that same vertex is the first and last one.

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

What is a cycle in a directed graph?

A

Path in a directed graph, of length at least 1 such that the starting and ending vertices are the same.

17
Q

When is a cycle in a directed graph simple?

A

When all vertices are distinct except for possibly the first and last ones can be the same.

18
Q

What is a cycle in an undirected graph?

A

Cycle such, that the first and last vertices are equal except that all edges must be distinct. Because for every (v,u), (u,v) is essentially the same edge.

19
Q

When is a directed graph acyclic?

A

When the directed graph has no cycles.

20
Q

What is a loop?

A

edge (v,v) such that it is a path from a vertex v to itself.

21
Q

When is an undirected graph said to be connected?

A

When there is a path from every vertex to every other vertex.

22
Q

When is a directed graph said to be strongly directed?

A

Whenever there is a path from every vertex to every other vertex

23
Q

When is a directed graph said to be weakly connected?

A

When the underlying graph (graph with no arrows) is connected.

24
Q

What is a complete graph, for an undirected graph?

A

If there is an edge for every pair of distinct vertices (v, w).

25
Q

What is a real life example of where we would see graphs?

A

Airport systems with graphs, where each airport is a vertex.

26
Q

What are the two methods that we utilize to represent graphs?

A

Adjacency matrix as well as adjacency list.

27
Q

What is an adjacency matrix?

A

A two dimensional array, if an edge (u,v) exists then A[u][v] is set too true and false otherwise.

28
Q

How do we represent graphs with weights with adjacency matrices?

A

Set A[u][v] equal to the weight, and we utilize a sentinel value to indicate that an edge does not exist.

29
Q

When do we consider a graph to be dense?

A

For every vertex, we have an edge going to every other vertex.

30
Q

What is an adjacency list?

A

Standard way to represent graphs which are “sparse” in other words not dense.

31
Q

Why is an adjacency list better than an adjacency matrix?

A

Because, we don’t need to worry about creating space for edges that don’t even exist.

32
Q

What do we store in an adjacency list?

A

For every vertex, we store the adjacent vertices.

33
Q

What is a subgraph?

A

Denoted as G’, vertex and edge set of a subgraph are a subset of the set of vertices and edges of G.