human
Write me a Python program to find any topological order for the given graph given the following:
I am working on the file "04_BFS.ipynb".
The first task is:
Topological Sorting

Given an directed graph, a topological order of the graph nodes is defined as follow:
For each directed edge A -> B in graph, A must before B in the order list.
The first node in the order can be any node in the graph with no nodes direct to it.
Find any topological order for the given graph.
http://www.lintcode.com/en/problem/topological-sorting/
Can you write Python program for it?
assistant
#Here is Python program to find any topological order for the given graph.

# Definition for a Directed graph node
# class DirectedGraphNode:
#     def __init__(self, x):
#         self.label = x
#         self.neighbors = []

class Solution:
    """
    @param graph: A list of Directed graph node
    @return: A list of graph nodes in topological order.
    """
    def topSort(self, graph):
        # write your code here
        dic = {}
        for node in graph:
            dic[node] = 0
        
        for node in graph:
            for n in node.neighbors:
                dic[n] += 1
        
        order = []
        for node in graph:
            if dic[node] == 0:
                order.append(node)
        
        queue = order[:]   ## right way to copy a list!!!
        while queue:
            node = queue.pop(0)
            for n in node.neighbors:
                dic[n] -= 1
                if dic[n] == 0:
                    order.append(n)
                    queue.append(n)
        
        return order if len(order) == len(dic) else None