def build_class_graph(modules, klass=None, graph=None):
        """ Builds up a graph of the DictCell subclass structure """
        if klass is None:
            class_graph = nx.DiGraph()
            for name, classmember in inspect.getmembers(modules, inspect.isclass):
                if issubclass(classmember, Referent) and classmember is not Referent:
                    TaxonomyCell.build_class_graph(modules, classmember, class_graph)
            return class_graph
        else:
            parents = getattr(klass, '__bases__')
            for parent in parents:
                if parent != Referent:
                    graph.add_edge(parent.__name__, klass.__name__)
                    # store pointer to classes in property 'class'
                    graph.node[parent.__name__]['class'] = parent
                    graph.node[klass.__name__]['class'] = klass 
                    if issubclass(parent, Referent):
                        TaxonomyCell.build_class_graph(modules, parent, graph)
def build_class_graph ( modules , klass = None , graph = None ) : if klass is None : class_graph = nx . DiGraph ( ) for name , classmember in inspect . getmembers ( modules , inspect . isclass ) : if issubclass ( classmember , Referent ) and classmember is not Referent : TaxonomyCell . build_class_graph ( modules , classmember , class_graph ) return class_graph else : parents = getattr ( klass , '__bases__' ) for parent in parents : if parent != Referent : graph . add_edge ( parent . __name__ , klass . __name__ ) graph . node [ parent . __name__ ] [ 'class' ] = parent graph . node [ klass . __name__ ] [ 'class' ] = klass if issubclass ( parent , Referent ) : TaxonomyCell . build_class_graph ( modules , parent , graph )
Builds up a graph of the DictCell subclass structure