def source_components(self):
        """
        Return the strongly connected components not reachable from any other
        component.  Any component in the graph is reachable from one of these.

        """
        raw_sccs = self._component_graph()

        # Construct a dictionary mapping each vertex to the root of its scc.
        vertex_to_root = self.vertex_dict()

        # And keep track of which SCCs have incoming edges.
        non_sources = self.vertex_set()

        # Build maps from vertices to roots, and identify the sccs that *are*
        # reachable from other components.
        for scc in raw_sccs:
            root = scc[0][1]
            for item_type, w in scc:
                if item_type == 'VERTEX':
                    vertex_to_root[w] = root
                elif item_type == 'EDGE':
                    non_sources.add(vertex_to_root[w])

        sccs = []
        for raw_scc in raw_sccs:
            root = raw_scc[0][1]
            if root not in non_sources:
                sccs.append([v for vtype, v in raw_scc if vtype == 'VERTEX'])

        return [self.full_subgraph(scc) for scc in sccs]
def source_components ( self ) : raw_sccs = self . _component_graph ( ) vertex_to_root = self . vertex_dict ( ) non_sources = self . vertex_set ( ) for scc in raw_sccs : root = scc [ 0 ] [ 1 ] for item_type , w in scc : if item_type == 'VERTEX' : vertex_to_root [ w ] = root elif item_type == 'EDGE' : non_sources . add ( vertex_to_root [ w ] ) sccs = [ ] for raw_scc in raw_sccs : root = raw_scc [ 0 ] [ 1 ] if root not in non_sources : sccs . append ( [ v for vtype , v in raw_scc if vtype == 'VERTEX' ] ) return [ self . full_subgraph ( scc ) for scc in sccs ]
Return the strongly connected components not reachable from any other
        component.  Any component in the graph is reachable from one of these.