Skip to content

Commit c71bd71

Browse files
committed
Fix data type for graph degree in static_dense_graph
Fix for src/sage/graphs/base/static_dense_graph.cp313-win_amd64.pyd.p/src/sage/graphs/base/static_dense_graph.pyx.c: 2025-11-29T22:55:09.9262575Z In function 2025-11-29T22:55:09.9262723Z '__pyx_gb_4sage_6graphs_4base_18static_dense_graph_13generator1': 2025-11-29T22:55:09.9263047Z src/sage/graphs/base/static_dense_graph.cp313-win_amd64.pyd.p/src/sage/graphs/base/static_dense_graph.pyx.c:19862:88: 2025-11-29T22:55:09.9263213Z error: passing argument 1 of '_bitset_len' from incompatible pointer 2025-11-29T22:55:09.9263401Z type [-Wincompatible-pointer-types] 2025-11-29T22:55:09.9263473Z 19862 | __pyx_t_9 = 2025-11-29T22:55:09.9263601Z PyInt_FromSsize_t((__pyx_cur_scope->__pyx_v_num_edges 2025-11-29T22:55:09.9263701Z + _bitset_len((&__pyx_cur_scope->__pyx_v_c), 1))); if 2025-11-29T22:55:09.9263813Z (unlikely(!__pyx_t_9)) __PYX_ERR(0, 688, __pyx_L1_error) 2025-11-29T22:55:09.9263872Z | 2025-11-29T22:55:09.9263941Z ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2025-11-29T22:55:09.9263992Z | 2025-11-29T22:55:09.9264050Z | 2025-11-29T22:55:09.9264101Z | 2025-11-29T22:55:09.9264192Z mp_bitcnt_t * {aka long unsigned int *} 2025-11-29T22:55:09.9264262Z In file included from 2025-11-29T22:55:09.9264587Z src/sage/graphs/base/static_dense_graph.cp313-win_amd64.pyd.p/src/sage/graphs/base/static_dense_graph.pyx.c:1228: 2025-11-29T22:55:09.9264748Z ..\src\sage\data_structures/bitset_intrinsics.h:272:43: note: expected 2025-11-29T22:55:09.9264889Z 'mp_limb_t *' {aka 'long long unsigned int *'} but argument is of type 2025-11-29T22:55:09.9264978Z 'mp_bitcnt_t *' {aka 'long unsigned int *'} 2025-11-29T22:55:09.9265124Z 272 | static inline long _bitset_len(mp_limb_t* bits, mp_bitcnt_t 2025-11-29T22:55:09.9265178Z limbs){ 2025-11-29T22:55:09.9265261Z | ~~~~~~~~~~~^~~~ 2025-11-29T22:55:09.9265560Z src/sage/graphs/base/static_dense_graph.cp313-win_amd64.pyd.p/src/sage/graphs/base/static_dense_graph.pyx.c: 2025-11-29T22:55:09.9265649Z In function '__Pyx_ImportType_3_0_12': 2025-11-29T22:55:09.9265978Z src/sage/graphs/base/static_dense_graph.cp313-win_amd64.pyd.p/src/sage/graphs/base/static_dense_graph.pyx.c:28401:13: 2025-11-29T22:55:09.9266139Z warning: unknown conversion type character 'z' in format [-Wformat=] 2025-11-29T22:55:09.9266246Z 28401 | "%s.%s size changed, may indicate binary 2025-11-29T22:55:09.9266322Z incompatibility. " 2025-11-29T22:55:09.9266375Z | 2025-11-29T22:55:09.9266467Z ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2025-11-29T22:55:09.9266793Z src/sage/graphs/base/static_dense_graph.cp313-win_amd64.pyd.p/src/sage/graphs/base/static_dense_graph.pyx.c:28402:24: 2025-11-29T22:55:09.9266871Z note: format string is defined here 2025-11-29T22:55:09.9267004Z 28402 | "Expected %zd from C header, got %zd from PyObject", 2025-11-29T22:55:09.9267151Z | ^ 2025-11-29T22:55:09.9267469Z src/sage/graphs/base/static_dense_graph.cp313-win_amd64.pyd.p/src/sage/graphs/base/static_dense_graph.pyx.c:28401:13: 2025-11-29T22:55:09.9267629Z warning: unknown conversion type character 'z' in format [-Wformat=] 2025-11-29T22:55:09.9267730Z 28401 | "%s.%s size changed, may indicate binary 2025-11-29T22:55:09.9267803Z incompatibility. " 2025-11-29T22:55:09.9267855Z | 2025-11-29T22:55:09.9267938Z ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2025-11-29T22:55:09.9268266Z src/sage/graphs/base/static_dense_graph.cp313-win_amd64.pyd.p/src/sage/graphs/base/static_dense_graph.pyx.c:28402:47: 2025-11-29T22:55:09.9268344Z note: format string is defined here 2025-11-29T22:55:09.9268464Z 28402 | "Expected %zd from C header, got %zd from PyObject", 2025-11-29T22:55:09.9268549Z | ^ 2025-11-29T22:55:09.9268861Z src/sage/graphs/base/static_dense_graph.cp313-win_amd64.pyd.p/src/sage/graphs/base/static_dense_graph.pyx.c:28401:13: 2025-11-29T22:55:09.9269001Z warning: too many arguments for format [-Wformat-extra-args] 2025-11-29T22:55:09.9269096Z 28401 | "%s.%s size changed, may indicate binary 2025-11-29T22:55:09.9269161Z incompatibility. " 2025-11-29T22:55:09.9269215Z | 2025-11-29T22:55:09.9269366Z ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 parent 11091fd commit c71bd71

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/sage/graphs/base/static_dense_graph.pyx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ def connected_full_subgraphs(G, edges_only=False, labels=False,
612612
raise ValueError("the input (di)graph is not connected")
613613

614614
for d in G.degree():
615-
if d >= 8 * sizeof(unsigned long) - 1:
615+
if d >= 8 * sizeof(mp_limb_t) - 1:
616616
raise ValueError("the degree of the graph is too large for this method")
617617

618618
cdef Py_ssize_t n = G.order()
@@ -640,7 +640,7 @@ def connected_full_subgraphs(G, edges_only=False, labels=False,
640640

641641
cdef MemoryAllocator mem = MemoryAllocator()
642642
cdef int * order = <int *> mem.calloc(n, sizeof(int))
643-
cdef mp_bitcnt_t * n_cpt = <mp_bitcnt_t *> mem.calloc(n, sizeof(mp_bitcnt_t))
643+
cdef mp_limb_t * n_cpt = <mp_limb_t *> mem.calloc(n, sizeof(mp_limb_t))
644644

645645
# We use several bitsets to store the current boundary and active neighbors.
646646
# We also need another bitset that we create at the same time
@@ -659,10 +659,10 @@ def connected_full_subgraphs(G, edges_only=False, labels=False,
659659
bitset_complement(active, active)
660660
bitset_discard(active, 0)
661661
bitset_copy(neighborhoods.rows[0], DG.rows[0])
662-
n_cpt[0] = 1 << bitset_len(DG.rows[0])
662+
n_cpt[0] = (<mp_limb_t>1) << bitset_len(DG.rows[0])
663663

664664
cdef long u, v, j
665-
cdef mp_bitcnt_t c
665+
cdef mp_limb_t c
666666
cdef Py_ssize_t num_edges = 0
667667
cdef list E = []
668668
cdef list edges
@@ -734,7 +734,10 @@ def connected_full_subgraphs(G, edges_only=False, labels=False,
734734
# prepare neighborhood of u
735735
bitset_and(neighborhoods.rows[i], active, DG.rows[u])
736736
j = bitset_len(neighborhoods.rows[i])
737-
n_cpt[i] = bool(j) << j # 0 if not j else 2^j
737+
if j:
738+
n_cpt[i] = (<mp_limb_t>1) << j # 2^j possible neighborhoods
739+
else:
740+
n_cpt[i] = 0
738741

739742
sig_on()
740743
binary_matrix_free(boundaries)

0 commit comments

Comments
 (0)