Write a function
topological_ordering that takes the
location of a text file containing the description of a directed acyclic
graph $$\mathcal{G}$$ in the form of an adjacency list. Each line of the
file contains the label (an integer) of a starting node, a space, the
characters
->, another space and a comma-separated list
containing the lexicographically sorted labels (integers) of all ending
nodes connected to that starting node. The function must return a
topological ordering of graph $$\mathcal{G}$$, represented as tuple of node
labels.
Example
In the following interactive session, we assume the text file data01.txt to be located
in the current directory.
>>> topological_ordering('data01.txt')
(1, 4, 5, 2, 3)