Topological ordering tutorial: emit or certify a cycle
A fixed six-vertex digraph yields either a complete prerequisite order or an explicit cycle certificate; a downstream tail shows why a residual set is not itself a cycle.
Topological ordering tutorial: keep the arrows fixed
A topological order places every vertex of a directed graph in one list so that each arrow points from an earlier vertex to a later one. Given a complete, fixed graph, the decision is precise: produce such a list or identify a directed cycle proving that no list can work. The procedure below repeatedly removes a vertex with no incoming arrow from the remaining graph. It succeeds exactly when the supplied graph has no directed cycle.
This tutorial assumes that the vertices and arrows have already been defined. It does not discover prerequisites from a project narrative, clarify task outputs or change requirements to make a plan feasible. An arrow u→v means that u must occur strictly before v in the requested list. It carries no duration, distance, money or numerical difference. Keep this meaning with the input, because the cycle argument depends on strict precedence rather than merely on the shape of a drawing.
Write the complete six-vertex input
Use vertices A, B, C, D, E and F. The complete arrow list is A→C, B→C, C→D and D→E. There are no other arrows. F is an isolated vertex: no arrow enters or leaves it. Every vertex must appear in the output, including F. The question is not whether one selected destination can be reached from another vertex; it concerns an order of the entire supplied set.
Define a vertex's current indegree as the number of incoming arrows whose starting vertices are still present. Initially, A, B and F have indegree zero. C has indegree two, from A and B. D has indegree one, from C, and E has indegree one, from D. An outgoing arrow does not add to its starting vertex's indegree. These six values give a direct check on whether the arrow direction has been read correctly.
Repeat the zero-indegree step
Maintain a remaining-vertex set and an initially empty output list. Select any remaining vertex of indegree zero, append it to the output, and remove it together with its outgoing arrows. Recompute the relevant indegrees in the remaining graph, or decrement each outgoing neighbor's count once for the arrow just removed. Continue while a zero-indegree vertex is available. Stop successfully when no vertices remain; stop with a blocked residual graph if vertices remain but none has indegree zero.
For a reproducible trace, choose the alphabetically first available vertex. This is a tie rule for selecting one permitted answer, not an extra graph constraint. Initially the choices are A, B and F, so emit A. Removing A→C reduces C's indegree from two to one. B and F remain available. C is not yet available because B→C is still an incoming arrow from a remaining vertex.
Emit B next. Removing B→C reduces C's indegree to zero. The available vertices are now C and F, so the tie rule selects C. Its removal deletes C→D, making D available. Select D, whose removal deletes D→E and makes E available. Select E and finally F. The complete output is A, B, C, D, E, F. Each step uses the remaining graph, rather than continuing to count arrows whose starting vertices were already removed.
Check the complete output against every arrow
Read the original arrow list, not a partially erased sketch. A occurs before C, B occurs before C, C occurs before D, and D occurs before E. Every vertex appears once, and every arrow has its required earlier-to-later direction. This independently verifies the displayed output. The fact that the procedure stopped is not a substitute for checking that the saved list contains the full input vertex set without duplication.
Another valid list is F, B, A, C, D, E. F may appear first because it has no prerequisites, and A and B may exchange their relative positions because neither has an arrow to the other. This demonstrates that the original graph does not force a unique order. A tie-breaking convention can choose one answer consistently without proving that every other answer is wrong. No completion-time or minimum-move objective has been added to the graph.
Prove why a full emitted list is valid
Consider any input arrow u→v. When the procedure emits v, no incoming arrow from a remaining vertex can enter v. Therefore u cannot still be remaining at that moment. It must already have been emitted. Consequently u occurs earlier than v in any complete output produced by the procedure. Applying this reasoning to every input arrow establishes the topological-order condition for the whole list, rather than just for the few arrows in our example.
The procedure also cannot emit the same vertex twice, because emission removes that vertex from the remaining set. If it finishes with an empty remaining set, every original vertex has been emitted. Together, these facts prove that successful output is a complete valid order. They do not yet prove that every acyclic graph allows the procedure to finish; that requires a separate argument about whether a ready vertex must exist.
Show why an acyclic residual graph has a ready vertex
Suppose a nonempty finite directed graph has no vertex of indegree zero. Start at any vertex and select one incoming arrow, then move backward to its starting vertex. That new vertex also has an incoming arrow, so continue choosing predecessors. Because the graph is finite, this backward walk must eventually revisit a vertex. The part between two visits gives a closed sequence of directed arrows when read in their forward direction: a directed cycle.
The contrapositive is useful: a nonempty finite graph with no directed cycle must contain a zero-indegree vertex. Removing a vertex and arrows cannot create a cycle that was absent before. Thus, if the original graph is acyclic, every nonempty residual graph still has a vertex available for emission. Each step removes one vertex, so after finitely many steps the remaining set is empty. This proves that the procedure succeeds on every finite acyclic input under the stated rules.
Add one arrow and preserve the first input separately
Now create a second graph by adding D→B to the original arrow list. Keep the original graph as its own control; do not silently change its earlier successful trace. In the second graph, B→C, C→D and D→B form a directed cycle. The other original arrows, A→C and D→E, remain present, and F remains isolated. The changed input is completely specified by this one added arrow.
Initially A and F have indegree zero. Under the alphabetic rule, emit A and then F. Removing A→C leaves C with its incoming arrow from B. The residual vertices are B, C, D and E. Each has indegree one within that residual graph: B receives from D, C from B, D from C, and E from D. No zero-indegree vertex remains, so the procedure stops with output prefix A, F and that nonempty residual set.
Extract an actual cycle, not just a list of blocked vertices
Start a backward predecessor walk at E. Its incoming arrow comes from D. D's incoming arrow comes from C, C's from B, and B's from D. The backward vertex sequence is E, D, C, B, D. D has repeated. The actual selected arrows were D→E, C→D, B→C and D→B. Read the repeated portion in forward arrow direction to obtain D→B→C→D, equivalently the cycle B→C→D→B.
The direction qualification matters. Writing E→D→C→B→D as though those were forward arrows would invent edges not in the input. The backward walk is a way to discover a cycle; the reported certificate must list real arrows in their actual direction. Check B→C, C→D and D→B against the preserved second graph. This short certificate can be verified without replaying every earlier emission step.
Why does that certificate rule out every complete topological order? Such an order would require B before C, C before D and D before B. In terms of positions, it would demand pos(B)<pos(C)<pos(D)<pos(B), an impossibility. The argument rejects all possible linear lists, not merely the alphabetic attempt. Choosing F earlier or making a different permitted tie choice could not remove the contradiction created by the fixed cycle.
Keep the downstream tail distinct from the cycle
E remains blocked, but E is not on the displayed cycle. In fact, no outgoing arrow leaves E anywhere in the second graph, so E cannot belong to any directed cycle. It waits behind D, which is itself in the cycle. Thus the complete residual set B,C,D,E is not a cycle certificate. It contains a cycle together with an acyclic downstream vertex. Save the exact cycle edges rather than labeling every residual vertex cyclic.
This distinction also explains what the algorithm has and has not repaired. It has diagnosed that the fixed graph admits no complete precedence order. It has not authorized deleting D→B, redefining B, or replacing an input requirement with a provisional one. Those would produce a different graph requiring its own analysis. The appropriate mathematical output here is the blocked prefix, the residual graph and the explicit cycle witness, with the original input preserved.
Handle small boundaries with the same definitions
An empty graph has the empty list as a valid complete order. An isolated vertex has indegree zero and can be emitted whenever it is selected. A self-loop v→v gives v an incoming arrow from itself while it remains present, so v cannot be emitted; that loop is already a one-edge cycle certificate. These boundaries use the same strict-precedence definition and do not need exceptions invented after the procedure stops.
For the six-vertex controls, checking all 720 possible vertex permutations finds twelve valid orders for the first graph and none for the second. That finite enumeration checks the example's arithmetic and the claimed failure. The zero-indegree invariant and predecessor-walk proof establish the general finite-graph result. They do not establish measured software speed, resource use or an optimal real project schedule, none of which is part of this worksheet.
Keep the supporting references separate
The Gem map-tack listing shows complete colored round-headed tacks with pointed shafts. Its native category is Thumb Tacks & Push Pins. The picture does not authenticate a maker, delivered box count, dimensions, material or holding performance. It supplies optional paper-diagram context, not evidence about a graph's arrows.
The Baumgartens paper-clip listing shows individually packaged wire clips in a clear tub. Its native assortment description accounts for the colors, and its packaging matches the catalog name. Native category absence remains explicit. Delivered quantity, dimensions, recycled composition and holding performance are unverified; separately mentioned dispensers are not adopted as supplied contents.
The early path finalization repair guide repairs a weighted-path calculation using a supplied dependency order. This tutorial instead finds an order or certifies that no order exists for a fixed unweighted precedence graph. It does not calculate a smallest route score or reuse the weighted example.
The six-point two-color triangle puzzle freely labels undirected connections and proves a uniform triangle exists. Our arrows express strict precedence, and the cycle certificate proves the impossibility of a complete linear order. The edge meanings and the conclusions remain separate.
Keep an optional order enquiry outside the graph
If you later consider buying a supply for a paper worksheet, assess that purchase with its own current evidence. A valid graph order cannot authenticate a maker, confirm a delivered quantity or establish physical holding performance. Read the exact offer on republeq.com and resolve the item, variant, quantity, delivery and return information that matters to the intended order. If cryptocurrency appears among the payment choices for that purchase, examine those instructions before deciding whether to use it. Mentioning USDT here does not establish token acceptance, network support or an appropriate wallet. Where a suitable cryptocurrency method is actually offered, verify the asset, network, receiving destination, amount and order reference against the current transaction information. Keep any written clarification with the exact offer it identifies. If the basket, variant or payment instructions change, check the changed information rather than assuming an earlier answer still applies. Save any eventual acknowledgement with the order and transaction records so a later enquiry can identify what actually occurred. An uncertain payment or order status calls for reconciliation before considering another payment. This conditional paragraph reports no completed transaction, guarantees no acceptance, promises no discount and establishes no refund right. It also provides no assurance about fees, speed, token price stability or recovering an erroneous transfer. You can complete both graph examples without buying anything, creating an account or holding a token. Their vertices and arrows are fictional mathematical inputs. A cycle certificate proves a statement about that fixed input, while a transaction needs its own evidence; neither record can stand in for the other.
Retain the right certificate for the supplied graph
For the first graph, keep the complete A,B,C,D,E,F order beside the four original arrows. For the second, keep the added D→B arrow, emitted prefix A,F and actual cycle B→C→D→B. Record E as blocked downstream, not cyclic. The two outputs answer the same fixed-input decision in different cases: either every arrow admits a complete earlier-to-later order, or a directed cycle provides a verifiable reason that none can exist.