Algorithms on Graphs

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/6

encourage image

There's no tags or description

Looks like no tags are added yet.

7 Terms

1
New cards

What does Kruskal’s Algorithm do?

Find the minimum spanning tree

2
New cards

Kruskal’s Algorithm

1- Sort all arcs into ascending order of weight

2- Select the arc of least weight to start the tree

3- Consider the next arc of least weight. If it creates a cycle reject it. If not, add it to the tree.

4- Repeat until all vertices are connected

3
New cards

What does Prim’s Algorithm do

Find the minimum spanning tree

4
New cards

Prim’s Algorithm

1- Select a vertex to start the tree

2- Select an arc of least weight that connects a vertex not in the tree to a vertex in the tree

3- Repeat until all vertices are connected

5
New cards

How to do Prim’s Algorithm on a distance matrix

1- Choose any vertex to start the tree

2- Delete the row in the matrix for the chosen vertex

3- Number the column in the matrix for the chosen vertex

4- Put a ring around the lowest undeleted entry in the numbered columns

5- The ringed entry becomes the next arc in the tree

6
New cards

What does Dijkstra’s Algorithm do?

Find the shortest path from S to T

7
New cards

Dijkstra’s Algorithm

1- Label the start vertex S with final label 0

2- Record a working value (final label + weight of arc) at every vertex that is connected to the vertex that has just received its final label. Only record the working value if it is smaller than the current value at the vertex

3- Look at all vertices without final labels. Select the one with the smallest working value and make this the final label.

4- Repeat until T receives its final label

5- Trace back from T to S, vertices on the path will have a final label such that the previous final label - the weight of the arc = the final label