Ticket #11880: trac_11880-object_oriented.patch

File trac_11880-object_oriented.patch, 24.8 KB (added by ncohen, 8 years ago)
  • doc/en/reference/misc.rst

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1329764537 -3600
    # Node ID f48c07be6d0ac463c2103bd830cce45945a9b0fd
    # Parent  d84d80415d829517538b92a21dfb3db973cd4d80
    ISGCI database -- updating the design : from functions to methods
    
    diff --git a/doc/en/reference/misc.rst b/doc/en/reference/misc.rst
    a b  
    3535   sage/misc/lazy_import
    3636   sage/misc/log
    3737   sage/misc/persist
     38   sage/misc/unknown
    3839   sage/misc/func_persist
    3940   sage/misc/sage_eval
    4041   sage/misc/random_testing
  • sage/graphs/isgci.py

    diff --git a/sage/graphs/isgci.py b/sage/graphs/isgci.py
    a b  
    1313How to use it?
    1414--------------
    1515
    16 The current limited aim of this module is to provide a pure
    17 Sage/Python interface which is easier to deal with than a XML file. I
    18 hope it will be rewritten many times until it stabilizes :-)
     16The current limited aim of this module is to provide a pure Sage/Python
     17interface which is easier to deal with than a XML file. I hope it will be
     18rewritten many times until it stabilizes :-)
    1919
    2020Presently, it is possible to use this database through the variables and methods
    2121present in the :obj:`graph_classes <sage.graphs.isgci.GraphClasses>` object.
     
    2424    sage: Trees = graph_classes.Tree
    2525    sage: Chordal = graph_classes.Chordal
    2626
    27 It is then possible to check the inclusion of classes inside of
    28 others, if the information is available in the database::
     27It is then possible to check the inclusion of classes inside of others, if the
     28information is available in the database::
    2929
    3030    sage: Trees <= Chordal
    3131    True
     
    3434
    3535.. WARNING::
    3636
    37     At the moment, only *positive* answers are guaranteed correct!
     37    The ISGCI database is not all-knowing, and so comparing two classes can
     38    return ``True``, ``False``, or ``Unknown`` (see the :mod:`documentation of
     39    the Unknown truth value <sage.misc.unknown>`).
    3840
    39     A *negative* answer to ``A <= B`` only means that ISGCI can't
    40     deduce from the information in its database that ``A`` is a
    41     subclass of ``B`` nor that it is not. For the reverse inclusion
    42     between Trees and Chordal graphs the answer is correct though::
     41    An *unknown* answer to ``A <= B`` only means that ISGCI cannot deduce from
     42    the information in its database that ``A`` is a subclass of ``B`` nor that
     43    it is not. For instance, ISGCI does not know at the moment that some chordal
     44    graphs are not trees::
    4345
    44         sage: Chordal <= Trees
    45         False
    46 
    47     TODO: what about using a Troolean?
    48 
    49     TODO: what about strict inclusion?
     46        sage: graph_classes.Chordal <= graph_classes.Tree
     47        Unknown
    5048
    5149Given a graph class, one can obtain its associated information in the
    5250ISGCI database with the :meth:`show
     
    7472    3-Colourability                :  Linear
    7573    Recognition                    :  Linear
    7674
    77 It is possible to obtain the complete list of the classes stored in
    78 ISGCI by calling the :func:`sage.graphs.isgci.show_all` function
     75It is possible to obtain the complete list of the classes stored in ISGCI by
     76calling the :meth:`show_all <sage.graphs.isgci.GraphClasses.show_all>` function
    7977(beware -- long output)::
    8078
    81     sage: sage.graphs.isgci.show_all()
     79    sage: graph_classes.show_all()
    8280    ID        | name                                     | type                 | smallgraph
    8381    ----------------------------------------------------------------------------------------------------------------------
    8482    gc_309    | $K_4$--minor--free                       | base                 |
     
    9189    ...
    9290
    9391Until a proper search method is implemented, this lets one find
    94 classes which are not listed in :obj:`graph_classes <sage.graphs.isgci.GraphClasses>`.
    95 
    96 TODO: get_class_from_id is currently a method of graph_classes whereas
    97 show_all is a function of this module. Should show_all be moved to
    98 graph_classes for consistency?
     92classes which do not appear in:obj:`graph_classes.* <sage.graphs.isgci.GraphClasses>`.
    9993
    10094To retrieve a class of graph from its ISGCI ID one may use
    101 :meth:`graph_classes.get_class_from_id <GraphClasses.get_class_from_id>`::
     95:meth:`graph_classes.get_class <GraphClasses.get_class>`::
    10296
    103     sage: GC = graph_classes.get_class_from_id("gc_5")
     97    sage: GC = graph_classes.get_class("gc_5")
    10498    sage: GC
    105     Graph class : $P_4$--bipartite
     99    $P_4$--bipartite graphs
    106100
    107101Predefined classes
    108102------------------
    109103
    110104:obj:`graph_classes <sage.graphs.isgci.GraphClasses>` currently lists the following graph classes
    111105
    112 TODO: use .. seealso:: in all entries of this list?
    113 
    114106.. list-table::
    115107   :widths: 20 30
    116108   :header-rows: 1
     
    136128
    137129     - :meth:`is_chordal <sage.graphs.generic_graph.GenericGraph.is_chordal>`
    138130
    139    * - Clique
    140 
    141      - :meth:`CompleteGraph <sage.graphs.graph_generators.GraphGenerators.CompleteGraph>`,
    142        :meth:`is_clique <sage.graphs.generic_graph.GenericGraph.is_clique>`
    143 
    144131   * - Comparability
    145132     -
    146133
     
    190177       :meth:`is_tree <sage.graphs.generic_graph.GenericGraph.is_tree>`
    191178
    192179   * - UnitDisk
    193      -
     180     - :meth:`IntervalGraph <sage.graphs.graph_generators.GraphGenerators.IntervalGraph>`,
    194181
    195182   * - UnitInterval
    196183
    197184     - :meth:`is_interval <sage.graphs.generic_graph.GenericGraph.is_interval>`
    198185
     186Sage's view of ISGCI
     187--------------------
     188
     189The database is stored by Sage in two ways.
     190
     191**The classes :** the list of all graph classes and their properties is stored
     192in a huge dictionary (see :meth:`classes()
     193<sage.graphs.isgci.GraphClasses.classes>`). Below is what Sage knows of
     194``gc_249``::
     195
     196    sage: graph_classes.classes()['gc_249']
     197    {'problems':
     198        {'Independent set': 'Polynomial',
     199         'Treewidth': 'Unknown',
     200         'Weighted independent set': 'Polynomial',
     201         'Cliquewidth expression': 'NP-complete',
     202         'Weighted clique': 'Polynomial',
     203         'Clique cover': 'Unknown',
     204         'Domination': 'NP-complete',
     205         'Clique': 'Polynomial',
     206         'Colourability': 'NP-complete',
     207         'Cliquewidth': 'Unbounded',
     208         '3-Colourability': 'NP-complete',
     209         'Recognition': 'Linear'},
     210     'type': 'base',
     211     'ID': 'gc_249',
     212     'name': 'line'}
     213
     214**The class inclusion digraph :** Sage remembers the class inclusions through
     215the inclusion digraph (see :meth:`inclusion_digraph()
     216<sage.graphs.isgci.GraphClasses.inclusion_digraph>`). Its nodes are ID of ISGCI
     217classes::
     218
     219    sage: d = graph_classes.inclusion_digraph()
     220    sage: d.vertices()[-10:]                   
     221    ['gc_990', 'gc_991', 'gc_992', 'gc_993', 'gc_994', 'gc_995', 'gc_996', 'gc_997', 'gc_998', 'gc_999']
     222
     223An arc from ``gc1`` to ``gc2`` means that ``gc1`` is a superclass of
     224``gc2``. This being said, not all edges are stored ! To ensure that a given
     225class is included in another one, we have to check whether there is in the
     226digraph a ``path`` from the first one to the other::
     227
     228    sage: bip_id = graph_classes.Bipartite._gc_id
     229    sage: perfect_id = graph_classes.Perfect._gc_id
     230    sage: d.has_edge(perfect_id, bip_id)
     231    False
     232    sage: d.distance(perfect_id, bip_id)
     233    2
     234
     235Hence bipartite graphs are perfect graphs. We can see how ISGCI obtains this
     236result ::
     237
     238    sage: d.shortest_path(perfect_id, bip_id)
     239    ['gc_56', 'gc_76', 'gc_69']
     240    sage: map(graph_classes.get_class, d.shortest_path(perfect_id, bip_id))
     241    [perfect graphs, unimodular graphs, bipartite graphs]
     242
     243What ISGCI knows is that perfect graphs contain unimodular graph which contain
     244bipartite graphs. And so bipartite graphs are perfect !
     245
     246.. note::
     247
     248    The inclusion digraph is **NOT ACYCLIC**. Indeed, several entries
     249    exist in the ISGCI database which represent the same graph class,
     250    for instance Perfect graphs and Berge graphs ::
     251
     252        sage: graph_classes.inclusion_digraph().is_directed_acyclic()
     253        False
     254        sage: Berge = graph_classes.get_class("gc_274"); Berge
     255        Berge graphs
     256        sage: Perfect = graph_classes.get_class("gc_56"); Perfect
     257        perfect graphs
     258        sage: Berge <= Perfect
     259        True
     260        sage: Perfect <= Berge
     261        True
     262        sage: Perfect == Berge
     263        True
    199264
    200265Information for developpers
    201266----------------------------
    202267
    203 * The database is not *so* large, but enough to prevent it from being loaded at
    204   Sage's startup. The internal methods using the database should often be
    205   preceded by a call to :meth:`_load_ISGCI_if_not_loaded
    206   <sage.graphs.isgci._load_ISGCI_if_not_loaded>` or to
    207   :meth:`_build_inclusion_digraph_if_not_built
    208   <sage.graphs.isgci._build_inclusion_digraph_if_not_built>`.
     268* The database is not *so* large, but enough to avoid loading it at Sage's
     269  startup. This is the reason why the methods :meth:`classes()
     270  <sage.graphs.isgci.GraphClasses.classes>` and :meth:`inclusion_digraph()
     271  <sage.graphs.isgci.GraphClasses.inclusion_digraph>` are cached.
    209272
    210273* Once the database has been accessed once, the information is extracted from
    211   the ``.sobj`` files in which it is stored and their information can be
    212   accessed by the following variables :
     274  the ``.sobj`` files in which it is stored and their information is stored in
     275  the following variables :
    213276
    214   * ``sage.graphs.isgci.classes`` (dictionary)
    215   * ``sage.graphs.isgci.inclusions`` (list of dictionaries)
    216   * ``sage.graphs.isgci.inclusion_digraph`` (DiGraph)
     277  * ``sage.graphs.isgci._classes`` (dictionary)
     278  * ``sage.graphs.isgci._inclusions`` (list of dictionaries)
     279  * ``sage.graphs.isgci._inclusion_digraph`` (DiGraph)
    217280
    218281  Note that the digraph is only built if necessary (for instance if the user
    219282  tried to compare two classes).
    220283
    221 * The ``DiGraph`` object ``sage.graphs.isgci.inclusion_digraph`` has for vertex set
    222   the ID of the graph classes. This digraph contains an edge `uv` if the graph
    223   class represented by `u` is larger (not necessarily strictly) than the one
    224   represented by `v`.
    225 
    226 
    227   TODO: this is useful information for the user too. Move it out of
    228   the developpers section?
    229 
    230   Though it represents inclusions of sets, this ``DiGraph`` is **NOT
    231   ACYCLIC**::
    232 
    233       sage: sage.graphs.isgci.inclusion_digraph.is_directed_acyclic()
    234       False
    235 
    236   Indeed, several entries exist in the ISGCI database which represent
    237   the same graph class::
    238 
    239     sage: Berge = graph_classes.get_class_from_id("gc_274"); Berge
    240     Graph class : Berge
    241     sage: Perfect = graph_classes.get_class_from_id("gc_56"); Perfect
    242     Graph class : perfect
    243     sage: Berge <= Perfect
    244     True
    245     sage: Perfect <= Berge
    246     True
    247 
    248   In other words::
    249 
    250     sage: Perfect == Berge
    251     True
    252 
    253284.. todo::
    254285
    255286    Technical things:
    256287
     288    * Query the database for non-inclusion results so that comparisons can
     289      return ``False``, and implement strict inclusions.
     290
    257291    * Implement a proper search method for the classes not listed in
    258292      :obj:`graph_classes <sage.graphs.isgci.GraphClasses>`
    259293
     
    262296    * Some of the graph classes appearing in :obj:`graph_classes
    263297      <sage.graphs.isgci.GraphClasses>` already have a recognition
    264298      algorithm implemented in Sage. It would be so nice to be able to
    265       write ``g in Trees``, ``g in Perfect``, ``g in Chordal``, ... `:-)`
     299      write ``g in Trees``, ``g in Perfect``, ``g in Chordal``, ... :-)
    266300
    267301    Long-term stuff:
    268302
     
    282316      that a given graph is, say, a tree or a planar graph, and use a
    283317      specialized algorithm for finding an independent set.
    284318
    285 
    286319AUTHORS:
    287320--------
    288321
     
    295328
    296329from sage.structure.sage_object import SageObject
    297330from sage.structure.unique_representation import UniqueRepresentation
    298 
    299 classes = {}
    300 inclusions = []
    301 inclusion_digraph = None
     331from sage.misc.unknown import Unknown
    302332
    303333#*****************************************************************************
    304334#      Copyright (C) 2011 Nathann Cohen <nathann.cohen@gmail.com>
     
    323353        sage: Trees <= Chordal
    324354        True
    325355        sage: Chordal <= Trees
    326         False
     356        Unknown
    327357
    328358    TEST::
    329359
    330360        sage: Trees >= Chordal
    331         False
     361        Unknown
    332362        sage: Chordal >= Trees
    333363        True
    334364    """
     
    343373        EXAMPLE::
    344374
    345375            sage: graph_classes.Chordal
    346             Graph class : Chordal
     376            Chordal graphs
    347377        """
    348378        return self._name+" graphs"
    349379
     
    358388
    359389    def __ge__(self, other):
    360390        inclusion_digraph = GraphClasses().inclusion_digraph()
    361         return (inclusion_digraph.shortest_path(self._gc_id,other._gc_id) != [])
     391        if inclusion_digraph.shortest_path(self._gc_id,other._gc_id) != []:
     392            return True
     393        else:
     394            return Unknown
    362395
    363396    def __eq__(self, other):
    364397        return self.__ge__(other) and other.__ge__(self)
     
    396429            3-Colourability                :  Linear
    397430            Recognition                    :  Linear
    398431        """
    399         global classes
    400         _load_ISGCI_if_not_loaded()
     432
     433        classes = GraphClasses().classes()
    401434
    402435        cls = classes[self._gc_id]
    403436        print "Class of graphs : "+self._name
     
    415448                print "{0:30} : ".format(key),
    416449                print value
    417450
    418 from sage.misc.cachefunc import cached_function
     451from sage.misc.cachefunc import cached_method
    419452
    420453class GraphClasses(UniqueRepresentation):
    421     def get_class_from_id(self, ID):
     454    def __init__(self):
     455        self._classes = {}
     456        self._inclusions = []
     457        self._inclusion_digraph = None
     458
     459    def get_class(self, id):
    422460        r"""
    423         Returns the class corresponding to the given ID in the ISGCI database.
     461        Returns the class corresponding to the given id in the ISGCI database.
     462
     463        INPUT:
     464
     465        - ``id`` (string) -- the desired class' ID
     466
     467        .. seealso:
     468
     469            :meth:`show_all <sage.graphs.isgci.GraphClasses.show_all>`
    424470
    425471        EXAMPLE:
    426472
    427         With an existing ID::
     473        With an existing id::
    428474
    429             sage: Cographs = graph_classes.get_class_from_id("gc_151")
     475            sage: Cographs = graph_classes.get_class("gc_151")
    430476            sage: Cographs
    431             Graph class : cograph
     477            cograph graphs
    432478
    433         With a wrong ID::
     479        With a wrong id::
    434480
    435             sage: graph_classes.get_class_from_id(-1)
     481            sage: graph_classes.get_class(-1)
    436482            Traceback (most recent call last):
    437483            ...
    438             ValueError: The given class ID does not exist in the ISGCI database. Is the db too old ? You can update it with sage.graphs.isgci.update_db().
    439 
    440 
    441         TODO: rename ot     ``graph_classes.get_class(id = "gc_151")``?
    442         or even ``graph_classes.Class(id = "gc_151")``?
     484            ValueError: The given class id does not exist in the ISGCI database. Is the db too old ? You can update it with graph_classes.update_db().
    443485        """
    444         global classes
    445         _load_ISGCI_if_not_loaded()
    446         if ID in classes:
    447             c = classes[ID]
     486        classes = self.classes()
     487        if id in classes:
     488            c = classes[id]
    448489
    449490            if "name" in c and c["name"] != "":
    450491                name = c["name"]
    451492            else:
    452                 name = "class "+str(ID)
     493                name = "class "+str(id)
    453494
    454             return GraphClass(name, ID)
     495            return GraphClass(name, id)
     496        else:
     497            raise ValueError("The given class id does not exist in the ISGCI database. Is the db too old ? You can update it with graph_classes.update_db().")
    455498
    456         else:
    457             raise ValueError("The given class ID does not exist in the ISGCI database. Is the db too old ? You can update it with sage.graphs.isgci.update_db().")
     499    @cached_method
     500    def classes(self):
     501        r"""
     502        Returns the graph classes as a dictionary.
    458503
    459     @cached_function
    460     def classes():
    461         global classes
    462         _load_ISGCI_if_not_loaded()
    463         return classes
     504        If the database it has not been built from the local sobj files, this
     505        methods load it.
     506        """
     507        if self._classes == {}:
     508            self._classes, self._inclusions = self._get_ISGCI()
    464509
    465     @cached_function
    466     def inclusion_digraph():
    467         global inclusion_digraph, classes
    468         _build_inclusion_digraph_if_not_built()
    469         return inclusion_digraph
     510        return self._classes
    470511
    471     def _download_db():
     512    @cached_method
     513    def inclusion_digraph(self):
     514        r"""
     515        Returns the class inclusion digraph
     516
     517        If the database it has not been built from the local sobj files, this
     518        methods load it.
     519        """
     520        if not (self._inclusion_digraph is None):
     521            return
     522
     523        classes = self.classes()
     524
     525        from sage.graphs.digraph import DiGraph
     526        self._inclusion_digraph = DiGraph()
     527        self._inclusion_digraph.add_vertices(classes.keys())
     528
     529        for edge in self._inclusions:
     530            if edge.get("confidence","") == "unpublished":
     531                continue
     532
     533            self._inclusion_digraph.add_edge(edge['super'], edge['sub'])
     534
     535        self._inclusions = []
     536
     537        return self._inclusion_digraph
     538
     539    def _download_db(self):
    472540        r"""
    473541        Downloads the current version of the ISGCI db
    474542
    475543        EXAMPLE::
    476544
    477             sage: sage.graphs.isgci._download_db() # Not tested -- requires internet
     545            sage: graph_classes._download_db() # Not tested -- requires internet
    478546        """
    479547
    480548        from sage.misc.misc import SAGE_TMP
     
    487555        z = zipfile.ZipFile(SAGE_TMP+'isgci.zip')
    488556        z.extract(_XML_FILE, SAGE_TMP)
    489557
    490     def _create_db():
     558    def _create_db(self):
    491559        r"""
    492560        Parses the ISGCI database and returns its content as Python objects.
    493561
    494562        EXAMPLE::
    495563
    496             sage: sage.graphs.isgci._create_db() # Not tested -- requires internet
     564            sage: graph_classes._create_db() # Not tested -- requires internet
    497565        """
    498566        from sage.misc.misc import SAGE_TMP
    499567        import xml.dom.minidom
     
    553621
    554622        return classes, inclusions
    555623
    556     def update_db(verbose = False):
     624    def update_db(self):
    557625        r"""
    558626        Updates the ISGCI database by downloading the latest version from internet.
    559627
     
    568636        command is run, one attempt is made at saving the result in Sage's
    569637        directory so that all users can benefit from it. If the
    570638        credentials are not sufficient, the ``.sobj`` files are saved
    571         instead in the user's directory. #TODO: be more specific about where in the user's directory?
    572 
    573         INPUT:
    574 
    575         - ``verbose`` -- a boolean (default: False); whether to output
    576           information of the update process
     639        instead in the user's directory (in the SAGE_DB folder).
    577640
    578641        EXAMPLE::
    579642
    580             sage: sage.graphs.isgci.update_db() # Not tested -- requires internet
     643            sage: graph_classes.update_db() # Not tested -- requires internet
    581644        """
    582645        from sage.misc.misc import SAGE_TMP, SAGE_ROOT, SAGE_LOCAL, SAGE_DB
    583         global classes, inclusions, inclusion_digraph
    584646
    585         try:
    586             _download_db()
    587         except:
    588             # TODO: as such, the user won't get the, probably more
    589             # informative, error message thrown by download_db. What about
    590             # not catching it? Or at least retransmitting the error
    591             # message?
    592             raise Exception("There has been a problem while downloading or unzipping the ISGCI database O_o")
     647        self._download_db()
    593648
     649        print "Database downloaded"
    594650
    595         if verbose:
    596             print "Database downloaded"
     651        self._classes, self._inclusions = self._create_db()
    597652
    598         classes, inclusions = _create_db()
    599 
    600         if verbose:
    601             print "XML file converted to Python dictionaries"
    602 
     653        print "XML file converted into Python dictionaries"
    603654
    604655        from sage.all import save
    605656
    606657        # Trying to save to Sage's directory
    607658        try:
    608             save(classes, SAGE_ROOT+'/data/graphs/isgci_classes.sobj')
    609             save(inclusions, SAGE_ROOT+'/data/graphs/isgci_inclusions.sobj')
    610             inclusions = inclusion_digraph = None
    611             classes = {}
    612             if verbose:
    613                 print "Database saved to .sobj files in "+SAGE_ROOT+'/data/graphs/'
     659            save(self._classes, SAGE_ROOT+'/data/graphs/isgci_classes.sobj')
     660            save(self._inclusions, SAGE_ROOT+'/data/graphs/isgci_inclusions.sobj')
     661            self._inclusions = self._inclusion_digraph = None
     662            self._classes = {}
     663            print "Database saved to .sobj files in "+SAGE_ROOT+'/data/graphs/'
     664            return
    614665
    615             return
    616666        except IOError:
    617             if verbose:
    618                 # TODO: improve!
    619                 print "Could not save save database in "+SAGE_ROOT+'/data/graphs/'
     667            # TODO: improve!
     668            print "Could not save save database in "+SAGE_ROOT+'/data/graphs/'
     669            print "Now attempting to save the files to "+str(SAGE_DB)
    620670            pass
    621671
    622672        # Trying to save to the user's home directory
    623         try:
    624             save(classes, SAGE_DB+"/isgci_classes.sobj")
    625             save(inclusions, SAGE_DB+"/isgci_inclusions.sobj")
    626             classes = inclusions = inclusion_digraph = None
    627             if verbose:
    628                 print "Database saved to .sobj files in "+SAGE_DB
     673        save(self._classes, SAGE_DB+"/isgci_classes.sobj")
     674        save(self._inclusions, SAGE_DB+"/isgci_inclusions.sobj")
     675        self._inclusions = self._inclusion_digraph = None
     676        self._classes = {}
     677        print "Database saved to .sobj files in "+SAGE_DB
    629678
    630             return
    631 
    632         except IOError:
    633             pass
    634 
    635         # TODO: as above: don't hide the more informative error message
    636         # from the system
    637 
    638         # Gloops !
    639         raise Exception("Sage is unable to write the files to your"+
    640                         "computer ! This shouldn't have happened. "+
    641                         "Could you report the bug ? ;-)")
    642 
    643     def get_ISGCI():
     679    def _get_ISGCI(self):
    644680        r"""
    645681        Returns the contents of the ISGCI database.
    646682
     
    659695
    660696        EXAMPLE::
    661697
    662             sage: classes, inclusions = sage.graphs.isgci.get_ISGCI()
     698            sage: classes, inclusions = graph_classes._get_ISGCI()
    663699        """
    664700
    665701        import os.path
     
    690726
    691727        return classes, inclusions
    692728
    693     def show_all():
     729    def show_all(self):
    694730        r"""
    695731        Prints all graph classes stored in ISGCI
    696732
    697733        EXAMPLE::
    698734
    699             sage: sage.graphs.isgci.show_all()
     735            sage: graph_classes.show_all()
    700736            ID        | name                                     | type                 | smallgraph
    701737            ----------------------------------------------------------------------------------------------------------------------
    702738            gc_309    | $K_4$--minor--free                       | base                 |
     
    708744            gc_7      | $P_4$--extendible                        | base                 |
    709745            ...
    710746        """
    711         global classes
    712         _load_ISGCI_if_not_loaded()
     747        classes = self.classes()
    713748        classes_list = classes.values()
    714749
    715750        # We want to print the different fields, and this dictionary stores the
     
    748783            smallgraph = entry.get("smallgraph","")
    749784            print ("{0:"+str(MAX["ID"])+"} | {1:"+str(MAX["name"])+"} | {2:"+str(MAX["type"])+"} | ").format(ID, name[:MAX_LEN], type[:MAX_LEN])+str(smallgraph)[:MAX_LEN]
    750785
    751     def _load_ISGCI_if_not_loaded():
    752         r"""
    753         Load ISGI if not loaded already
    754 
    755         This is here to avoid having to load the db when Sage starts
    756         """
    757         global classes, inclusions
    758         if classes == {}:
    759             classes, inclusions = get_ISGCI()
    760 
    761     def _build_inclusion_digraph_if_not_built():
    762         r"""
    763         Builds the class digraph
    764         """
    765         global classes, inclusions, inclusion_digraph
    766 
    767         if not (inclusion_digraph is None):
    768             return
    769 
    770         _load_ISGCI_if_not_loaded()
    771 
    772         from sage.graphs.digraph import DiGraph
    773         inclusion_digraph = DiGraph()
    774         inclusion_digraph.add_vertices(classes.keys())
    775 
    776         for edge in inclusions:
    777             if edge.get("confidence","") == "unpublished":
    778                 continue
    779 
    780             inclusion_digraph.add_edge(edge['super'], edge['sub'])
    781 
    782         inclusions = []
    783 
    784 
    785786graph_classes = GraphClasses()
    786787
    787788# Any object added to this list should also appear in the class' documentation, at the top of the file.
     
    789790graph_classes.Bipartite = GraphClass("Bipartite", "gc_69")
    790791graph_classes.Block = GraphClass("Block", "gc_93")
    791792graph_classes.Chordal = GraphClass("Chordal", "gc_32")
    792 graph_classes.Clique = GraphClass("Clique", "gc_141")
    793793graph_classes.Comparability = GraphClass("Comparability", "gc_72")
    794794graph_classes.Gallai = GraphClass("Gallai", "gc_73")
    795795graph_classes.Grid = GraphClass("Grid", "gc_464")