Topological Sort

Enter the adjacency list of your graph. Each line must start with a vertex label. The other tokens in the line for a vertex u describe the vertices reachable from u over the outgoing edges. Separate the tokens with space(s).

In the example below, the vertex undershorts is adjacent with vertices pants and shoes.

The maximum input length is limited by 300 characters including spaces.

Program output

Source code