# 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
|
|
498 | 498 | - ``h_UB`` -- is an integer equal to the proven upper bound for `h`. When |
499 | 499 | ``h == h_UB``, the returned solution is optimal. |
500 | 500 | """ |
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 |
502 | 503 | cdef dict distr = {} |
503 | 504 | cdef list certificate = [] |
504 | 505 | |
… |
… |
|
889 | 890 | |
890 | 891 | cdef unsigned short * _distances_ |
891 | 892 | 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 |
893 | 894 | cdef dict distr = {} |
894 | 895 | cdef list certificate = [] |
895 | 896 | cdef list certif |
… |
… |
|
932 | 933 | # in the range [0..N-1]. |
933 | 934 | mymap = H.relabel( return_map=True ) |
934 | 935 | |
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 |
936 | 938 | _distances_ = c_distances_all_pairs(H) |
| 939 | if _distances_ == NULL: |
| 940 | raise MemoryError |
937 | 941 | distances = <unsigned short **>sage_malloc(sizeof(unsigned short *)*N) |
938 | 942 | if distances == NULL: |
939 | 943 | sage_free(_distances_) |
… |
… |
|
948 | 952 | |
949 | 953 | # We call the cython function for computing the hyperbolicity with |
950 | 954 | # 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) |
952 | 957 | |
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 |
956 | 965 | 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) |
960 | 967 | |
961 | 968 | elif algorithm == 'basic': |
962 | 969 | hh, certif = __hyperbolicity_basic_algorithm__(N, distances, verbose) |