Week4 - Graph algorithms Flashcards

1
Q

Conditions for topological sorting

A

DAG:

Directed - Directed Graph
Acyclic

G is just graph

said to be a DAG if :
- irreflexive ( no self loops )
- does not contain any cycles of length >= 2

hint when you do DFS part look for a vertex with no in degree or small in degree

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

very good video on topological sorting must watch

A

https://youtu.be/yYW6lQ1ajx4?si=vpi5MSyPXn5FFqpy

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

Q1: What is a Strongly Connected Component (SCC)?

A

A strongly connected component is a maximal subset C of vertices such that for all u, v in C, there is a path from u to v and a path from v to u.

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

JUST READ VERY GOOD NOYTES

A

Topological sorting (which is typically used to determine task ordering and concurrency) only works on DAGs

When you have cycles, it means tasks depend on each other in a circular way, which creates a logical impossibility for ordering

You can’t determine a valid sequence when Task A needs Task B to complete, but Task B also needs Task A to complete

Your peer suggests the solution would be to:

Find the Strongly Connected Components (SCCs) - these are groups of nodes that form cycles
Treat each SCC as a single unit, which would create a DAG
Then use topological sorting on this new DAG to determine which tasks can be performed concurrently

This is a valid approach because tasks within a cycle must effectively be performed together or considered as one unit, since they can’t be sequenced independently.

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

: How is a binary relation ( ~) defined for Strongly Connected Components?

A

A binary relation ~ is defined such that u ~ v if u = v or there exists a path from u to v and a path from v to u.

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

What does the term “maximal subset” mean in the context of SCCs?

A

A maximal subset is the largest possible subset C of vertices where all vertices are strongly connected to each other. Adding any vertex outside C would break the property of strong connectivity.

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

difference between kruskals algorithm and primms

A

In kruskal we dont care if minimums spanning tree is connected we are just growing lots of smaller trees that come together to form one final tree

but in prims we do

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

if all edges are distinct ( different weights ) how many minimum spanning trees

A

If all edge weights in a graph are distinct, there will be exactly one unique Minimum Spanning Tree (MST). This is because greedy algorithms (like Kruskal’s or Prim’s) always have a clear choice for the smallest edge, with no ties or ambiguity. The cycle and cut properties also ensure a unique solution.

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