When directed graph is linear, return the nodes in order. Otherwise fail
Here is a quite non-optimal algorithm, to get you started.

Go over all edges $(a,b)$. For each edge, go again over all edges, and check how many times $a$ appears. Stop once you discover $a$ that appears only once (if this never happens, reject). We will take $n_1 = a$.

Go over all edges again, looking for the unique edge $(n_1,b)$ in which $n_1$ appears. Take $n_2 = b$.

Go over all edges again, looking for an edge $(n_2,c)$ in which $n_2$ appears on the left (if there is no such edge, reject). Take $n_3 = c$.

Continue in this way, finding $n_4,\ldots,n_n$.

This algorithm runs in $O(n^2)$. Using hashing, you should be able to improve it to $O(n)$.