docs(docs): add Carousel component and embed in topological‑sort page, replace static spine image with interactive component

This commit is contained in:
Prad Nukala committed 2026-09-22 14:11:33 -04:00
1 parent fd3b1952b1
commit 1a440e55ce
17 files changed
+635 -556

No files matched your search

+1 -1
View File
@@ -3,7 +3,7 @@ title: Overview
description: Live SRS campaign dashboard — phases, ladder, review queue, gates, and recent attempts, fetched from the SRS Worker.
---
![Dependency Map](../public/dependency-spine.svg)
<DependencySpine />
Live view of the 56-day campaign. Everything below is fetched client-side
from the SRS Worker, so it is always current — no rebuild required.
+29 -6
View File
@@ -8,11 +8,11 @@ hidden: true
Before we get started on topological order, let's talk about directed graphs first. A graph is directed when its edges have directions (these edges are also called arcs). Suppose that v, w are vertices in a directed graph. Let's get familiar with a few concepts.
- in-edge - an edge pointing to or coming into the node
- out-edge - an edge pointing away or going out from the node (we will refer those nodes on the other end of the out-edges of v to v's neighbors)
- in-degree - the number of in-edges coming into the node
- out-degree - the number of out-edges going out from the node
- dependency - "v depends on w" / "v is dependent on w" means that there is a directed path from w to v where v, w are vertices in a directed graph. With these new terms under our belt, it will make more sense when we talk about directed graphs.
- **in-edge** - an edge pointing to or coming into the node
- **out-edge** - an edge pointing away or going out from the node (we will refer those nodes on the other end of the out-edges of v to v's neighbors)
- **in-degree** - the number of in-edges coming into the node
- **out-degree** - the number of out-edges going out from the node
- **dependency** - "v depends on w" / "v is dependent on w" means that there is a directed path from w to v where v, w are vertices in a directed graph. With these new terms under our belt, it will make more sense when we talk about directed graphs.
## What is a topological order?
@@ -33,10 +33,33 @@ Task 3 is completely independent of task 2 and 4, and it can be anywhere in the
It should be obvious that if a graph with a cycle does not have a topological ordering. In the above example, 2 has to come before 5 which has come before 4 which has to come before 2 which has to come before 5... which is impossible.
:::
## Kahn's Algorithm
To obtain a topological order, we can use Kahn's algorithm which is very similar to Breadth First Search.
In order to understand why we must use this algorithm we first look at the problem it is trying to solve.
Given a directed graph does there exist a way to remove the nodes such that each time we remove a node we guarantee that no other nodes point to that particular node?
For this algorithm, we systematically remove one node at a time, each time removing a node such that no other nodes point to that node (in-degree is 0). If no such node exists, then there must be a cycle, and there is no way to order the nodes such that "every node appears in the ordering before all the nodes it points to" (no solution). After removing the current node, for each neighboring node the current node points to, we check whether any nodes point to this node. If there isn't any, we push this node into the queue. Notice it is important to keep track of the number of nodes pointing to a node (in-degree) in the question as we only push the node into the queue once all nodes the current node depended on have been removed.
Here is a graphic to demonstrate the idea.
<Carousel>
<CarouselImage src='../../public/topo_kahn.001.png' />
<CarouselImage src='../../public/topo_kahn.002.png' />
<CarouselImage src='../../public/topo_kahn.003.png' />
<CarouselImage src='../../public/topo_kahn.004.png' />
<CarouselImage src='../../public/topo_kahn.005.png' />
<CarouselImage src='../../public/topo_kahn.006.png' />
<CarouselImage src='../../public/topo_kahn.007.png' />
<CarouselImage src='../../public/topo_kahn.009.png' />
<CarouselImage src='../../public/topo_kahn.010.png' />
</Carousel>
## Example Code
:::note
:::tip
Notice the topological sort algorithm is very similar to BFS. The main difference is that we only push nodes with 0 in-degree into the queue in topological sort whereas in BFS we push all the neighboring nodes into the queue.
:::