title: Determine whether a directed graph has a unique topological ordering?
body: <p>I'm trying to create pseudo-code for an algorithm that will be able to determine whether a directed graph has a unique topological ordering. I've already come up with the following pseudo-code for a topological sort, but what would I have to add or edit in order to determine whether a digraph has a unique topological ordering?</p>
  
  <pre><code>Input: A graph G
  Output: A list L that contain the sorted vertices
  
   define an empty list L;
   create a stack Stack;
   push all vertices with no incoming edges into Stack;
   while Stack is not empty do
  
  v ← Stack.pop();
  add v to the list L;
  
  for all the vertices w with an edge e from v to w do
  remove edge e from G;
   if w has no other incoming edges then
  push w into Stack;
   if G has edges left then
   return error (graph G can’t be topological ordered);
  ￼￼￼￼￼￼￼￼￼ else
   return L;
  </code></pre>