Ticket #13808: trac_13808-rev2.patch

File trac_13808-rev2.patch, 3.1 KB (added by dcoudert, 8 years ago)
  • sage/graphs/hyperbolicity.pyx

    # HG changeset patch
    # User dcoudert <david.coudert@inria.fr>
    # Date 1356119985 -3600
    # Node ID 386b880c3c51919efc089b5d710ffee3bbeaea84
    # Parent  9166fdbbd99a6b37dddde6184cd8c83fe27cc5b5
    trac #13808 -- second review patch
    
    diff --git a/sage/graphs/hyperbolicity.pyx b/sage/graphs/hyperbolicity.pyx
    a b  
    498498    - ``h_UB`` -- is an integer equal to the proven upper bound for `h`. When
    499499      ``h == h_UB``, the returned solution is optimal.
    500500    """
    501     cdef int i, j, l, l1, l2, x, y, h, hh, h_UB, a, b, c, d, S1, S2, S3
     501    cdef int i, j, l, l1, l2, h, hh, h_UB, a, b, c, d, S1, S2, S3
     502    cdef uint32_t x, y
    502503    cdef dict distr = {}
    503504    cdef list certificate = []
    504505
     
    889890
    890891    cdef unsigned short * _distances_
    891892    cdef unsigned short ** distances
    892     cdef int i, j, k, iN, N, hyp, hyp_UB, hh, hh_UB, D
     893    cdef int i, j, k, N, hyp, hyp_UB, hh, hh_UB, D
    893894    cdef dict distr = {}
    894895    cdef list certificate = []
    895896    cdef list certif
     
    932933            # in the range [0..N-1].
    933934            mymap = H.relabel( return_map=True )
    934935
    935             # We compute the distances and store the results in a 2D array, and the diameter
     936            # We compute the distances and store the results in a 2D array, and
     937            # the diameter
    936938            _distances_ = c_distances_all_pairs(H)
     939            if _distances_ == NULL:
     940                raise MemoryError
    937941            distances = <unsigned short **>sage_malloc(sizeof(unsigned short *)*N)
    938942            if distances == NULL:
    939943                sage_free(_distances_)
     
    948952
    949953            # We call the cython function for computing the hyperbolicity with
    950954            # the required parameters.
    951             if algorithm == 'cuts' or algorithm == 'cuts+':
     955            if algorithm == 'cuts':
     956                hh, certif, hh_UB = __hyperbolicity__(N, distances, D, hyp, approximation_factor, 2*additive_gap, [], verbose)
    952957
    953                 if algorithm == 'cuts+':
    954                     # We compute the elimination ordering of simplicial vertices of H
    955                     elim = elimination_ordering_of_simplicial_vertices(H, max(2,floor(N**(1/2.0))), verbose)
     958            elif algorithm == 'cuts+':
     959                # We compute the elimination ordering of simplicial vertices of H
     960                elim = elimination_ordering_of_simplicial_vertices(H, max(2,floor(N**(1/2.0))), verbose)
     961                if len(elim)==N and hyp>=2:
     962                    # We know that this component has hyperbolicity <=1 and so
     963                    # that we cannot improve current lower bound.
     964                    hh = hyp
    956965                else:
    957                     elim = []
    958 
    959                 hh, certif, hh_UB = __hyperbolicity__(N, distances, D, hyp, approximation_factor, 2*additive_gap, elim, verbose)
     966                    hh, certif, hh_UB = __hyperbolicity__(N, distances, D, hyp, approximation_factor, 2*additive_gap, elim, verbose)
    960967
    961968            elif algorithm == 'basic':
    962969                hh, certif = __hyperbolicity_basic_algorithm__(N, distances, verbose)