Graph Algorithms Flashcards

1
Q

Dijkstra’s algorithm (3)

A
  1. ) Used to find the shortest path from one node (“source”) to every other node.
  2. ) Part of greedy technique.
  3. ) Works only on graphs with non negative edges.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Dijkstra’s how (6)

A
  1. ) Assign 0 to initial node and infinity to all others.
  2. ) Set initial node as current, all others as unvisited.
  3. ) Calculate all tentative distances from adjacent nodes. If value is lower than current assign it.
  4. ) Set node as visited.
  5. ) if destination node is set as visited or no more nodes are available, algorithm has finished.
  6. ) else select node with lowest tentative distance and repeat from 3.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Spanning tree (1)

A

1.) Tree which contains all vertices in the graph.

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

Minimum spanning tree (1)

A

1.) Spanning tree in a weighted graph with the lowest possible weight.

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

Prim’s algorithm (2)

A
  1. ) Used to find the minimum spanning tree in a graph.

2. ) Part of greedy technique.

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

Prim’s how (3)

A
  1. ) Select a vertex to be the first in the tree.
  2. ) Consider all vertices adjacent to the tree, and add the lowest one.
  3. ) Repeat 2 until each vertex is included.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Kruskal’s algorithm (2)

A
  1. ) Used to find the minimum spanning tree in a graph.

2. ) If graph is made of sub-graphs, find minimum spanning forest.

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

Kruskal how (6)

A
  1. ) Remove all loops.
  2. ) Remove parallel edges (keep ones with lowest weight).
  3. ) Create edge table sorted in ascending order.
  4. ) Select edge with minimum weight.
  5. ) Select edge with minimum weight which doesn’t form a cycle.
  6. ) Repeat 5 until each vertex is included.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly