Graph Theory Flashcards

1
Q

Who is the birth of graph theory attributed to?

A

Euler and the Seven Bridges of Konigsberg problem

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

Examples of real world problems formulated as graphs

A
  • What is the fastest way to get from city A to city B? or
  • What is the cheapest way to get from city A to city B?
  • Are all the circuits in a computer connected?
  • Social Connections
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a graph?

A
  • A graph is a collection of vertices (nodes) and edges (arcs)
  • G = (V,E)
  • Vertices (V) are objects that have properties associated with them
  • Edges (E) normally do not have properties (values) but they may have.
  • Graphs that have valued edges are called weighted graphs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Where might the shape of the graph matter?

A

For instance, if we’re representing cities as they appear in the map we may
not want to change the shape of the graph
• We may want a more realistic representation for the cities’ locations.

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

What is a graph path?

A

A path from node A to node B in a graph is a list of nodes where successive nodes are connected in the graph

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

What is a simple path?

A

• A simple path is a path in which no node is repeated

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

What is a cycle?

A

A cycle is a path that is simple except that the first and the last nodes are the same.
It is a path from a node back to itself.

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

Difference between a directed and undirected graph

A

• A connected (undirected) graph with no cycles is called a tree

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

What is a spanning graph?

A

A spanning tree T of an undirected graph G is a subgraph that is a tree which includes all of the vertices of G, with minimum possible number of edges.

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

How many edges can be in a graph?

A

• The number of edges in a graph can range from 0 (zero) to V(V-1)/2.

V = Vertices

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

What is a sparse graph?

A
  • We call a sparse graph a graph in which E is much less than V2
  • In general we say that in a sparse graph E = O(V)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a dense graph?

A

We call a dense graph one in which E is close to V2

• Or we say that in a dense graph E = Θ(V2)

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

What is a complete graph?

A
  • We call a complete graph a graph in which E is exactly V(V-1)/2
  • A complete graph with k nodes is also called a k-clique.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is an adjacency list?

A

A way to represent a graph (usually sparse).
Consists of an array, adj, of all nodes in the graph.
For each node, i, adj[i] is a list of all other nodes i is connected to.

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

What is an adjacency matrix?

A

Preferred when representing dense graphs.
i x i matrix, where there are 1s between connected nodes.
Always symmetrical in undirected graphs.

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

Breadth first search

A

Practise this (its easy)
Graph search algorithm, results in a tree of searched nodes. Useful for algorithms like Dijkstra’s algorithm.
Uses a queue.

17
Q

Depth first search

A

Graph search algorithm, follows a node until it has no unexplored child nodes, and then backtracks.
Uses a stack.

18
Q

Minimum spanning tree

A

Spanning tree for a weighted graph such that the total weight of each edge is minimum. Found using a priority queue DFS.

19
Q

Dijkstra’s Algorithm

A

Priority queue of the cheapest paths from the start node to each node.

20
Q

What happens if 2 weights are the same in dijkstra’s algorithm?

A

Longer paths are rejected in favour of shorter paths (when the weight of the paths are the same)