Ticket #13188: trac_13188.patch

File trac_13188.patch, 27.7 KB (added by ncohen, 8 years ago)
  • sage/graphs/chrompoly.pyx

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1341072239 -7200
    # Node ID f58cebb10eeeb8e1fcaed9f36f953f475c338f95
    # Parent  4bf4480e8fd30e0cede481f174fa8630cf558133
    Deletion of duplicates in the graph/ files, and update of some deprecation warnings
    
    diff --git a/sage/graphs/chrompoly.pyx b/sage/graphs/chrompoly.pyx
    a b  
    2727def chromatic_polynomial(G, return_tree_basis = False):
    2828    """
    2929    Computes the chromatic polynomial of the graph G.
    30    
     30
    3131    The algorithm used is a recursive one, based on the following observations
    3232    of Read:
     33
    3334        - The chromatic polynomial of a tree on n vertices is x(x-1)^(n-1).
     35
    3436        - If e is an edge of G, G' is the result of deleting the edge e, and G''
    35         is the result of contracting e, then the chromatic polynomial of G is
    36         equal to that of G' minus that of G''.
    37    
    38     EXAMPLES:
     37          is the result of contracting e, then the chromatic polynomial of G is
     38          equal to that of G' minus that of G''.
     39
     40    EXAMPLES::
     41
    3942        sage: graphs.CycleGraph(4).chromatic_polynomial()
    4043        x^4 - 4*x^3 + 6*x^2 - 3*x
    4144        sage: graphs.CycleGraph(3).chromatic_polynomial()
  • sage/graphs/cliquer.pyx

    diff --git a/sage/graphs/cliquer.pyx b/sage/graphs/cliquer.pyx
    a b  
    1111
    1212- Jeroen Demeyer (2011-05-06): Make cliquer interruptible (#11252)
    1313
     14REFERENCE:
     15
     16.. [NisOst2003] Sampo Niskanen and Patric R. J. Ostergard,
     17  "Cliquer User's  Guide, Version 1.0,"
     18  Communications Laboratory, Helsinki University of Technology,
     19  Espoo, Finland, Tech. Rep. T48, 2003.
     20
    1421Methods
    1522-------
    1623"""
    1724
     25
    1826#*****************************************************************************
    1927#       Copyright (C) 2009 Nathann Cohen <nathann.cohen@gmail.com>
    2028#
     
    8290def all_max_clique(graph):
    8391    """
    8492    Returns the vertex sets of *ALL* the maximum complete subgraphs.
    85    
    86     Currently only implemented for undirected graphs. Use
    87     to_undirected to convert a digraph to an undirected graph.
    88    
     93
     94    Returns the list of all maximum cliques, with each clique represented by a
     95    list of vertices. A clique is an induced complete subgraph, and a maximum
     96    clique is one of maximal order.
     97
     98    .. NOTE::
     99
     100       Currently only implemented for undirected graphs. Use to_undirected
     101       to convert a digraph to an undirected graph.
     102
     103    ALGORITHM:
     104
     105    This function is based on Cliquer [NisOst2003]_.
     106
    89107    EXAMPLES::
    90    
    91           sage: C=graphs.PetersenGraph()
    92           sage: all_max_clique(C)
    93           [[2, 7], [7, 9], [6, 8], [6, 9], [0, 4], [4, 9], [5, 7], [0, 5], [5, 8], [3, 4], [2, 3], [3, 8], [1, 6], [0, 1], [1, 2]]
     108
     109        sage: graphs.ChvatalGraph().cliques_maximum()
     110        [[0, 1], [0, 4], [0, 6], [0, 9], [1, 2], [1, 5], [1, 7], [2, 3],
     111         [2, 6], [2, 8], [3, 4], [3, 7], [3, 9], [4, 5], [4, 8], [5, 10],
     112         [5, 11], [6, 10], [6, 11], [7, 8], [7, 11], [8, 10], [9, 10], [9, 11]]
     113        sage: G = Graph({0:[1,2,3], 1:[2], 3:[0,1]})
     114        sage: G.show(figsize=[2,2])
     115        sage: G.cliques_maximum()
     116        [[0, 1, 2], [0, 1, 3]]
     117        sage: C=graphs.PetersenGraph()
     118        sage: C.cliques_maximum()
     119        [[0, 1], [0, 4], [0, 5], [1, 2], [1, 6], [2, 3], [2, 7], [3, 4],
     120         [3, 8], [4, 9], [5, 7], [5, 8], [6, 8], [6, 9], [7, 9]]
     121        sage: C = Graph('DJ{')
     122        sage: C.cliques_maximum()
     123        [[1, 2, 3, 4]]
    94124    """
    95125
    96126    graph,d = graph.relabel(inplace=False, return_map=True)
     
    122152        else:
    123153            b.append(list_composition(c,d_inv))
    124154            c=[]
    125     return b
     155    return sorted(b)
    126156
    127157
    128 #computes the clique number of a graph 
     158#computes the clique number of a graph
    129159
    130160def clique_number(graph):
    131161    """
    132162    Returns the size of the largest clique of the graph (clique
    133     number). 
     163    number).
    134164   
    135165    Currently only implemented for undirected graphs. Use
    136166    to_undirected to convert a digraph to an undirected graph.
  • sage/graphs/digraph.py

    diff --git a/sage/graphs/digraph.py b/sage/graphs/digraph.py
    a b  
    974974        """
    975975        return self._backend.is_directed_acyclic(certificate = certificate)
    976976
    977     def is_transitive(self, certificate = False):
    978         r"""
    979         Tests whether the given digraph is transitive.
    980 
    981         A digraph is transitive if for any pair of vertices `u,v\in G` linked by a
    982         `uv`-path the edge `uv` belongs to `G`.
    983 
    984         INPUT:
    985 
    986         - ``certificate`` -- whether to return a certificate for negative answers.
    987 
    988           - If ``certificate = False`` (default), this method returns ``True`` or
    989             ``False`` according to the graph.
    990 
    991           - If ``certificate = True``, this method either returns ``True`` answers
    992             or yield a pair of vertices `uv` such that there exists a `uv`-path in
    993             `G` but `uv\not\in G`.
    994 
    995         EXAMPLE::
    996 
    997             sage: digraphs.Circuit(4).is_transitive()
    998             False
    999             sage: digraphs.Circuit(4).is_transitive(certificate = True)
    1000             (0, 2)
    1001             sage: digraphs.RandomDirectedGNP(30,.2).is_transitive()
    1002             False
    1003             sage: digraphs.DeBruijn(5,2).is_transitive()
    1004             False
    1005             sage: digraphs.DeBruijn(5,2).is_transitive(certificate = True)
    1006             ('00', '10')
    1007             sage: digraphs.RandomDirectedGNP(20,.2).transitive_closure().is_transitive()
    1008             True
    1009         """
    1010         from sage.graphs.comparability import is_transitive
    1011         return is_transitive(self, certificate = certificate)
    1012 
    1013977    def to_directed(self):
    1014978        """
    1015979        Since the graph is already directed, simply returns a copy of
     
    12361200    def in_degree_iterator(self, vertices=None, labels=False):
    12371201        """
    12381202        Same as degree_iterator, but for in degree.
    1239        
     1203
    12401204        EXAMPLES::
    1241        
     1205
    12421206            sage: D = graphs.Grid2dGraph(2,4).to_directed()
    12431207            sage: for i in D.in_degree_iterator():
    12441208            ...    print i
     
    26862650
    26872651        else:
    26882652            raise ValueError("implementation must be set to one of \"default\" or \"NetworkX\"")
    2689    
     2653
    26902654    def topological_sort_generator(self):
    26912655        """
    26922656        Returns a list of all topological sorts of the digraph if it is
    26932657        acyclic, and raises a TypeError if the digraph contains a directed
    26942658        cycle.
    2695        
     2659
    26962660        A topological sort is an ordering of the vertices of the digraph
    26972661        such that each vertex comes before all of its successors. That is,
    26982662        if u comes before v in the sort, then there may be a directed path
    26992663        from u to v, but there will be no directed path from v to u. See
    27002664        also Graph.topological_sort().
    2701        
     2665
    27022666        AUTHORS:
    27032667
    27042668        - Mike Hansen - original implementation
    27052669
    27062670        - Robert L. Miller: wrapping, documentation
    2707        
     2671
    27082672        REFERENCE:
    27092673
    27102674        - [1] Pruesse, Gara and Ruskey, Frank. Generating Linear
    27112675          Extensions Fast. SIAM J. Comput., Vol. 23 (1994), no. 2, pp.
    27122676          373-386.
    2713        
     2677
    27142678        EXAMPLES::
    2715        
     2679
    27162680            sage: D = DiGraph({ 0:[1,2], 1:[3], 2:[3,4] })
    27172681            sage: D.plot(layout='circular').show()
    27182682            sage: D.topological_sort_generator()
    27192683            [[0, 1, 2, 3, 4], [0, 1, 2, 4, 3], [0, 2, 1, 3, 4], [0, 2, 1, 4, 3], [0, 2, 4, 1, 3]]
    2720        
     2684
    27212685        ::
    2722        
     2686
    27232687            sage: for sort in D.topological_sort_generator():
    27242688            ...       for edge in D.edge_iterator():
    27252689            ...           u,v,l = edge
     
    30653029        except AttributeError:
    30663030            return len(self.strongly_connected_components()) == 1
    30673031
    3068 
    3069 
     3032import types
     3033
     3034import sage.graphs.comparability
     3035DiGraph.is_transitive = types.MethodType(sage.graphs.comparability.is_transitive, None, DiGraph)
  • sage/graphs/distances_all_pairs.pyx

    diff --git a/sage/graphs/distances_all_pairs.pyx b/sage/graphs/distances_all_pairs.pyx
    a b  
    104104
    105105- Nathann Cohen (2011)
    106106
     107REFERENCE:
     108
     109.. [KRG96b] S. Klavzar, A. Rajapakse, and I. Gutman. The Szeged and the
     110  Wiener index of graphs. *Applied Mathematics Letters*, 9(5):45--49, 1996.
     111
     112.. [GYLL93c] I. Gutman, Y.-N. Yeh, S.-L. Lee, and Y.-L. Luo. Some recent
     113  results in the theory of the Wiener number. *Indian Journal of
     114  Chemistry*, 32A:651--661, 1993.
    107115
    108116Functions
    109117---------
     
    631639        sage: w=lambda x: (x*(x*x -1)/6)
    632640        sage: g.wiener_index()==w(10)
    633641        True
    634 
    635     REFERENCE:
    636 
    637     .. [KRG96b] S. Klavzar, A. Rajapakse, and I. Gutman. The Szeged and the
    638       Wiener index of graphs. *Applied Mathematics Letters*, 9(5):45--49, 1996.
    639 
    640     .. [GYLL93c] I. Gutman, Y.-N. Yeh, S.-L. Lee, and Y.-L. Luo. Some recent
    641       results in the theory of the Wiener number. *Indian Journal of
    642       Chemistry*, 32A:651--661, 1993.
    643642    """
    644643    if not G.is_connected():
    645644        from sage.rings.infinity import Infinity
  • sage/graphs/generic_graph.py

    diff --git a/sage/graphs/generic_graph.py b/sage/graphs/generic_graph.py
    a b  
    32783278            sage: g.set_planar_positions(test=True)
    32793279            True
    32803280
    3281         This method is deprecated. Please use instead:
     3281        This method is deprecated since Sage-4.4.1.alpha2. Please use instead:
    32823282
    32833283            sage: g.layout(layout = "planar", save_pos = True)
    32843284            {0: [1, 1], 1: [2, 2], 2: [3, 2], 3: [1, 4], 4: [5, 1], 5: [0, 5], 6: [1, 0]}
     
    1149511495            raise ValueError("The algorithm keyword can be equal to either \"BFS\" or \"Floyd-Warshall\" or \"auto\"")
    1149611496
    1149711497
    11498     def distances_distribution(self):
    11499         r"""
    11500         Returns the distances distribution of the (di)graph in a dictionary.
    11501 
    11502         This method *ignores all edge labels*, so that the distance considered
    11503         is the topological distance.
    11504 
    11505         OUTPUT:
    11506 
    11507             A dictionary ``d`` such that the number of pairs of vertices at
    11508             distance ``k`` (if any) is equal to `d[k] \cdot |V(G)| \cdot
    11509             (|V(G)|-1)`.
    11510 
    11511         .. NOTE::
    11512 
    11513             We consider that two vertices that do not belong to the same
    11514             connected component are at infinite distance, and we do not take the
    11515             trivial pairs of vertices `(v, v)` at distance `0` into account.
    11516             Empty (di)graphs and (di)graphs of order 1 have no paths and so we
    11517             return the empty dictionary ``{}``.
    11518 
    11519         EXAMPLES:
    11520 
    11521         An empty Graph::
    11522 
    11523             sage: g = Graph()
    11524             sage: g.distances_distribution()
    11525             {}
    11526 
    11527         A Graph of order 1::
    11528 
    11529             sage: g = Graph()
    11530             sage: g.add_vertex(1)
    11531             sage: g.distances_distribution()
    11532             {}
    11533 
    11534         A Graph of order 2 without edge::
    11535 
    11536             sage: g = Graph()
    11537             sage: g.add_vertices([1,2])
    11538             sage: g.distances_distribution()
    11539             {+Infinity: 1}
    11540 
    11541         The Petersen Graph::
    11542 
    11543             sage: g = graphs.PetersenGraph()
    11544             sage: g.distances_distribution()
    11545             {1: 1/3, 2: 2/3}
    11546 
    11547         A graph with multiple disconnected components::
    11548 
    11549             sage: g = graphs.PetersenGraph()
    11550             sage: g.add_edge('good','wine')
    11551             sage: g.distances_distribution()
    11552             {1: 8/33, 2: 5/11, +Infinity: 10/33}
    11553 
    11554         The de Bruijn digraph dB(2,3)::
    11555 
    11556             sage: D = digraphs.DeBruijn(2,3)
    11557             sage: D.distances_distribution()
    11558             {1: 1/4, 2: 11/28, 3: 5/14}
    11559         """
    11560         from sage.graphs.distances_all_pairs import distances_distribution
    11561         return distances_distribution(self)
    11562 
    11563 
    1156411498    def eccentricity(self, v=None, dist_dict=None, with_labels=False):
    1156511499        """
    1156611500        Return the eccentricity of vertex (or vertices) v.
     
    1263212566
    1263312567        return dist, pred
    1263412568
    12635     def wiener_index(self):
    12636         r"""
    12637         Returns the Wiener index of the graph. 
    12638        
    12639         The Wiener index of a graph `G` can be defined in two equivalent 
    12640         ways [KRG96]_ : 
    12641    
    12642         - `W(G) = \frac 1 2 \sum_{u,v\in G} d(u,v)` where `d(u,v)` denotes the
    12643           distance between vertices `u` and `v`. 
    12644  
    12645         - Let `\Omega` be a set of `\frac {n(n-1)} 2` paths in `G` such that
    12646           `\Omega` contains exactly one shortest `u-v` path for each set
    12647           `\{u,v\}` of vertices in `G`. Besides, `\forall e\in E(G)`, let
    12648           `\Omega(e)` denote the paths from `\Omega` containing `e`. We then
    12649           have `W(G) = \sum_{e\in E(G)}|\Omega(e)|`.
    12650          
    12651         EXAMPLE: 
    12652          
    12653         From [GYLL93b]_, cited in [KRG96]_:: 
    12654  
    12655             sage: g=graphs.PathGraph(10) 
    12656             sage: w=lambda x: (x*(x*x -1)/6) 
    12657             sage: g.wiener_index()==w(10) 
    12658             True 
    12659  
    12660         REFERENCES: 
    12661 
    12662         .. [KRG96] S. Klavzar, A. Rajapakse, and I. Gutman. The Szeged and the 
    12663           Wiener index of graphs. *Applied Mathematics Letters*, 9(5):45--49,
    12664           1996.
    12665    
    12666         .. [GYLL93b] I. Gutman, Y.-N. Yeh, S.-L. Lee, and Y.-L. Luo. Some recent 
    12667           results in the theory of the Wiener number. *Indian Journal of
    12668           Chemistry*, 32A:651--661, 1993. 
    12669         """
    12670         from sage.graphs.distances_all_pairs import wiener_index
    12671         return wiener_index(self)
    12672        
    12673 
    1267412569    def average_distance(self):
    1267512570        r"""
    1267612571        Returns the average distance between vertices of the graph.
     
    1706416959        else:
    1706516960            return H
    1706616961
     16962import types
     16963
     16964import sage.graphs.distances_all_pairs
     16965GenericGraph.distances_distribution = types.MethodType(sage.graphs.distances_all_pairs.distances_distribution, None, GenericGraph)
     16966GenericGraph.wiener_index = types.MethodType(sage.graphs.distances_all_pairs.wiener_index, None, GenericGraph)
     16967
    1706716968def tachyon_vertex_plot(g, bgcolor=(1,1,1),
    1706816969                        vertex_colors=None,
    1706916970                        vertex_size=0.06,
  • sage/graphs/graph.py

    diff --git a/sage/graphs/graph.py b/sage/graphs/graph.py
    a b  
    3333    :meth:`~Graph.centrality_betweenness` | Returns the betweenness centrality
    3434
    3535
    36 
    3736**Graph properties:**
    3837
    3938.. csv-table::
     
    5453    :meth:`~Graph.is_weakly_chordal` | Tests whether ``self`` is weakly chordal.
    5554    :meth:`~Graph.is_strongly_regular` | Tests whether ``self`` is strongly regular.
    5655
     56
    5757**Connectivity and orientations:**
    5858
    5959.. csv-table::
     
    6767    :meth:`~Graph.degree_constrained_subgraph` | Returns a degree-constrained subgraph.
    6868
    6969
    70 
    7170**Clique-related methods:**
    7271
    7372.. csv-table::
     
    451450    sage: for g in Q:
    452451    ...     show(g)
    453452
    454 
    455 
    456 
    457453Visualization
    458454-------------
    459455
     
    494490#*****************************************************************************
    495491
    496492from sage.rings.integer import Integer
    497 
     493from sage.misc.superseded import deprecated_function_alias
    498494import sage.graphs.generic_graph_pyx as generic_graph_pyx
    499495from sage.graphs.generic_graph import GenericGraph
    500496from sage.graphs.digraph import DiGraph
     
    520516    This graph is not very interesting as it is by default the empty graph.
    521517    But Sage contains a large collection of pre-defined graph classes that
    522518    can be listed this way:
    523    
     519
    524520    * Within a Sage session, type ``graphs.``
    525521      (Do not press "Enter", and do not forget the final period ".")
     522
    526523    * Hit "tab".
    527    
     524
    528525    You will see a list of methods which will construct named graphs. For
    529526    example::
    530527
     
    543540    by using the almost 200 functions on graphs in the Sage library!
    544541    If your graph is named ``g``, you can list these functions as previously
    545542    this way
    546    
     543
    547544    * Within a Sage session, type ``g.``
    548545      (Do not press "Enter", and do not forget the final period "." )
     546
    549547    * Hit "tab".
    550548
    551549    As usual, you can get some information about what these functions do by
     
    555553    If you have defined a graph ``g`` having several connected components
    556554    (i.e. ``g.is_connected()`` returns False), you can print each one of its
    557555    connected components with only two lines::
    558    
     556
    559557        sage: for component in g.connected_components():
    560558        ...      g.subgraph(component).plot()
    561    
     559
    562560
    563561    INPUT:
    564    
     562
    565563    -  ``data`` -- can be any of the following (see the ``format`` argument):
    566564
    567565      #.  An integer specifying the number of vertices
     
    26542652
    26552653        return left, right
    26562654
    2657     def chromatic_polynomial(self):
    2658         """
    2659         Returns the chromatic polynomial of the graph G.
    2660        
    2661         EXAMPLES::
    2662        
    2663             sage: G = Graph({0:[1,2,3],1:[2]})
    2664             sage: factor(G.chromatic_polynomial())
    2665             (x - 2) * x * (x - 1)^2
    2666        
    2667         ::
    2668        
    2669             sage: g = graphs.trees(5).next()
    2670             sage: g.chromatic_polynomial().factor()
    2671             x * (x - 1)^4
    2672        
    2673         ::
    2674        
    2675             sage: seven_acre_wood = sum(graphs.trees(7), Graph())
    2676             sage: seven_acre_wood.chromatic_polynomial()
    2677             x^77 - 66*x^76 ... - 2515943049305400*x^60 ... - 66*x^12 + x^11
    2678        
    2679         ::
    2680        
    2681             sage: for i in range(2,7):
    2682             ...     graphs.CompleteGraph(i).chromatic_polynomial().factor()
    2683             (x - 1) * x
    2684             (x - 2) * (x - 1) * x
    2685             (x - 3) * (x - 2) * (x - 1) * x
    2686             (x - 4) * (x - 3) * (x - 2) * (x - 1) * x
    2687             (x - 5) * (x - 4) * (x - 3) * (x - 2) * (x - 1) * x
    2688         """
    2689         from sage.graphs.chrompoly import chromatic_polynomial
    2690         return chromatic_polynomial(self)
    2691 
    26922655    def chromatic_number(self, algorithm="DLX", verbose = 0):
    26932656        r"""
    26942657        Returns the minimal number of colors needed to color the vertices
     
    32263189
    32273190        return rs_dict
    32283191
    3229 
    3230     def rank_decomposition(self, verbose = False):
    3231         """
    3232         Returns an rank-decomposition of ``self`` achieving optiml rank-width.
    3233 
    3234         See the documentation of the ``rankwidth`` module
    3235         :mod:`rankwidth <sage.graphs.graph_decompositions.rankwidth>`.
    3236 
    3237         INPUT:
    3238 
    3239         - ``verbose`` (boolean) -- whether to display progress information while
    3240            computing the decomposition.
    3241 
    3242         OUTPUT:
    3243 
    3244         A pair ``(rankwidth, decomposition_tree)``, where ``rankwidth`` is a
    3245         numerical value and ``decomposition_tree`` is a ternary tree describing
    3246         the decomposition (cf. the module's documentation).
    3247 
    3248         See the documentation of the ``rankwidth`` module for more information
    3249         on the tree
    3250         :mod:`rankwidth <sage.graphs.graph_decompositions.rankwidth>`.
    3251 
    3252         .. WARNING::
    3253 
    3254             The current implementation cannot handle graphs of more than 32 vertices.
    3255 
    3256         EXAMPLE::
    3257 
    3258             sage: g = graphs.PetersenGraph()
    3259             sage: rw, tree = g.rank_decomposition()
    3260             sage: rw
    3261             3
    3262             sage: tree
    3263             Graph on 19 vertices
    3264             sage: tree.is_tree()
    3265             True
    3266         """
    3267 
    3268         from sage.graphs.graph_decompositions.rankwidth import rank_decomposition
    3269         return rank_decomposition(self, verbose = verbose)
    3270 
    3271     ### Matching
    3272 
    3273     def matching_polynomial(self, complement=True, name=None):
    3274         """
    3275         Computes the matching polynomial of the graph `G`.
    3276 
    3277         If `p(G, k)` denotes the number of `k`-matchings (matchings with `k`
    3278         edges) in `G`, then the matching polynomial is defined as [Godsil93]_:
    3279 
    3280         .. MATH::
    3281 
    3282             \mu(x)=\sum_{k \geq 0} (-1)^k p(G,k) x^{n-2k}
    3283            
    3284        
    3285         INPUT:
    3286        
    3287         - ``complement`` - (default: ``True``) whether to use Godsil's duality
    3288           theorem to compute the matching polynomial from that of the graphs
    3289           complement (see ALGORITHM).
    3290        
    3291         - ``name`` - optional string for the variable name in the polynomial
    3292 
    3293         .. NOTE::
    3294        
    3295             The ``complement`` option uses matching polynomials of complete
    3296             graphs, which are cached. So if you are crazy enough to try
    3297             computing the matching polynomial on a graph with millions of
    3298             vertices, you might not want to use this option, since it will end
    3299             up caching millions of polynomials of degree in the millions.
    3300 
    3301         ALGORITHM:
    3302 
    3303         The algorithm used is a recursive one, based on the following
    3304         observation [Godsil93]_:
    3305        
    3306         - If `e` is an edge of `G`, `G'` is the result of deleting the edge `e`,
    3307           and `G''` is the result of deleting each vertex in `e`, then the
    3308           matching polynomial of `G` is equal to that of `G'` minus that of
    3309           `G''`.
    3310 
    3311           (the algorithm actually computes the *signless* matching polynomial,
    3312           for which the recursion is the same when one replaces the substraction
    3313           by an addition. It is then converted into the matching polynomial and
    3314           returned)
    3315 
    3316         Depending on the value of ``complement``, Godsil's duality theorem
    3317         [Godsil93]_ can also be used to compute `\mu(x)` :
    3318 
    3319         .. MATH::
    3320 
    3321             \mu(\overline{G}, x) = \sum_{k \geq 0} p(G,k) \mu( K_{n-2k}, x)
    3322            
    3323 
    3324         Where `\overline{G}` is the complement of `G`, and `K_n` the complete
    3325         graph on `n` vertices.
    3326 
    3327         EXAMPLES::
    3328        
    3329             sage: g = graphs.PetersenGraph()
    3330             sage: g.matching_polynomial()
    3331             x^10 - 15*x^8 + 75*x^6 - 145*x^4 + 90*x^2 - 6
    3332             sage: g.matching_polynomial(complement=False)
    3333             x^10 - 15*x^8 + 75*x^6 - 145*x^4 + 90*x^2 - 6
    3334             sage: g.matching_polynomial(name='tom')
    3335             tom^10 - 15*tom^8 + 75*tom^6 - 145*tom^4 + 90*tom^2 - 6
    3336             sage: g = Graph()
    3337             sage: L = [graphs.RandomGNP(8, .3) for i in [1..5]]
    3338             sage: prod([h.matching_polynomial() for h in L]) == sum(L, g).matching_polynomial()  # long time (7s on sage.math, 2011)
    3339             True
    3340         """
    3341         from matchpoly import matching_polynomial
    3342         return matching_polynomial(self, complement=complement, name=name)
    3343 
    33443192    ### Convexity
    33453193
    33463194    def convexity_properties(self):
     
    35633411        """
    35643412        Since the graph is already undirected, simply returns a copy of
    35653413        itself.
    3566        
     3414
    35673415        EXAMPLES::
    3568        
     3416
    35693417            sage: graphs.PetersenGraph().to_undirected()
    35703418            Petersen graph: Graph on 10 vertices
    35713419        """
     
    36603508
    36613509        .. NOTE::
    36623510
    3663             * This function can be expected to be *very* slow, especially
    3664               where the topological minor does not exist.
    3665 
    3666             (CPLEX seems to be *much* more efficient than GLPK on this
    3667             kind of problem)
     3511            This function can be expected to be *very* slow, especially where
     3512            the topological minor does not exist.
     3513
     3514            (CPLEX seems to be *much* more efficient than GLPK on this kind of
     3515            problem)
    36683516
    36693517        EXAMPLES:
    36703518
     
    38843732        import networkx
    38853733        return sorted(networkx.find_cliques(self.networkx_graph(copy=False)))
    38863734
    3887     def cliques(self):
    3888         """
    3889         (Deprecated) alias for ``cliques_maximal``. See that function for more
    3890         details.
    3891        
    3892         EXAMPLE::
    3893        
    3894             sage: C = Graph('DJ{')
    3895             sage: C.cliques()
    3896             doctest:...: DeprecationWarning: The function 'cliques' has been deprecated. Use 'cliques_maximal' or 'cliques_maximum'.
    3897             See http://trac.sagemath.org/5793 for details.
    3898             [[4, 0], [4, 1, 2, 3]]
    3899 
    3900         """
    3901         from sage.misc.superseded import deprecation
    3902         deprecation(5793, "The function 'cliques' has been deprecated. Use " + \
    3903                     "'cliques_maximal' or 'cliques_maximum'.")
    3904         return self.cliques_maximal()
    3905        
    3906     def cliques_maximum(self):
    3907         """
    3908         Returns the list of all maximum cliques, with each clique represented
    3909         by a list of vertices. A clique is an induced complete subgraph, and a
    3910         maximum clique is one of maximal order.
    3911        
    3912         .. NOTE::
    3913        
    3914             Currently only implemented for undirected graphs. Use to_undirected
    3915             to convert a digraph to an undirected graph.
    3916        
    3917         ALGORITHM:
    3918        
    3919         This function is based on Cliquer [NisOst2003]_.
    3920            
    3921         REFERENCE:
    3922 
    3923         .. [NisOst2003] Sampo Niskanen and Patric R. J. Ostergard,
    3924           "Cliquer User's Guide, Version 1.0," Communications Laboratory,
    3925           Helsinki University of Technology, Espoo, Finland,
    3926           Tech. Rep. T48, 2003.
    3927        
    3928         EXAMPLES::
    3929        
    3930             sage: graphs.ChvatalGraph().cliques_maximum()
    3931             [[0, 1], [0, 4], [0, 6], [0, 9], [1, 2], [1, 5], [1, 7], [2, 3], [2, 6], [2, 8], [3, 4], [3, 7], [3, 9], [4, 5], [4, 8], [5, 10], [5, 11], [6, 10], [6, 11], [7, 8], [7, 11], [8, 10], [9, 10], [9, 11]]
    3932             sage: G = Graph({0:[1,2,3], 1:[2], 3:[0,1]})
    3933             sage: G.show(figsize=[2,2])
    3934             sage: G.cliques_maximum()
    3935             [[0, 1, 2], [0, 1, 3]]
    3936             sage: C=graphs.PetersenGraph()
    3937             sage: C.cliques_maximum()
    3938             [[0, 1], [0, 4], [0, 5], [1, 2], [1, 6], [2, 3], [2, 7], [3, 4], [3, 8], [4, 9], [5, 7], [5, 8], [6, 8], [6, 9], [7, 9]]
    3939             sage: C = Graph('DJ{')
    3940             sage: C.cliques_maximum()
    3941             [[1, 2, 3, 4]]
    3942 
    3943         """
    3944         from sage.graphs.cliquer import all_max_clique
    3945         return sorted(all_max_clique(self))
     3735    cliques = deprecated_function_alias(5739, cliques_maximal)
    39463736
    39473737    def clique_maximum(self,  algorithm="Cliquer"):
    39483738        """
     
    50314821
    50324822        OUTPUT:
    50334823
    5034         graph with labeled edges
     4824        A graph with labeled edges
    50354825
    50364826        EXAMPLE:
    50374827
     
    50534843            sage: (2*g).gomory_hu_tree().is_connected()
    50544844            False
    50554845
    5056         On the other hand, such a tree has lost nothing of the initial 
     4846        On the other hand, such a tree has lost nothing of the initial
    50574847        graph connectedness::
    50584848
    50594849            sage: all([ t.flow(u,v) == g.flow(u,v) for u,v in Subsets( g.vertices(), 2 ) ])
     
    51514941Graph.is_long_antihole_free = types.MethodType(sage.graphs.weakly_chordal.is_long_antihole_free, None, Graph)
    51524942Graph.is_weakly_chordal = types.MethodType(sage.graphs.weakly_chordal.is_weakly_chordal, None, Graph)
    51534943
     4944import sage.graphs.chrompoly
     4945Graph.chromatic_polynomial = types.MethodType(sage.graphs.chrompoly.chromatic_polynomial, None, Graph)
     4946
     4947import sage.graphs.graph_decompositions.rankwidth
     4948Graph.rank_decomposition = types.MethodType(sage.graphs.graph_decompositions.rankwidth.rank_decomposition, None, Graph)
     4949
     4950import sage.graphs.matchpoly
     4951Graph.matching_polynomial = types.MethodType(sage.graphs.matchpoly.matching_polynomial, None, Graph)
     4952
     4953import sage.graphs.cliquer
     4954Graph.cliques_maximum = types.MethodType(sage.graphs.cliquer.all_max_clique, None, Graph)
    51544955
    51554956def compare_edges(x, y):
    51564957    """
  • sage/graphs/matchpoly.pyx

    diff --git a/sage/graphs/matchpoly.pyx b/sage/graphs/matchpoly.pyx
    a b  
    1616- Robert Miller, Tom Boothby - original implementation
    1717
    1818REFERENCE:
    19  Chris Godsil, Algebraic Combinatorics.
     19
     20.. [Godsil93] Chris Godsil (1993) Algebraic Combinatorics.
     21
    2022
    2123Methods
    2224-------
     
    5254
    5355        \mu(x)=\sum_{k \geq 0} (-1)^k p(G,k) x^{n-2k}
    5456
    55 
    5657    INPUT:
    5758
    5859    - ``complement`` - (default: ``True``) whether to use Godsil's duality
     
    202203        x^12 - 66*x^10 + 1485*x^8 - 13860*x^6 + 51975*x^4 - 62370*x^2 + 10395
    203204        sage: matching_polynomial(graphs.CompleteGraph(13), complement=False)
    204205        x^13 - 78*x^11 + 2145*x^9 - 25740*x^7 + 135135*x^5 - 270270*x^3 + 135135*x
    205 
    206     REFERENCE:
    207 
    208     .. [Godsil93] Chris Godsil (1993) Algebraic Combinatorics.
    209 
    210 
    211206    """
    212207
    213208    cdef int nverts, nedges, i, j, v, cur