{
  "slug": "topological-sort",
  "title": "Topological Sort",
  "category": "Graphs",
  "difficulty": "medium",
  "complexity": {
    "time": "O(V + E)",
    "space": "O(V)"
  },
  "idea": "Kahn's algorithm counts how many prerequisites each node has. Anything with zero is ready to go; taking it removes one prerequisite from each of its successors, which may make them ready too. If everything comes out, the graph had no cycle.",
  "code": [
    "compute indegree of every node",
    "queue = all nodes with indegree 0",
    "while queue not empty:",
    "    cur = queue.pop(); append cur to order",
    "    for each cur -> nb: if --indegree[nb] == 0: queue.push(nb)"
  ],
  "example": {
    "array": []
  },
  "invariant": "Each step is the real data structure at that step — the picture is a pure function of it.",
  "stepCount": 15,
  "steps": [
    {
      "i": 0,
      "op": "graph",
      "caption": "Count each node’s prerequisites — the number under it is its indegree.",
      "note": null,
      "codeLine": 1,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": null,
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": null,
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "2",
          "focus": null,
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "2",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": [
            "A",
            "B"
          ]
        },
        {
          "label": "topological order",
          "items": []
        }
      ]
    },
    {
      "i": 1,
      "op": "graph",
      "caption": "A and B need nothing — they are ready to go.",
      "note": null,
      "codeLine": 2,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "insert",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "insert",
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "2",
          "focus": null,
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "2",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": [
            "A",
            "B"
          ]
        },
        {
          "label": "topological order",
          "items": []
        }
      ]
    },
    {
      "i": 2,
      "op": "graph",
      "caption": "Take A — all its prerequisites are done.",
      "note": null,
      "codeLine": 4,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": null,
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "2",
          "focus": null,
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "2",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": [
            "B"
          ]
        },
        {
          "label": "topological order",
          "items": [
            "A"
          ]
        }
      ]
    },
    {
      "i": 3,
      "op": "graph",
      "caption": "C still needs 1 more.",
      "note": null,
      "codeLine": 5,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": null,
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "1",
          "focus": "read",
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "2",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "active"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": [
            "B"
          ]
        },
        {
          "label": "topological order",
          "items": [
            "A"
          ]
        }
      ]
    },
    {
      "i": 4,
      "op": "graph",
      "caption": "Take B — all its prerequisites are done.",
      "note": null,
      "codeLine": 4,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "C",
          "label": "C",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "2",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": []
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B"
          ]
        }
      ]
    },
    {
      "i": 5,
      "op": "graph",
      "caption": "C has no prerequisites left — it becomes ready.",
      "note": null,
      "codeLine": 5,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "C",
          "label": "C",
          "text": "0",
          "focus": "insert",
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "2",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "active"
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": [
            "C"
          ]
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B"
          ]
        }
      ]
    },
    {
      "i": 6,
      "op": "graph",
      "caption": "Take C — all its prerequisites are done.",
      "note": null,
      "codeLine": 4,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "D",
          "label": "D",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "2",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": []
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B",
            "C"
          ]
        }
      ]
    },
    {
      "i": 7,
      "op": "graph",
      "caption": "D has no prerequisites left — it becomes ready.",
      "note": null,
      "codeLine": 5,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "D",
          "label": "D",
          "text": "0",
          "focus": "insert",
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "1",
          "focus": null,
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "2",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": "active"
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": [
            "D"
          ]
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B",
            "C"
          ]
        }
      ]
    },
    {
      "i": 8,
      "op": "graph",
      "caption": "E has no prerequisites left — it becomes ready.",
      "note": null,
      "codeLine": 5,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "D",
          "label": "D",
          "text": "0",
          "focus": null,
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "0",
          "focus": "insert",
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "2",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": "active"
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": [
            "D",
            "E"
          ]
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B",
            "C"
          ]
        }
      ]
    },
    {
      "i": 9,
      "op": "graph",
      "caption": "Take D — all its prerequisites are done.",
      "note": null,
      "codeLine": 4,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "E",
          "label": "E",
          "text": "0",
          "focus": null,
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "2",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": [
            "E"
          ]
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B",
            "C",
            "D"
          ]
        }
      ]
    },
    {
      "i": 10,
      "op": "graph",
      "caption": "F still needs 1 more.",
      "note": null,
      "codeLine": 5,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "E",
          "label": "E",
          "text": "0",
          "focus": null,
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "1",
          "focus": "read",
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": "active"
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": [
            "E"
          ]
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B",
            "C",
            "D"
          ]
        }
      ]
    },
    {
      "i": 11,
      "op": "graph",
      "caption": "Take E — all its prerequisites are done.",
      "note": null,
      "codeLine": 4,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "F",
          "label": "F",
          "text": "1",
          "focus": null,
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": null
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": []
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B",
            "C",
            "D",
            "E"
          ]
        }
      ]
    },
    {
      "i": 12,
      "op": "graph",
      "caption": "F has no prerequisites left — it becomes ready.",
      "note": null,
      "codeLine": 5,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        },
        {
          "id": "F",
          "label": "F",
          "text": "0",
          "focus": "insert",
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": "active"
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": [
            "F"
          ]
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B",
            "C",
            "D",
            "E"
          ]
        }
      ]
    },
    {
      "i": 13,
      "op": "graph",
      "caption": "Take F — all its prerequisites are done.",
      "note": null,
      "codeLine": 4,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "0",
          "focus": "settled",
          "badges": [
            "cur"
          ]
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": "settled"
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": []
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B",
            "C",
            "D",
            "E",
            "F"
          ]
        }
      ]
    },
    {
      "i": 14,
      "op": "graph",
      "caption": "Every node came out — a valid order is A B C D E F.",
      "note": null,
      "codeLine": 4,
      "stats": null,
      "nodes": [
        {
          "id": "A",
          "label": "A",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "B",
          "label": "B",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "C",
          "label": "C",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "D",
          "label": "D",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "E",
          "label": "E",
          "text": "0",
          "focus": "settled",
          "badges": null
        },
        {
          "id": "F",
          "label": "F",
          "text": "0",
          "focus": "settled",
          "badges": null
        }
      ],
      "edges": [
        {
          "from": "A",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "B",
          "to": "C",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "D",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "C",
          "to": "E",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "D",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": "settled"
        },
        {
          "from": "E",
          "to": "F",
          "weight": null,
          "directed": true,
          "tone": "settled"
        }
      ],
      "rows": [
        {
          "label": "ready (indegree 0)",
          "items": []
        },
        {
          "label": "topological order",
          "items": [
            "A",
            "B",
            "C",
            "D",
            "E",
            "F"
          ]
        }
      ]
    }
  ]
}