Kahn's algorithm for Topological Sorting
        - Finds cycles in graph
        - Computes dependency weight

def _topological_sort(self):
        """
        Kahn's algorithm for Topological Sorting
        - Finds cycles in graph
        - Computes dependency weight
        """
        sorted_graph = []
        node_map = self._graph.get_nodes()

        nodes = [NodeVisitor(node_map[node]) for node in node_map]

        def get_pointers_for_edge_nodes(visitor_decorated_node):
            edges = []
            edge_ids = visitor_decorated_node.get_node().get_edges()
            for node in nodes:
                if node.get_id() in edge_ids:
                    edges.append(node)

            return edges

        # node is initially weighted with the number of immediate dependencies
        for node in nodes:
            for edge in get_pointers_for_edge_nodes(node):
                edge.increment()

        # Start with a list of nodes who have no dependents
        resolved = [node for node in nodes if node.get_weight() == 0]

        while resolved:
            node = resolved.pop()
            sorted_graph.append(node)

            for edge in get_pointers_for_edge_nodes(node):
                edge.decrement()
                if edge.get_weight() == 0:
                    resolved.append(edge)

        self._circular_dependencies = [
            node.get_node() for node in nodes if node.get_weight() > 0]

        self._sorted_nodes = list(reversed(
            [node.get_node() for node in sorted_graph]))