Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

11721 lines (11059 sloc) 544.184 kb
/* Generated by Cython 0.17.1 on Mon Oct 29 21:25:21 2012 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
#error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02040000
#error Cython requires Python 2.4+.
#else
#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
#ifndef __stdcall
#define __stdcall
#endif
#ifndef __cdecl
#define __cdecl
#endif
#ifndef __fastcall
#define __fastcall
#endif
#endif
#ifndef DL_IMPORT
#define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
#define DL_EXPORT(t) t
#endif
#ifndef PY_LONG_LONG
#define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
#define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
#define CYTHON_COMPILING_IN_PYPY 1
#define CYTHON_COMPILING_IN_CPYTHON 0
#else
#define CYTHON_COMPILING_IN_PYPY 0
#define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if PY_VERSION_HEX < 0x02050000
typedef int Py_ssize_t;
#define PY_SSIZE_T_MAX INT_MAX
#define PY_SSIZE_T_MIN INT_MIN
#define PY_FORMAT_SIZE_T ""
#define CYTHON_FORMAT_SSIZE_T ""
#define PyInt_FromSsize_t(z) PyInt_FromLong(z)
#define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o)
#define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
(PyErr_Format(PyExc_TypeError, \
"expected index value, got %.200s", Py_TYPE(o)->tp_name), \
(PyObject*)0))
#define PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && !PyComplex_Check(o))
#define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#define __PYX_BUILD_PY_SSIZE_T "i"
#else
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#endif
#if PY_VERSION_HEX < 0x02060000
#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
#define PyVarObject_HEAD_INIT(type, size) \
PyObject_HEAD_INIT(type) size,
#define PyType_Modified(t)
typedef struct {
void *buf;
PyObject *obj;
Py_ssize_t len;
Py_ssize_t itemsize;
int readonly;
int ndim;
char *format;
Py_ssize_t *shape;
Py_ssize_t *strides;
Py_ssize_t *suboffsets;
void *internal;
} Py_buffer;
#define PyBUF_SIMPLE 0
#define PyBUF_WRITABLE 0x0001
#define PyBUF_FORMAT 0x0004
#define PyBUF_ND 0x0008
#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
#endif
#if PY_MAJOR_VERSION < 3
#define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
PyCode_New(a, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#else
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
#define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
#endif
#if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6
#define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
#endif
#if PY_MAJOR_VERSION >= 3
#define Py_TPFLAGS_CHECKTYPES 0
#define Py_TPFLAGS_HAVE_INDEX 0
#endif
#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
#define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
#define CYTHON_PEP393_ENABLED 1
#define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
0 : _PyUnicode_Ready((PyObject *)(op)))
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#else
#define CYTHON_PEP393_ENABLED 0
#define __Pyx_PyUnicode_READY(op) (0)
#define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
#define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
#define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBaseString_Type PyUnicode_Type
#define PyStringObject PyUnicodeObject
#define PyString_Type PyUnicode_Type
#define PyString_Check PyUnicode_Check
#define PyString_CheckExact PyUnicode_CheckExact
#endif
#if PY_VERSION_HEX < 0x02060000
#define PyBytesObject PyStringObject
#define PyBytes_Type PyString_Type
#define PyBytes_Check PyString_Check
#define PyBytes_CheckExact PyString_CheckExact
#define PyBytes_FromString PyString_FromString
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
#define PyBytes_FromFormat PyString_FromFormat
#define PyBytes_DecodeEscape PyString_DecodeEscape
#define PyBytes_AsString PyString_AsString
#define PyBytes_AsStringAndSize PyString_AsStringAndSize
#define PyBytes_Size PyString_Size
#define PyBytes_AS_STRING PyString_AS_STRING
#define PyBytes_GET_SIZE PyString_GET_SIZE
#define PyBytes_Repr PyString_Repr
#define PyBytes_Concat PyString_Concat
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
#endif
#if PY_VERSION_HEX < 0x02060000
#define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
#define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
#endif
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#if PY_MAJOR_VERSION >= 3
#define PyIntObject PyLongObject
#define PyInt_Type PyLong_Type
#define PyInt_Check(op) PyLong_Check(op)
#define PyInt_CheckExact(op) PyLong_CheckExact(op)
#define PyInt_FromString PyLong_FromString
#define PyInt_FromUnicode PyLong_FromUnicode
#define PyInt_FromLong PyLong_FromLong
#define PyInt_FromSize_t PyLong_FromSize_t
#define PyInt_FromSsize_t PyLong_FromSsize_t
#define PyInt_AsLong PyLong_AsLong
#define PyInt_AS_LONG PyLong_AS_LONG
#define PyInt_AsSsize_t PyLong_AsSsize_t
#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif
#if PY_MAJOR_VERSION >= 3
#define PyBoolObject PyLongObject
#endif
#if PY_VERSION_HEX < 0x03020000
typedef long Py_hash_t;
#define __Pyx_PyInt_FromHash_t PyInt_FromLong
#define __Pyx_PyInt_AsHash_t PyInt_AsLong
#else
#define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
#endif
#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
#define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
#define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
#define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
#define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
(PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
(likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
(PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
#define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
(PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
(likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
(PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
#define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
(PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
(likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
(PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif
#if PY_MAJOR_VERSION >= 3
#define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif
#if PY_VERSION_HEX < 0x02050000
#define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n)))
#define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
#define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n)))
#else
#define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n))
#define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
#define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n))
#endif
#if PY_VERSION_HEX < 0x02050000
#define __Pyx_NAMESTR(n) ((char *)(n))
#define __Pyx_DOCSTR(n) ((char *)(n))
#else
#define __Pyx_NAMESTR(n) (n)
#define __Pyx_DOCSTR(n) (n)
#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
#else
#define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
#endif
#ifndef __PYX_EXTERN_C
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#endif
#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE__scipy__sparse__csgraph___traversal
#define __PYX_HAVE_API__scipy__sparse__csgraph___traversal
#include "stdio.h"
#include "stdlib.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */
#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif
/* inline attribute */
#ifndef CYTHON_INLINE
#if defined(__GNUC__)
#define CYTHON_INLINE __inline__
#elif defined(_MSC_VER)
#define CYTHON_INLINE __inline
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define CYTHON_INLINE inline
#else
#define CYTHON_INLINE
#endif
#endif
/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
#endif
typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
/* Type Conversion Predeclarations */
#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s) ((unsigned char*) PyBytes_AsString(s))
#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
#if CYTHON_COMPILING_IN_CPYTHON
#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#else
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;
#if !defined(CYTHON_CCOMPLEX)
#if defined(__cplusplus)
#define CYTHON_CCOMPLEX 1
#elif defined(_Complex_I)
#define CYTHON_CCOMPLEX 1
#else
#define CYTHON_CCOMPLEX 0
#endif
#endif
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#include <complex>
#else
#include <complex.h>
#endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
#undef _Complex_I
#define _Complex_I 1.0fj
#endif
static const char *__pyx_f[] = {
"_traversal.pyx",
"numpy.pxd",
"type.pxd",
"parameters.pxi",
};
#define IS_UNSIGNED(type) (((type) -1) > 0)
struct __Pyx_StructField_;
#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0)
typedef struct {
const char* name; /* for error messages only */
struct __Pyx_StructField_* fields;
size_t size; /* sizeof(type) */
size_t arraysize[8]; /* length of array in each dimension */
int ndim;
char typegroup; /* _R_eal, _C_omplex, Signed _I_nt, _U_nsigned int, _S_truct, _P_ointer, _O_bject, c_H_ar */
char is_unsigned;
int flags;
} __Pyx_TypeInfo;
typedef struct __Pyx_StructField_ {
__Pyx_TypeInfo* type;
const char* name;
size_t offset;
} __Pyx_StructField;
typedef struct {
__Pyx_StructField* field;
size_t parent_offset;
} __Pyx_BufFmt_StackElem;
typedef struct {
__Pyx_StructField root;
__Pyx_BufFmt_StackElem* head;
size_t fmt_offset;
size_t new_count, enc_count;
size_t struct_alignment;
int is_complex;
char enc_type;
char new_packmode;
char enc_packmode;
char is_valid_array;
} __Pyx_BufFmt_Context;
/* "numpy.pxd":723
* # in Cython to enable them only on the right systems.
*
* ctypedef npy_int8 int8_t # <<<<<<<<<<<<<<
* ctypedef npy_int16 int16_t
* ctypedef npy_int32 int32_t
*/
typedef npy_int8 __pyx_t_5numpy_int8_t;
/* "numpy.pxd":724
*
* ctypedef npy_int8 int8_t
* ctypedef npy_int16 int16_t # <<<<<<<<<<<<<<
* ctypedef npy_int32 int32_t
* ctypedef npy_int64 int64_t
*/
typedef npy_int16 __pyx_t_5numpy_int16_t;
/* "numpy.pxd":725
* ctypedef npy_int8 int8_t
* ctypedef npy_int16 int16_t
* ctypedef npy_int32 int32_t # <<<<<<<<<<<<<<
* ctypedef npy_int64 int64_t
* #ctypedef npy_int96 int96_t
*/
typedef npy_int32 __pyx_t_5numpy_int32_t;
/* "numpy.pxd":726
* ctypedef npy_int16 int16_t
* ctypedef npy_int32 int32_t
* ctypedef npy_int64 int64_t # <<<<<<<<<<<<<<
* #ctypedef npy_int96 int96_t
* #ctypedef npy_int128 int128_t
*/
typedef npy_int64 __pyx_t_5numpy_int64_t;
/* "numpy.pxd":730
* #ctypedef npy_int128 int128_t
*
* ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<<
* ctypedef npy_uint16 uint16_t
* ctypedef npy_uint32 uint32_t
*/
typedef npy_uint8 __pyx_t_5numpy_uint8_t;
/* "numpy.pxd":731
*
* ctypedef npy_uint8 uint8_t
* ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<<
* ctypedef npy_uint32 uint32_t
* ctypedef npy_uint64 uint64_t
*/
typedef npy_uint16 __pyx_t_5numpy_uint16_t;
/* "numpy.pxd":732
* ctypedef npy_uint8 uint8_t
* ctypedef npy_uint16 uint16_t
* ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<<
* ctypedef npy_uint64 uint64_t
* #ctypedef npy_uint96 uint96_t
*/
typedef npy_uint32 __pyx_t_5numpy_uint32_t;
/* "numpy.pxd":733
* ctypedef npy_uint16 uint16_t
* ctypedef npy_uint32 uint32_t
* ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<<
* #ctypedef npy_uint96 uint96_t
* #ctypedef npy_uint128 uint128_t
*/
typedef npy_uint64 __pyx_t_5numpy_uint64_t;
/* "numpy.pxd":737
* #ctypedef npy_uint128 uint128_t
*
* ctypedef npy_float32 float32_t # <<<<<<<<<<<<<<
* ctypedef npy_float64 float64_t
* #ctypedef npy_float80 float80_t
*/
typedef npy_float32 __pyx_t_5numpy_float32_t;
/* "numpy.pxd":738
*
* ctypedef npy_float32 float32_t
* ctypedef npy_float64 float64_t # <<<<<<<<<<<<<<
* #ctypedef npy_float80 float80_t
* #ctypedef npy_float128 float128_t
*/
typedef npy_float64 __pyx_t_5numpy_float64_t;
/* "numpy.pxd":747
* # The int types are mapped a bit surprising --
* # numpy.int corresponds to 'l' and numpy.long to 'q'
* ctypedef npy_long int_t # <<<<<<<<<<<<<<
* ctypedef npy_longlong long_t
* ctypedef npy_longlong longlong_t
*/
typedef npy_long __pyx_t_5numpy_int_t;
/* "numpy.pxd":748
* # numpy.int corresponds to 'l' and numpy.long to 'q'
* ctypedef npy_long int_t
* ctypedef npy_longlong long_t # <<<<<<<<<<<<<<
* ctypedef npy_longlong longlong_t
*
*/
typedef npy_longlong __pyx_t_5numpy_long_t;
/* "numpy.pxd":749
* ctypedef npy_long int_t
* ctypedef npy_longlong long_t
* ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<<
*
* ctypedef npy_ulong uint_t
*/
typedef npy_longlong __pyx_t_5numpy_longlong_t;
/* "numpy.pxd":751
* ctypedef npy_longlong longlong_t
*
* ctypedef npy_ulong uint_t # <<<<<<<<<<<<<<
* ctypedef npy_ulonglong ulong_t
* ctypedef npy_ulonglong ulonglong_t
*/
typedef npy_ulong __pyx_t_5numpy_uint_t;
/* "numpy.pxd":752
*
* ctypedef npy_ulong uint_t
* ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<<
* ctypedef npy_ulonglong ulonglong_t
*
*/
typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
/* "numpy.pxd":753
* ctypedef npy_ulong uint_t
* ctypedef npy_ulonglong ulong_t
* ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<<
*
* ctypedef npy_intp intp_t
*/
typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t;
/* "numpy.pxd":755
* ctypedef npy_ulonglong ulonglong_t
*
* ctypedef npy_intp intp_t # <<<<<<<<<<<<<<
* ctypedef npy_uintp uintp_t
*
*/
typedef npy_intp __pyx_t_5numpy_intp_t;
/* "numpy.pxd":756
*
* ctypedef npy_intp intp_t
* ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<<
*
* ctypedef npy_double float_t
*/
typedef npy_uintp __pyx_t_5numpy_uintp_t;
/* "numpy.pxd":758
* ctypedef npy_uintp uintp_t
*
* ctypedef npy_double float_t # <<<<<<<<<<<<<<
* ctypedef npy_double double_t
* ctypedef npy_longdouble longdouble_t
*/
typedef npy_double __pyx_t_5numpy_float_t;
/* "numpy.pxd":759
*
* ctypedef npy_double float_t
* ctypedef npy_double double_t # <<<<<<<<<<<<<<
* ctypedef npy_longdouble longdouble_t
*
*/
typedef npy_double __pyx_t_5numpy_double_t;
/* "numpy.pxd":760
* ctypedef npy_double float_t
* ctypedef npy_double double_t
* ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<<
*
* ctypedef npy_cfloat cfloat_t
*/
typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
/* "/home/rgommers/Code/scipy/scipy/sparse/csgraph/parameters.pxi":2
* DTYPE = np.float64
* ctypedef np.float64_t DTYPE_t # <<<<<<<<<<<<<<
*
* ITYPE = np.int32
*/
typedef __pyx_t_5numpy_float64_t __pyx_t_5scipy_6sparse_7csgraph_10_traversal_DTYPE_t;
/* "/home/rgommers/Code/scipy/scipy/sparse/csgraph/parameters.pxi":5
*
* ITYPE = np.int32
* ctypedef np.int32_t ITYPE_t # <<<<<<<<<<<<<<
*
* # EPS is the precision of DTYPE
*/
typedef __pyx_t_5numpy_int32_t __pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t;
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
typedef ::std::complex< float > __pyx_t_float_complex;
#else
typedef float _Complex __pyx_t_float_complex;
#endif
#else
typedef struct { float real, imag; } __pyx_t_float_complex;
#endif
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
typedef ::std::complex< double > __pyx_t_double_complex;
#else
typedef double _Complex __pyx_t_double_complex;
#endif
#else
typedef struct { double real, imag; } __pyx_t_double_complex;
#endif
/*--- Type declarations ---*/
/* "numpy.pxd":762
* ctypedef npy_longdouble longdouble_t
*
* ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<<
* ctypedef npy_cdouble cdouble_t
* ctypedef npy_clongdouble clongdouble_t
*/
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
/* "numpy.pxd":763
*
* ctypedef npy_cfloat cfloat_t
* ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<<
* ctypedef npy_clongdouble clongdouble_t
*
*/
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
/* "numpy.pxd":764
* ctypedef npy_cfloat cfloat_t
* ctypedef npy_cdouble cdouble_t
* ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<<
*
* ctypedef npy_cdouble complex_t
*/
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
/* "numpy.pxd":766
* ctypedef npy_clongdouble clongdouble_t
*
* ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_MultiIterNew1(a):
*/
typedef npy_cdouble __pyx_t_5numpy_complex_t;
struct __pyx_t_5scipy_6sparse_7csgraph_10_traversal_NodeStack;
/* "scipy/sparse/csgraph/_traversal.pyx":670
*
*
* cdef struct NodeStack: # <<<<<<<<<<<<<<
* int index
* int label
*/
struct __pyx_t_5scipy_6sparse_7csgraph_10_traversal_NodeStack {
int index;
int label;
int i;
int N;
int c;
int arr[0];
};
#ifndef CYTHON_REFNANNY
#define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
typedef struct {
void (*INCREF)(void*, PyObject*, int);
void (*DECREF)(void*, PyObject*, int);
void (*GOTREF)(void*, PyObject*, int);
void (*GIVEREF)(void*, PyObject*, int);
void* (*SetupContext)(const char*, int, const char*);
void (*FinishContext)(void**);
} __Pyx_RefNannyAPIStruct;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
#define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
#ifdef WITH_THREAD
#define __Pyx_RefNannySetupContext(name, acquire_gil) \
if (acquire_gil) { \
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
PyGILState_Release(__pyx_gilstate_save); \
} else { \
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
}
#else
#define __Pyx_RefNannySetupContext(name, acquire_gil) \
__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
#endif
#define __Pyx_RefNannyFinishContext() \
__Pyx_RefNanny->FinishContext(&__pyx_refnanny)
#define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
#define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
#define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
#else
#define __Pyx_RefNannyDeclarations
#define __Pyx_RefNannySetupContext(name, acquire_gil)
#define __Pyx_RefNannyFinishContext()
#define __Pyx_INCREF(r) Py_INCREF(r)
#define __Pyx_DECREF(r) Py_DECREF(r)
#define __Pyx_GOTREF(r)
#define __Pyx_GIVEREF(r)
#define __Pyx_XINCREF(r) Py_XINCREF(r)
#define __Pyx_XDECREF(r) Py_XDECREF(r)
#define __Pyx_XGOTREF(r)
#define __Pyx_XGIVEREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
const char* function_name); /*proto*/
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
PyObject *r;
if (!j) return NULL;
r = PyObject_GetItem(o, j);
Py_DECREF(j);
return r;
}
#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
__Pyx_GetItemInt_List_Fast(o, i) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
#if CYTHON_COMPILING_IN_CPYTHON
if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
PyObject *r = PyList_GET_ITEM(o, i);
Py_INCREF(r);
return r;
}
else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
Py_INCREF(r);
return r;
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
return PySequence_GetItem(o, i);
#endif
}
#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
__Pyx_GetItemInt_Tuple_Fast(o, i) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
#if CYTHON_COMPILING_IN_CPYTHON
if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, i);
Py_INCREF(r);
return r;
}
else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
Py_INCREF(r);
return r;
}
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
#else
return PySequence_GetItem(o, i);
#endif
}
#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
__Pyx_GetItemInt_Fast(o, i) : \
__Pyx_GetItemInt_Generic(o, to_py_func(i)))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
#if CYTHON_COMPILING_IN_CPYTHON
if (PyList_CheckExact(o)) {
Py_ssize_t n = (likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
if (likely((n >= 0) & (n < PyList_GET_SIZE(o)))) {
PyObject *r = PyList_GET_ITEM(o, n);
Py_INCREF(r);
return r;
}
}
else if (PyTuple_CheckExact(o)) {
Py_ssize_t n = (likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
if (likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
PyObject *r = PyTuple_GET_ITEM(o, n);
Py_INCREF(r);
return r;
}
} else { /* inlined PySequence_GetItem() */
PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
if (likely(m && m->sq_item)) {
if (unlikely(i < 0) && likely(m->sq_length)) {
Py_ssize_t l = m->sq_length(o);
if (unlikely(l < 0)) return NULL;
i += l;
}
return m->sq_item(o, i);
}
}
#else
if (PySequence_Check(o)) {
return PySequence_GetItem(o, i);
}
#endif
return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}
static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/
static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj,
__Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack);
static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
static void __Pyx_RaiseBufferIndexError(int axis); /*proto*/
#define __Pyx_BufPtrCContig1d(type, buf, i0, s0) ((type)buf + i0)
static void __Pyx_RaiseBufferFallbackError(void); /*proto*/
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
typedef struct {
Py_ssize_t shape, strides, suboffsets;
} __Pyx_Buf_DimInfo;
typedef struct {
size_t refcount;
Py_buffer pybuffer;
} __Pyx_Buffer;
typedef struct {
__Pyx_Buffer *rcbuffer;
char *data;
__Pyx_Buf_DimInfo diminfo[8];
} __Pyx_LocalBuf_ND;
#if PY_MAJOR_VERSION < 3
static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags);
static void __Pyx_ReleaseBuffer(Py_buffer *view);
#else
#define __Pyx_GetBuffer PyObject_GetBuffer
#define __Pyx_ReleaseBuffer PyBuffer_Release
#endif
static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0};
static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1};
static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/
static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name);
static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_int32(npy_int32);
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#define __Pyx_CREAL(z) ((z).real())
#define __Pyx_CIMAG(z) ((z).imag())
#else
#define __Pyx_CREAL(z) (__real__(z))
#define __Pyx_CIMAG(z) (__imag__(z))
#endif
#else
#define __Pyx_CREAL(z) ((z).real)
#define __Pyx_CIMAG(z) ((z).imag)
#endif
#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX
#define __Pyx_SET_CREAL(z,x) ((z).real(x))
#define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
#define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
#define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
#if CYTHON_CCOMPLEX
#define __Pyx_c_eqf(a, b) ((a)==(b))
#define __Pyx_c_sumf(a, b) ((a)+(b))
#define __Pyx_c_difff(a, b) ((a)-(b))
#define __Pyx_c_prodf(a, b) ((a)*(b))
#define __Pyx_c_quotf(a, b) ((a)/(b))
#define __Pyx_c_negf(a) (-(a))
#ifdef __cplusplus
#define __Pyx_c_is_zerof(z) ((z)==(float)0)
#define __Pyx_c_conjf(z) (::std::conj(z))
#if 1
#define __Pyx_c_absf(z) (::std::abs(z))
#define __Pyx_c_powf(a, b) (::std::pow(a, b))
#endif
#else
#define __Pyx_c_is_zerof(z) ((z)==0)
#define __Pyx_c_conjf(z) (conjf(z))
#if 1
#define __Pyx_c_absf(z) (cabsf(z))
#define __Pyx_c_powf(a, b) (cpowf(a, b))
#endif
#endif
#else
static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
#if 1
static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex);
#endif
#endif
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
#if CYTHON_CCOMPLEX
#define __Pyx_c_eq(a, b) ((a)==(b))
#define __Pyx_c_sum(a, b) ((a)+(b))
#define __Pyx_c_diff(a, b) ((a)-(b))
#define __Pyx_c_prod(a, b) ((a)*(b))
#define __Pyx_c_quot(a, b) ((a)/(b))
#define __Pyx_c_neg(a) (-(a))
#ifdef __cplusplus
#define __Pyx_c_is_zero(z) ((z)==(double)0)
#define __Pyx_c_conj(z) (::std::conj(z))
#if 1
#define __Pyx_c_abs(z) (::std::abs(z))
#define __Pyx_c_pow(a, b) (::std::pow(a, b))
#endif
#else
#define __Pyx_c_is_zero(z) ((z)==0)
#define __Pyx_c_conj(z) (conj(z))
#if 1
#define __Pyx_c_abs(z) (cabs(z))
#define __Pyx_c_pow(a, b) (cpow(a, b))
#endif
#endif
#else
static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
#if 1
static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex);
#endif
#endif
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
static void __Pyx_WriteUnraisable(const char *name, int clineno,
int lineno, const char *filename); /*proto*/
static int __Pyx_check_binary_version(void);
#if !defined(__Pyx_PyIdentifier_FromString)
#if PY_MAJOR_VERSION < 3
#define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
#else
#define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
#endif
#endif
static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/
typedef struct {
int code_line;
PyCodeObject* code_object;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
int count;
int max_count;
__Pyx_CodeObjectCacheEntry* entries;
};
static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static PyCodeObject *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
static void __Pyx_AddTraceback(const char *funcname, int c_line,
int py_line, const char *filename); /*proto*/
static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from 'cpython.buffer' */
/* Module declarations from 'cpython.ref' */
/* Module declarations from 'libc.stdio' */
/* Module declarations from 'cpython.object' */
/* Module declarations from '__builtin__' */
/* Module declarations from 'cpython.type' */
static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
/* Module declarations from 'libc.stdlib' */
/* Module declarations from 'numpy' */
/* Module declarations from 'numpy' */
static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0;
static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0;
static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/
/* Module declarations from 'cython' */
/* Module declarations from 'libc' */
/* Module declarations from 'scipy.sparse.csgraph._traversal' */
static __pyx_t_5scipy_6sparse_7csgraph_10_traversal_DTYPE_t __pyx_v_5scipy_6sparse_7csgraph_10_traversal_DTYPE_EPS;
static __pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t __pyx_v_5scipy_6sparse_7csgraph_10_traversal_NULL_IDX;
static unsigned int __pyx_f_5scipy_6sparse_7csgraph_10_traversal__breadth_first_directed(unsigned int, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *); /*proto*/
static unsigned int __pyx_f_5scipy_6sparse_7csgraph_10_traversal__breadth_first_undirected(unsigned int, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *); /*proto*/
static unsigned int __pyx_f_5scipy_6sparse_7csgraph_10_traversal__depth_first_directed(unsigned int, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *); /*proto*/
static unsigned int __pyx_f_5scipy_6sparse_7csgraph_10_traversal__depth_first_undirected(unsigned int, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *); /*proto*/
static int __pyx_f_5scipy_6sparse_7csgraph_10_traversal__connected_components_undirected(PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *, PyArrayObject *); /*proto*/
static int __pyx_f_5scipy_6sparse_7csgraph_10_traversal__connected_components_directed(PyArrayObject *, PyArrayObject *, PyArrayObject *); /*proto*/
static int __pyx_f_5scipy_6sparse_7csgraph_10_traversal__cc_visit(int, struct __pyx_t_5scipy_6sparse_7csgraph_10_traversal_NodeStack *, PyArrayObject *, PyArrayObject *, PyArrayObject *); /*proto*/
static int __pyx_f_5scipy_6sparse_7csgraph_10_traversal_stack_pop(struct __pyx_t_5scipy_6sparse_7csgraph_10_traversal_NodeStack *); /*proto*/
static int __pyx_f_5scipy_6sparse_7csgraph_10_traversal_stack_push(struct __pyx_t_5scipy_6sparse_7csgraph_10_traversal_NodeStack *, int); /*proto*/
static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t = { "ITYPE_t", NULL, sizeof(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t), 0 };
#define __Pyx_MODULE_NAME "scipy.sparse.csgraph._traversal"
int __pyx_module_is_main_scipy__sparse__csgraph___traversal = 0;
/* Implementation of 'scipy.sparse.csgraph._traversal' */
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_range;
static PyObject *__pyx_builtin_RuntimeError;
static PyObject *__pyx_pf_5scipy_6sparse_7csgraph_10_traversal_connected_components(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csgraph, PyObject *__pyx_v_directed, PyObject *__pyx_v_connection, PyObject *__pyx_v_return_labels); /* proto */
static PyObject *__pyx_pf_5scipy_6sparse_7csgraph_10_traversal_2breadth_first_tree(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csgraph, PyObject *__pyx_v_i_start, PyObject *__pyx_v_directed); /* proto */
static PyObject *__pyx_pf_5scipy_6sparse_7csgraph_10_traversal_4depth_first_tree(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csgraph, PyObject *__pyx_v_i_start, PyObject *__pyx_v_directed); /* proto */
static PyObject *__pyx_pf_5scipy_6sparse_7csgraph_10_traversal_6breadth_first_order(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csgraph, PyObject *__pyx_v_i_start, PyObject *__pyx_v_directed, PyObject *__pyx_v_return_predecessors); /* proto */
static PyObject *__pyx_pf_5scipy_6sparse_7csgraph_10_traversal_8depth_first_order(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csgraph, PyObject *__pyx_v_i_start, PyObject *__pyx_v_directed, PyObject *__pyx_v_return_predecessors); /* proto */
static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */
static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */
static char __pyx_k_3[] = "connection must be 'weak' or 'strong'";
static char __pyx_k_13[] = "s.i < 0";
static char __pyx_k_15[] = "s.i >= N";
static char __pyx_k_17[] = "ndarray is not C contiguous";
static char __pyx_k_19[] = "ndarray is not Fortran contiguous";
static char __pyx_k_21[] = "Non-native byte order not supported";
static char __pyx_k_23[] = "unknown dtype code in numpy.pxd (%d)";
static char __pyx_k_24[] = "Format string allocated too short, see comment in numpy.pxd";
static char __pyx_k_27[] = "Format string allocated too short.";
static char __pyx_k_29[] = "\nRoutines for traversing graphs in compressed sparse format\n";
static char __pyx_k_30[] = "scipy.sparse";
static char __pyx_k_31[] = "scipy.sparse.csgraph._validation";
static char __pyx_k_32[] = "scipy.sparse.csgraph._tools";
static char __pyx_k_35[] = "connected_components";
static char __pyx_k_36[] = "/home/rgommers/Code/scipy/scipy/sparse/csgraph/_traversal.pyx";
static char __pyx_k_37[] = "scipy.sparse.csgraph._traversal";
static char __pyx_k_46[] = "breadth_first_tree (line 86)";
static char __pyx_k_47[] = "\n breadth_first_tree(csgraph, i_start, directed=True)\n\n Return the tree generated by a breadth-first search\n\n Note that a breadth-first tree from a specified node is unique.\n\n Parameters\n ----------\n csgraph: array_like or sparse matrix\n The N x N matrix representing the compressed sparse graph. The input\n csgraph will be converted to csr format for the calculation.\n i_start: int\n The index of starting node.\n directed: bool, optional\n if True (default), then operate on a directed graph: only\n move from point i to point j along paths csgraph[i, j].\n if False, then find the shortest path on an undirected graph: the\n algorithm can progress from point i to j along csgraph[i, j] or\n csgraph[j, i].\n\n Returns\n -------\n cstree : csr matrix\n The N x N directed compressed-sparse representation of the breadth-\n first tree drawn from csgraph, starting at the specified node.\n\n Examples\n --------\n The following example shows the computation of a depth-first tree\n over a simple four-component graph, starting at node 0::\n\n input graph breadth first tree from (0)\n\n (0) (0)\n / \\ / \\\n 3 8 3 8\n / \\ / \\\n (3)---5---(1) (3) (1)\n \\ / /\n 6 2 2\n \\ / /\n (2) (2)\n\n In compressed sparse representation, the solution looks like this:\n\n >>> from scipy.sparse import csr_matrix\n >>> from scipy.sparse.csgraph import breadth_first_tree\n >>> X = csr_matrix([[0, 8, 0, 3],\n ... [0, 0, 2, 5],\n ... [0, 0, 0, 6],\n ... [0, 0, 0,"" 0]])\n >>> Tcsr = breadth_first_tree(X, 0, directed=False)\n >>> Tcsr.toarray().astype(int)\n array([[0, 8, 0, 3],\n [0, 0, 2, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0]])\n\n Note that the resulting graph is a Directed Acyclic Graph which spans\n the graph. A breadth-first tree from a given node is unique.\n ";
static char __pyx_k_48[] = "depth_first_tree (line 154)";
static char __pyx_k_49[] = "\n depth_first_tree(csgraph, i_start, directed=True)\n\n Return a tree generated by a depth-first search.\n\n Note that a tree generated by a depth-first search is not unique:\n it depends on the order that the children of each node are searched.\n\n Parameters\n ----------\n csgraph: array_like or sparse matrix\n The N x N matrix representing the compressed sparse graph. The input\n csgraph will be converted to csr format for the calculation.\n i_start: int\n The index of starting node.\n directed: bool, optional\n if True (default), then operate on a directed graph: only\n move from point i to point j along paths csgraph[i, j].\n if False, then find the shortest path on an undirected graph: the\n algorithm can progress from point i to j along csgraph[i, j] or\n csgraph[j, i].\n\n Returns\n -------\n cstree : csr matrix\n The N x N directed compressed-sparse representation of the depth-\n first tree drawn from csgraph, starting at the specified node.\n\n Examples\n --------\n The following example shows the computation of a depth-first tree\n over a simple four-component graph, starting at node 0::\n\n input graph depth first tree from (0)\n\n (0) (0)\n / \\ \\\n 3 8 8\n / \\ \\\n (3)---5---(1) (3) (1)\n \\ / \\ /\n 6 2 6 2\n \\ / \\ /\n (2) (2)\n\n In compressed sparse representation, the solution looks like this:\n\n >>> from scipy.sparse import csr_matrix\n >>> from scipy.sparse.csgraph import depth_first_tree\n >>> X = csr_matrix([[0, 8, 0, 3],\n ... [0, 0, 2, 5],\n ""... [0, 0, 0, 6],\n ... [0, 0, 0, 0]])\n >>> Tcsr = depth_first_tree(X, 0, directed=False)\n >>> Tcsr.toarray().astype(int)\n array([[0, 8, 0, 0],\n [0, 0, 2, 0],\n [0, 0, 0, 6],\n [0, 0, 0, 0]])\n\n Note that the resulting graph is a Directed Acyclic Graph which spans\n the graph. Unlike a breadth-first tree, a depth-first tree of a given\n graph is not unique if the graph contains cycles. If the above solution\n had begun with the edge connecting nodes 0 and 3, the result would have\n been different.\n ";
static char __pyx_k__B[] = "B";
static char __pyx_k__H[] = "H";
static char __pyx_k__I[] = "I";
static char __pyx_k__L[] = "L";
static char __pyx_k__N[] = "N";
static char __pyx_k__O[] = "O";
static char __pyx_k__Q[] = "Q";
static char __pyx_k__T[] = "T";
static char __pyx_k__b[] = "b";
static char __pyx_k__d[] = "d";
static char __pyx_k__f[] = "f";
static char __pyx_k__g[] = "g";
static char __pyx_k__h[] = "h";
static char __pyx_k__i[] = "i";
static char __pyx_k__l[] = "l";
static char __pyx_k__q[] = "q";
static char __pyx_k__Zd[] = "Zd";
static char __pyx_k__Zf[] = "Zf";
static char __pyx_k__Zg[] = "Zg";
static char __pyx_k__np[] = "np";
static char __pyx_k__fill[] = "fill";
static char __pyx_k__flag[] = "flag";
static char __pyx_k__weak[] = "weak";
static char __pyx_k__DTYPE[] = "DTYPE";
static char __pyx_k__ITYPE[] = "ITYPE";
static char __pyx_k__dtype[] = "dtype";
static char __pyx_k__empty[] = "empty";
static char __pyx_k__int32[] = "int32";
static char __pyx_k__lower[] = "lower";
static char __pyx_k__numpy[] = "numpy";
static char __pyx_k__range[] = "range";
static char __pyx_k__shape[] = "shape";
static char __pyx_k__tocsr[] = "tocsr";
static char __pyx_k__zeros[] = "zeros";
static char __pyx_k__indptr[] = "indptr";
static char __pyx_k__labels[] = "labels";
static char __pyx_k__length[] = "length";
static char __pyx_k__strong[] = "strong";
static char __pyx_k__csgraph[] = "csgraph";
static char __pyx_k__float64[] = "float64";
static char __pyx_k__i_start[] = "i_start";
static char __pyx_k__indices[] = "indices";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__directed[] = "directed";
static char __pyx_k__csgraph_T[] = "csgraph_T";
static char __pyx_k__node_list[] = "node_list";
static char __pyx_k__root_list[] = "root_list";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__connection[] = "connection";
static char __pyx_k__csr_matrix[] = "csr_matrix";
static char __pyx_k__isspmatrix[] = "isspmatrix";
static char __pyx_k__RuntimeError[] = "RuntimeError";
static char __pyx_k__dense_output[] = "dense_output";
static char __pyx_k__n_components[] = "n_components";
static char __pyx_k__predecessors[] = "predecessors";
static char __pyx_k__return_labels[] = "return_labels";
static char __pyx_k__isspmatrix_csc[] = "isspmatrix_csc";
static char __pyx_k__isspmatrix_csr[] = "isspmatrix_csr";
static char __pyx_k__validate_graph[] = "validate_graph";
static char __pyx_k__depth_first_tree[] = "depth_first_tree";
static char __pyx_k__reconstruct_path[] = "reconstruct_path";
static char __pyx_k__depth_first_order[] = "depth_first_order";
static char __pyx_k__breadth_first_tree[] = "breadth_first_tree";
static char __pyx_k__breadth_first_order[] = "breadth_first_order";
static char __pyx_k__return_predecessors[] = "return_predecessors";
static PyObject *__pyx_kp_s_13;
static PyObject *__pyx_kp_s_15;
static PyObject *__pyx_kp_u_17;
static PyObject *__pyx_kp_u_19;
static PyObject *__pyx_kp_u_21;
static PyObject *__pyx_kp_u_23;
static PyObject *__pyx_kp_u_24;
static PyObject *__pyx_kp_u_27;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_n_s_30;
static PyObject *__pyx_n_s_31;
static PyObject *__pyx_n_s_32;
static PyObject *__pyx_n_s_35;
static PyObject *__pyx_kp_s_36;
static PyObject *__pyx_n_s_37;
static PyObject *__pyx_kp_u_46;
static PyObject *__pyx_kp_u_47;
static PyObject *__pyx_kp_u_48;
static PyObject *__pyx_kp_u_49;
static PyObject *__pyx_n_s__DTYPE;
static PyObject *__pyx_n_s__ITYPE;
static PyObject *__pyx_n_s__N;
static PyObject *__pyx_n_s__RuntimeError;
static PyObject *__pyx_n_s__T;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s__breadth_first_order;
static PyObject *__pyx_n_s__breadth_first_tree;
static PyObject *__pyx_n_s__connection;
static PyObject *__pyx_n_s__csgraph;
static PyObject *__pyx_n_s__csgraph_T;
static PyObject *__pyx_n_s__csr_matrix;
static PyObject *__pyx_n_s__dense_output;
static PyObject *__pyx_n_s__depth_first_order;
static PyObject *__pyx_n_s__depth_first_tree;
static PyObject *__pyx_n_s__directed;
static PyObject *__pyx_n_s__dtype;
static PyObject *__pyx_n_s__empty;
static PyObject *__pyx_n_s__fill;
static PyObject *__pyx_n_s__flag;
static PyObject *__pyx_n_s__float64;
static PyObject *__pyx_n_s__i_start;
static PyObject *__pyx_n_s__indices;
static PyObject *__pyx_n_s__indptr;
static PyObject *__pyx_n_s__int32;
static PyObject *__pyx_n_s__isspmatrix;
static PyObject *__pyx_n_s__isspmatrix_csc;
static PyObject *__pyx_n_s__isspmatrix_csr;
static PyObject *__pyx_n_s__labels;
static PyObject *__pyx_n_s__length;
static PyObject *__pyx_n_s__lower;
static PyObject *__pyx_n_s__n_components;
static PyObject *__pyx_n_s__node_list;
static PyObject *__pyx_n_s__np;
static PyObject *__pyx_n_s__numpy;
static PyObject *__pyx_n_s__predecessors;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__reconstruct_path;
static PyObject *__pyx_n_s__return_labels;
static PyObject *__pyx_n_s__return_predecessors;
static PyObject *__pyx_n_s__root_list;
static PyObject *__pyx_n_s__shape;
static PyObject *__pyx_n_s__strong;
static PyObject *__pyx_n_s__tocsr;
static PyObject *__pyx_n_s__validate_graph;
static PyObject *__pyx_n_s__weak;
static PyObject *__pyx_n_s__zeros;
static PyObject *__pyx_int_0;
static PyObject *__pyx_int_neg_1;
static PyObject *__pyx_int_15;
static PyObject *__pyx_k_1;
static PyObject *__pyx_k_2;
static PyObject *__pyx_k_5;
static PyObject *__pyx_k_6;
static PyObject *__pyx_k_7;
static PyObject *__pyx_k_8;
static PyObject *__pyx_k_9;
static PyObject *__pyx_k_10;
static PyObject *__pyx_k_tuple_4;
static PyObject *__pyx_k_tuple_11;
static PyObject *__pyx_k_tuple_12;
static PyObject *__pyx_k_tuple_14;
static PyObject *__pyx_k_tuple_16;
static PyObject *__pyx_k_tuple_18;
static PyObject *__pyx_k_tuple_20;
static PyObject *__pyx_k_tuple_22;
static PyObject *__pyx_k_tuple_25;
static PyObject *__pyx_k_tuple_26;
static PyObject *__pyx_k_tuple_28;
static PyObject *__pyx_k_tuple_33;
static PyObject *__pyx_k_tuple_38;
static PyObject *__pyx_k_tuple_40;
static PyObject *__pyx_k_tuple_42;
static PyObject *__pyx_k_tuple_44;
static PyObject *__pyx_k_codeobj_34;
static PyObject *__pyx_k_codeobj_39;
static PyObject *__pyx_k_codeobj_41;
static PyObject *__pyx_k_codeobj_43;
static PyObject *__pyx_k_codeobj_45;
/* Python wrapper */
static PyObject *__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_1connected_components(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5scipy_6sparse_7csgraph_10_traversal_connected_components[] = "\n connected_components(csgraph, directed=True, connection='weak', return_labels=True)\n\n Analyze the connected components of a sparse graph\n\n Parameters\n ----------\n csgraph: array_like or sparse matrix\n The N x N matrix representing the compressed sparse graph. The input\n csgraph will be converted to csr format for the calculation.\n directed: bool, optional\n if True (default), then operate on a directed graph: only\n move from point i to point j along paths csgraph[i, j].\n if False, then find the shortest path on an undirected graph: the\n algorithm can progress from point i to j along csgraph[i, j] or\n csgraph[j, i].\n connection: string, optional\n ['weak'|'strong']. For directed graphs, the type of connection to\n use. Nodes i and j are strongly connected if a path exists both\n from i to j and from j to i. Nodes i and j are weakly connected if\n only one of these paths exists. If directed == False, this keyword\n is not referenced.\n return_labels: string, optional\n if True (default), then return the labels for each of the connected\n components.\n\n Returns\n -------\n n_components: integer\n The number of connected components.\n labels: ndarray\n The length-N array of labels of the connected components.\n ";
static PyMethodDef __pyx_mdef_5scipy_6sparse_7csgraph_10_traversal_1connected_components = {__Pyx_NAMESTR("connected_components"), (PyCFunction)__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_1connected_components, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5scipy_6sparse_7csgraph_10_traversal_connected_components)};
static PyObject *__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_1connected_components(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_csgraph = 0;
PyObject *__pyx_v_directed = 0;
PyObject *__pyx_v_connection = 0;
PyObject *__pyx_v_return_labels = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("connected_components (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__csgraph,&__pyx_n_s__directed,&__pyx_n_s__connection,&__pyx_n_s__return_labels,0};
PyObject* values[4] = {0,0,0,0};
values[1] = __pyx_k_1;
values[2] = ((PyObject *)__pyx_n_s__weak);
values[3] = __pyx_k_2;
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__csgraph)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__directed);
if (value) { values[1] = value; kw_args--; }
}
case 2:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__connection);
if (value) { values[2] = value; kw_args--; }
}
case 3:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__return_labels);
if (value) { values[3] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "connected_components") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_csgraph = values[0];
__pyx_v_directed = values[1];
__pyx_v_connection = values[2];
__pyx_v_return_labels = values[3];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("connected_components", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("scipy.sparse.csgraph._traversal.connected_components", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_5scipy_6sparse_7csgraph_10_traversal_connected_components(__pyx_self, __pyx_v_csgraph, __pyx_v_directed, __pyx_v_connection, __pyx_v_return_labels);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "scipy/sparse/csgraph/_traversal.pyx":20
* include 'parameters.pxi'
*
* def connected_components(csgraph, directed=True, connection='weak', # <<<<<<<<<<<<<<
* return_labels=True):
* """
*/
static PyObject *__pyx_pf_5scipy_6sparse_7csgraph_10_traversal_connected_components(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csgraph, PyObject *__pyx_v_directed, PyObject *__pyx_v_connection, PyObject *__pyx_v_return_labels) {
PyObject *__pyx_v_labels = NULL;
int __pyx_v_n_components;
PyObject *__pyx_v_csgraph_T = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_t_5;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
PyObject *__pyx_t_8 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("connected_components", 0);
__Pyx_INCREF(__pyx_v_csgraph);
__Pyx_INCREF(__pyx_v_directed);
/* "scipy/sparse/csgraph/_traversal.pyx":55
* The length-N array of labels of the connected components.
* """
* if connection.lower() not in ['weak', 'strong']: # <<<<<<<<<<<<<<
* raise ValueError("connection must be 'weak' or 'strong'")
*
*/
__pyx_t_1 = PyObject_GetAttr(__pyx_v_connection, __pyx_n_s__lower); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__weak), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (((int)__pyx_t_3)) {
__pyx_t_1 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__strong), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_5 = ((int)__pyx_t_4);
} else {
__pyx_t_5 = ((int)__pyx_t_3);
}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_3 = __pyx_t_5;
if (__pyx_t_3) {
/* "scipy/sparse/csgraph/_traversal.pyx":56
* """
* if connection.lower() not in ['weak', 'strong']:
* raise ValueError("connection must be 'weak' or 'strong'") # <<<<<<<<<<<<<<
*
* # weak connections <=> components of undirected graph
*/
__pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_Raise(__pyx_t_2, 0, 0, 0);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
goto __pyx_L3;
}
__pyx_L3:;
/* "scipy/sparse/csgraph/_traversal.pyx":59
*
* # weak connections <=> components of undirected graph
* if connection.lower() == 'weak': # <<<<<<<<<<<<<<
* directed = False
*
*/
__pyx_t_2 = PyObject_GetAttr(__pyx_v_connection, __pyx_n_s__lower); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__weak), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
if (__pyx_t_3) {
/* "scipy/sparse/csgraph/_traversal.pyx":60
* # weak connections <=> components of undirected graph
* if connection.lower() == 'weak':
* directed = False # <<<<<<<<<<<<<<
*
* csgraph = validate_graph(csgraph, directed,
*/
__pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_v_directed);
__pyx_v_directed = __pyx_t_2;
__pyx_t_2 = 0;
goto __pyx_L4;
}
__pyx_L4:;
/* "scipy/sparse/csgraph/_traversal.pyx":62
* directed = False
*
* csgraph = validate_graph(csgraph, directed, # <<<<<<<<<<<<<<
* dense_output=False)
*
*/
__pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__validate_graph); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v_csgraph);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_csgraph);
__Pyx_GIVEREF(__pyx_v_csgraph);
__Pyx_INCREF(__pyx_v_directed);
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_directed);
__Pyx_GIVEREF(__pyx_v_directed);
__pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_6));
/* "scipy/sparse/csgraph/_traversal.pyx":63
*
* csgraph = validate_graph(csgraph, directed,
* dense_output=False) # <<<<<<<<<<<<<<
*
* labels = np.empty(csgraph.shape[0], dtype=ITYPE)
*/
__pyx_t_7 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__dense_output), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_v_csgraph);
__pyx_v_csgraph = __pyx_t_7;
__pyx_t_7 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":65
* dense_output=False)
*
* labels = np.empty(csgraph.shape[0], dtype=ITYPE) # <<<<<<<<<<<<<<
* labels.fill(NULL_IDX)
*
*/
__pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__empty); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__shape); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_1 = __Pyx_GetItemInt(__pyx_t_7, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__ITYPE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__pyx_v_labels = __pyx_t_2;
__pyx_t_2 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":66
*
* labels = np.empty(csgraph.shape[0], dtype=ITYPE)
* labels.fill(NULL_IDX) # <<<<<<<<<<<<<<
*
* if directed:
*/
__pyx_t_2 = PyObject_GetAttr(__pyx_v_labels, __pyx_n_s__fill); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = __Pyx_PyInt_to_py_npy_int32(__pyx_v_5scipy_6sparse_7csgraph_10_traversal_NULL_IDX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":68
* labels.fill(NULL_IDX)
*
* if directed: # <<<<<<<<<<<<<<
* n_components = _connected_components_directed(csgraph.indices,
* csgraph.indptr,
*/
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_directed); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_3) {
/* "scipy/sparse/csgraph/_traversal.pyx":69
*
* if directed:
* n_components = _connected_components_directed(csgraph.indices, # <<<<<<<<<<<<<<
* csgraph.indptr,
* labels)
*/
__pyx_t_1 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__indices); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":70
* if directed:
* n_components = _connected_components_directed(csgraph.indices,
* csgraph.indptr, # <<<<<<<<<<<<<<
* labels)
* else:
*/
__pyx_t_7 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__indptr); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":71
* n_components = _connected_components_directed(csgraph.indices,
* csgraph.indptr,
* labels) # <<<<<<<<<<<<<<
* else:
* csgraph_T = csgraph.T.tocsr()
*/
if (!(likely(((__pyx_v_labels) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_labels, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_2 = __pyx_v_labels;
__Pyx_INCREF(__pyx_t_2);
__pyx_v_n_components = __pyx_f_5scipy_6sparse_7csgraph_10_traversal__connected_components_directed(((PyArrayObject *)__pyx_t_1), ((PyArrayObject *)__pyx_t_7), ((PyArrayObject *)__pyx_t_2));
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
goto __pyx_L5;
}
/*else*/ {
/* "scipy/sparse/csgraph/_traversal.pyx":73
* labels)
* else:
* csgraph_T = csgraph.T.tocsr() # <<<<<<<<<<<<<<
* n_components = _connected_components_undirected(csgraph.indices,
* csgraph.indptr,
*/
__pyx_t_2 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__T); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_7 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__tocsr); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__pyx_v_csgraph_T = __pyx_t_2;
__pyx_t_2 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":74
* else:
* csgraph_T = csgraph.T.tocsr()
* n_components = _connected_components_undirected(csgraph.indices, # <<<<<<<<<<<<<<
* csgraph.indptr,
* csgraph_T.indices,
*/
__pyx_t_2 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__indices); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":75
* csgraph_T = csgraph.T.tocsr()
* n_components = _connected_components_undirected(csgraph.indices,
* csgraph.indptr, # <<<<<<<<<<<<<<
* csgraph_T.indices,
* csgraph_T.indptr,
*/
__pyx_t_7 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__indptr); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":76
* n_components = _connected_components_undirected(csgraph.indices,
* csgraph.indptr,
* csgraph_T.indices, # <<<<<<<<<<<<<<
* csgraph_T.indptr,
* labels)
*/
__pyx_t_1 = PyObject_GetAttr(__pyx_v_csgraph_T, __pyx_n_s__indices); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":77
* csgraph.indptr,
* csgraph_T.indices,
* csgraph_T.indptr, # <<<<<<<<<<<<<<
* labels)
*
*/
__pyx_t_6 = PyObject_GetAttr(__pyx_v_csgraph_T, __pyx_n_s__indptr); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":78
* csgraph_T.indices,
* csgraph_T.indptr,
* labels) # <<<<<<<<<<<<<<
*
* if return_labels:
*/
if (!(likely(((__pyx_v_labels) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_labels, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_8 = __pyx_v_labels;
__Pyx_INCREF(__pyx_t_8);
__pyx_v_n_components = __pyx_f_5scipy_6sparse_7csgraph_10_traversal__connected_components_undirected(((PyArrayObject *)__pyx_t_2), ((PyArrayObject *)__pyx_t_7), ((PyArrayObject *)__pyx_t_1), ((PyArrayObject *)__pyx_t_6), ((PyArrayObject *)__pyx_t_8));
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
}
__pyx_L5:;
/* "scipy/sparse/csgraph/_traversal.pyx":80
* labels)
*
* if return_labels: # <<<<<<<<<<<<<<
* return n_components, labels
* else:
*/
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_return_labels); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_3) {
/* "scipy/sparse/csgraph/_traversal.pyx":81
*
* if return_labels:
* return n_components, labels # <<<<<<<<<<<<<<
* else:
* return n_components
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_8 = PyInt_FromLong(__pyx_v_n_components); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8);
__Pyx_GIVEREF(__pyx_t_8);
__Pyx_INCREF(__pyx_v_labels);
PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_labels);
__Pyx_GIVEREF(__pyx_v_labels);
__pyx_t_8 = 0;
__pyx_r = ((PyObject *)__pyx_t_6);
__pyx_t_6 = 0;
goto __pyx_L0;
goto __pyx_L6;
}
/*else*/ {
/* "scipy/sparse/csgraph/_traversal.pyx":83
* return n_components, labels
* else:
* return n_components # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_6 = PyInt_FromLong(__pyx_v_n_components); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__pyx_r = __pyx_t_6;
__pyx_t_6 = 0;
goto __pyx_L0;
}
__pyx_L6:;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_AddTraceback("scipy.sparse.csgraph._traversal.connected_components", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_labels);
__Pyx_XDECREF(__pyx_v_csgraph_T);
__Pyx_XDECREF(__pyx_v_csgraph);
__Pyx_XDECREF(__pyx_v_directed);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_3breadth_first_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5scipy_6sparse_7csgraph_10_traversal_2breadth_first_tree[] = "\n breadth_first_tree(csgraph, i_start, directed=True)\n\n Return the tree generated by a breadth-first search\n\n Note that a breadth-first tree from a specified node is unique.\n\n Parameters\n ----------\n csgraph: array_like or sparse matrix\n The N x N matrix representing the compressed sparse graph. The input\n csgraph will be converted to csr format for the calculation.\n i_start: int\n The index of starting node.\n directed: bool, optional\n if True (default), then operate on a directed graph: only\n move from point i to point j along paths csgraph[i, j].\n if False, then find the shortest path on an undirected graph: the\n algorithm can progress from point i to j along csgraph[i, j] or\n csgraph[j, i].\n\n Returns\n -------\n cstree : csr matrix\n The N x N directed compressed-sparse representation of the breadth-\n first tree drawn from csgraph, starting at the specified node.\n\n Examples\n --------\n The following example shows the computation of a depth-first tree\n over a simple four-component graph, starting at node 0::\n\n input graph breadth first tree from (0)\n\n (0) (0)\n / \\ / \\\n 3 8 3 8\n / \\ / \\\n (3)---5---(1) (3) (1)\n \\ / /\n 6 2 2\n \\ / /\n (2) (2)\n\n In compressed sparse representation, the solution looks like this:\n\n >>> from scipy.sparse import csr_matrix\n >>> from scipy.sparse.csgraph import breadth_first_tree\n >>> X = csr_matrix([[0, 8, 0, 3],\n ... [0, 0, 2, 5],\n ... [0, 0, 0, 6],\n ... [0, 0, 0,"" 0]])\n >>> Tcsr = breadth_first_tree(X, 0, directed=False)\n >>> Tcsr.toarray().astype(int)\n array([[0, 8, 0, 3],\n [0, 0, 2, 0],\n [0, 0, 0, 0],\n [0, 0, 0, 0]])\n\n Note that the resulting graph is a Directed Acyclic Graph which spans\n the graph. A breadth-first tree from a given node is unique.\n ";
static PyMethodDef __pyx_mdef_5scipy_6sparse_7csgraph_10_traversal_3breadth_first_tree = {__Pyx_NAMESTR("breadth_first_tree"), (PyCFunction)__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_3breadth_first_tree, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5scipy_6sparse_7csgraph_10_traversal_2breadth_first_tree)};
static PyObject *__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_3breadth_first_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_csgraph = 0;
PyObject *__pyx_v_i_start = 0;
PyObject *__pyx_v_directed = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("breadth_first_tree (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__csgraph,&__pyx_n_s__i_start,&__pyx_n_s__directed,0};
PyObject* values[3] = {0,0,0};
values[2] = __pyx_k_5;
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__csgraph)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_start)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("breadth_first_tree", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__directed);
if (value) { values[2] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "breadth_first_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_csgraph = values[0];
__pyx_v_i_start = values[1];
__pyx_v_directed = values[2];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("breadth_first_tree", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("scipy.sparse.csgraph._traversal.breadth_first_tree", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_5scipy_6sparse_7csgraph_10_traversal_2breadth_first_tree(__pyx_self, __pyx_v_csgraph, __pyx_v_i_start, __pyx_v_directed);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "scipy/sparse/csgraph/_traversal.pyx":86
*
*
* def breadth_first_tree(csgraph, i_start, directed=True): # <<<<<<<<<<<<<<
* r"""
* breadth_first_tree(csgraph, i_start, directed=True)
*/
static PyObject *__pyx_pf_5scipy_6sparse_7csgraph_10_traversal_2breadth_first_tree(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csgraph, PyObject *__pyx_v_i_start, PyObject *__pyx_v_directed) {
CYTHON_UNUSED PyObject *__pyx_v_node_list = NULL;
PyObject *__pyx_v_predecessors = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *(*__pyx_t_5)(PyObject *);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("breadth_first_tree", 0);
/* "scipy/sparse/csgraph/_traversal.pyx":149
* the graph. A breadth-first tree from a given node is unique.
* """
* node_list, predecessors = breadth_first_order(csgraph, i_start, # <<<<<<<<<<<<<<
* directed, True)
* return reconstruct_path(csgraph, predecessors, directed)
*/
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__breadth_first_order); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
/* "scipy/sparse/csgraph/_traversal.pyx":150
* """
* node_list, predecessors = breadth_first_order(csgraph, i_start,
* directed, True) # <<<<<<<<<<<<<<
* return reconstruct_path(csgraph, predecessors, directed)
*
*/
__pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(__pyx_v_csgraph);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_csgraph);
__Pyx_GIVEREF(__pyx_v_csgraph);
__Pyx_INCREF(__pyx_v_i_start);
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_i_start);
__Pyx_GIVEREF(__pyx_v_i_start);
__Pyx_INCREF(__pyx_v_directed);
PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_directed);
__Pyx_GIVEREF(__pyx_v_directed);
PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
PyObject* sequence = __pyx_t_2;
#if CYTHON_COMPILING_IN_CPYTHON
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = PySequence_Size(sequence);
#endif
if (unlikely(size != 2)) {
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
#if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
__pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_1 = PyTuple_GET_ITEM(sequence, 1);
} else {
__pyx_t_3 = PyList_GET_ITEM(sequence, 0);
__pyx_t_1 = PyList_GET_ITEM(sequence, 1);
}
__Pyx_INCREF(__pyx_t_3);
__Pyx_INCREF(__pyx_t_1);
#else
__pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
} else
{
Py_ssize_t index = -1;
__pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
__Pyx_GOTREF(__pyx_t_3);
index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
__Pyx_GOTREF(__pyx_t_1);
if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_5 = NULL;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
goto __pyx_L4_unpacking_done;
__pyx_L3_unpacking_failed:;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_5 = NULL;
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L4_unpacking_done:;
}
/* "scipy/sparse/csgraph/_traversal.pyx":149
* the graph. A breadth-first tree from a given node is unique.
* """
* node_list, predecessors = breadth_first_order(csgraph, i_start, # <<<<<<<<<<<<<<
* directed, True)
* return reconstruct_path(csgraph, predecessors, directed)
*/
__pyx_v_node_list = __pyx_t_3;
__pyx_t_3 = 0;
__pyx_v_predecessors = __pyx_t_1;
__pyx_t_1 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":151
* node_list, predecessors = breadth_first_order(csgraph, i_start,
* directed, True)
* return reconstruct_path(csgraph, predecessors, directed) # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__reconstruct_path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v_csgraph);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_csgraph);
__Pyx_GIVEREF(__pyx_v_csgraph);
__Pyx_INCREF(__pyx_v_predecessors);
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_predecessors);
__Pyx_GIVEREF(__pyx_v_predecessors);
__Pyx_INCREF(__pyx_v_directed);
PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_directed);
__Pyx_GIVEREF(__pyx_v_directed);
__pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("scipy.sparse.csgraph._traversal.breadth_first_tree", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_node_list);
__Pyx_XDECREF(__pyx_v_predecessors);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_5depth_first_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5scipy_6sparse_7csgraph_10_traversal_4depth_first_tree[] = "\n depth_first_tree(csgraph, i_start, directed=True)\n\n Return a tree generated by a depth-first search.\n\n Note that a tree generated by a depth-first search is not unique:\n it depends on the order that the children of each node are searched.\n\n Parameters\n ----------\n csgraph: array_like or sparse matrix\n The N x N matrix representing the compressed sparse graph. The input\n csgraph will be converted to csr format for the calculation.\n i_start: int\n The index of starting node.\n directed: bool, optional\n if True (default), then operate on a directed graph: only\n move from point i to point j along paths csgraph[i, j].\n if False, then find the shortest path on an undirected graph: the\n algorithm can progress from point i to j along csgraph[i, j] or\n csgraph[j, i].\n\n Returns\n -------\n cstree : csr matrix\n The N x N directed compressed-sparse representation of the depth-\n first tree drawn from csgraph, starting at the specified node.\n\n Examples\n --------\n The following example shows the computation of a depth-first tree\n over a simple four-component graph, starting at node 0::\n\n input graph depth first tree from (0)\n\n (0) (0)\n / \\ \\\n 3 8 8\n / \\ \\\n (3)---5---(1) (3) (1)\n \\ / \\ /\n 6 2 6 2\n \\ / \\ /\n (2) (2)\n\n In compressed sparse representation, the solution looks like this:\n\n >>> from scipy.sparse import csr_matrix\n >>> from scipy.sparse.csgraph import depth_first_tree\n >>> X = csr_matrix([[0, 8, 0, 3],\n ... [0, 0, 2, 5],\n ""... [0, 0, 0, 6],\n ... [0, 0, 0, 0]])\n >>> Tcsr = depth_first_tree(X, 0, directed=False)\n >>> Tcsr.toarray().astype(int)\n array([[0, 8, 0, 0],\n [0, 0, 2, 0],\n [0, 0, 0, 6],\n [0, 0, 0, 0]])\n\n Note that the resulting graph is a Directed Acyclic Graph which spans\n the graph. Unlike a breadth-first tree, a depth-first tree of a given\n graph is not unique if the graph contains cycles. If the above solution\n had begun with the edge connecting nodes 0 and 3, the result would have\n been different.\n ";
static PyMethodDef __pyx_mdef_5scipy_6sparse_7csgraph_10_traversal_5depth_first_tree = {__Pyx_NAMESTR("depth_first_tree"), (PyCFunction)__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_5depth_first_tree, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5scipy_6sparse_7csgraph_10_traversal_4depth_first_tree)};
static PyObject *__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_5depth_first_tree(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_csgraph = 0;
PyObject *__pyx_v_i_start = 0;
PyObject *__pyx_v_directed = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("depth_first_tree (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__csgraph,&__pyx_n_s__i_start,&__pyx_n_s__directed,0};
PyObject* values[3] = {0,0,0};
values[2] = __pyx_k_6;
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__csgraph)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_start)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("depth_first_tree", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__directed);
if (value) { values[2] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "depth_first_tree") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_csgraph = values[0];
__pyx_v_i_start = values[1];
__pyx_v_directed = values[2];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("depth_first_tree", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("scipy.sparse.csgraph._traversal.depth_first_tree", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_5scipy_6sparse_7csgraph_10_traversal_4depth_first_tree(__pyx_self, __pyx_v_csgraph, __pyx_v_i_start, __pyx_v_directed);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "scipy/sparse/csgraph/_traversal.pyx":154
*
*
* def depth_first_tree(csgraph, i_start, directed=True): # <<<<<<<<<<<<<<
* r"""
* depth_first_tree(csgraph, i_start, directed=True)
*/
static PyObject *__pyx_pf_5scipy_6sparse_7csgraph_10_traversal_4depth_first_tree(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csgraph, PyObject *__pyx_v_i_start, PyObject *__pyx_v_directed) {
CYTHON_UNUSED PyObject *__pyx_v_node_list = NULL;
PyObject *__pyx_v_predecessors = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *(*__pyx_t_5)(PyObject *);
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("depth_first_tree", 0);
/* "scipy/sparse/csgraph/_traversal.pyx":221
* been different.
* """
* node_list, predecessors = depth_first_order(csgraph, i_start, # <<<<<<<<<<<<<<
* directed, True)
* return reconstruct_path(csgraph, predecessors, directed)
*/
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__depth_first_order); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
/* "scipy/sparse/csgraph/_traversal.pyx":222
* """
* node_list, predecessors = depth_first_order(csgraph, i_start,
* directed, True) # <<<<<<<<<<<<<<
* return reconstruct_path(csgraph, predecessors, directed)
*
*/
__pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_INCREF(__pyx_v_csgraph);
PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_csgraph);
__Pyx_GIVEREF(__pyx_v_csgraph);
__Pyx_INCREF(__pyx_v_i_start);
PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_i_start);
__Pyx_GIVEREF(__pyx_v_i_start);
__Pyx_INCREF(__pyx_v_directed);
PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_directed);
__Pyx_GIVEREF(__pyx_v_directed);
PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
PyObject* sequence = __pyx_t_2;
#if CYTHON_COMPILING_IN_CPYTHON
Py_ssize_t size = Py_SIZE(sequence);
#else
Py_ssize_t size = PySequence_Size(sequence);
#endif
if (unlikely(size != 2)) {
if (size > 2) __Pyx_RaiseTooManyValuesError(2);
else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
#if CYTHON_COMPILING_IN_CPYTHON
if (likely(PyTuple_CheckExact(sequence))) {
__pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
__pyx_t_1 = PyTuple_GET_ITEM(sequence, 1);
} else {
__pyx_t_3 = PyList_GET_ITEM(sequence, 0);
__pyx_t_1 = PyList_GET_ITEM(sequence, 1);
}
__Pyx_INCREF(__pyx_t_3);
__Pyx_INCREF(__pyx_t_1);
#else
__pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
#endif
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
} else
{
Py_ssize_t index = -1;
__pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext;
index = 0; __pyx_t_3 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L3_unpacking_failed;
__Pyx_GOTREF(__pyx_t_3);
index = 1; __pyx_t_1 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_1)) goto __pyx_L3_unpacking_failed;
__Pyx_GOTREF(__pyx_t_1);
if (__Pyx_IternextUnpackEndCheck(__pyx_t_5(__pyx_t_4), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_5 = NULL;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
goto __pyx_L4_unpacking_done;
__pyx_L3_unpacking_failed:;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_5 = NULL;
if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_L4_unpacking_done:;
}
/* "scipy/sparse/csgraph/_traversal.pyx":221
* been different.
* """
* node_list, predecessors = depth_first_order(csgraph, i_start, # <<<<<<<<<<<<<<
* directed, True)
* return reconstruct_path(csgraph, predecessors, directed)
*/
__pyx_v_node_list = __pyx_t_3;
__pyx_t_3 = 0;
__pyx_v_predecessors = __pyx_t_1;
__pyx_t_1 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":223
* node_list, predecessors = depth_first_order(csgraph, i_start,
* directed, True)
* return reconstruct_path(csgraph, predecessors, directed) # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__reconstruct_path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v_csgraph);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_csgraph);
__Pyx_GIVEREF(__pyx_v_csgraph);
__Pyx_INCREF(__pyx_v_predecessors);
PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_predecessors);
__Pyx_GIVEREF(__pyx_v_predecessors);
__Pyx_INCREF(__pyx_v_directed);
PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_directed);
__Pyx_GIVEREF(__pyx_v_directed);
__pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("scipy.sparse.csgraph._traversal.depth_first_tree", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF(__pyx_v_node_list);
__Pyx_XDECREF(__pyx_v_predecessors);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_7breadth_first_order(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5scipy_6sparse_7csgraph_10_traversal_6breadth_first_order[] = "\n breadth_first_order(csgraph, i_start, directed=True, return_predecessors=True)\n\n Return a breadth-first ordering starting with specified node.\n\n Note that a breadth-first order is not unique, but the tree which it\n generates is unique.\n\n Parameters\n ----------\n csgraph: array_like or sparse matrix\n The N x N compressed sparse graph. The input csgraph will be\n converted to csr format for the calculation.\n i_start: int\n The index of starting node.\n directed: bool, optional\n If True (default), then operate on a directed graph: only\n move from point i to point j along paths csgraph[i, j].\n If False, then find the shortest path on an undirected graph: the\n algorithm can progress from point i to j along csgraph[i, j] or\n csgraph[j, i].\n return_predecessors: bool, optional\n If True (default), then return the predecesor array (see below).\n\n Returns\n -------\n node_array: ndarray, one dimension\n The breadth-first list of nodes, starting with specified node. The\n length of node_array is the number of nodes reachable from the\n specified node.\n predecessors: ndarray, one dimension\n Returned only if return_predecessors is True.\n The length-N list of predecessors of each node in a breadth-first\n tree. If node i is in the tree, then its parent is given by\n predecessors[i]. If node i is not in the tree (and for the parent\n node) then predecessors[i] = -9999.\n ";
static PyMethodDef __pyx_mdef_5scipy_6sparse_7csgraph_10_traversal_7breadth_first_order = {__Pyx_NAMESTR("breadth_first_order"), (PyCFunction)__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_7breadth_first_order, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5scipy_6sparse_7csgraph_10_traversal_6breadth_first_order)};
static PyObject *__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_7breadth_first_order(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_csgraph = 0;
PyObject *__pyx_v_i_start = 0;
PyObject *__pyx_v_directed = 0;
PyObject *__pyx_v_return_predecessors = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("breadth_first_order (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__csgraph,&__pyx_n_s__i_start,&__pyx_n_s__directed,&__pyx_n_s__return_predecessors,0};
PyObject* values[4] = {0,0,0,0};
values[2] = __pyx_k_7;
values[3] = __pyx_k_8;
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__csgraph)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_start)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("breadth_first_order", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__directed);
if (value) { values[2] = value; kw_args--; }
}
case 3:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__return_predecessors);
if (value) { values[3] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "breadth_first_order") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_csgraph = values[0];
__pyx_v_i_start = values[1];
__pyx_v_directed = values[2];
__pyx_v_return_predecessors = values[3];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("breadth_first_order", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("scipy.sparse.csgraph._traversal.breadth_first_order", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_5scipy_6sparse_7csgraph_10_traversal_6breadth_first_order(__pyx_self, __pyx_v_csgraph, __pyx_v_i_start, __pyx_v_directed, __pyx_v_return_predecessors);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "scipy/sparse/csgraph/_traversal.pyx":226
*
*
* def breadth_first_order(csgraph, i_start, # <<<<<<<<<<<<<<
* directed=True, return_predecessors=True):
* """
*/
static PyObject *__pyx_pf_5scipy_6sparse_7csgraph_10_traversal_6breadth_first_order(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csgraph, PyObject *__pyx_v_i_start, PyObject *__pyx_v_directed, PyObject *__pyx_v_return_predecessors) {
int __pyx_v_N;
PyArrayObject *__pyx_v_node_list = 0;
PyArrayObject *__pyx_v_predecessors = 0;
unsigned int __pyx_v_length;
PyObject *__pyx_v_csgraph_T = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
int __pyx_t_5;
int __pyx_t_6;
unsigned int __pyx_t_7;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("breadth_first_order", 0);
__Pyx_INCREF(__pyx_v_csgraph);
/* "scipy/sparse/csgraph/_traversal.pyx":266
* """
* global NULL_IDX
* csgraph = validate_graph(csgraph, directed, dense_output=False) # <<<<<<<<<<<<<<
* cdef int N = csgraph.shape[0]
*
*/
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__validate_graph); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_v_csgraph);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_csgraph);
__Pyx_GIVEREF(__pyx_v_csgraph);
__Pyx_INCREF(__pyx_v_directed);
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_directed);
__Pyx_GIVEREF(__pyx_v_directed);
__pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
__pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dense_output), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_v_csgraph);
__pyx_v_csgraph = __pyx_t_4;
__pyx_t_4 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":267
* global NULL_IDX
* csgraph = validate_graph(csgraph, directed, dense_output=False)
* cdef int N = csgraph.shape[0] # <<<<<<<<<<<<<<
*
* cdef np.ndarray node_list = np.empty(N, dtype=ITYPE)
*/
__pyx_t_4 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__shape); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_3 = __Pyx_GetItemInt(__pyx_t_4, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_v_N = __pyx_t_5;
/* "scipy/sparse/csgraph/_traversal.pyx":269
* cdef int N = csgraph.shape[0]
*
* cdef np.ndarray node_list = np.empty(N, dtype=ITYPE) # <<<<<<<<<<<<<<
* cdef np.ndarray predecessors = np.empty(N, dtype=ITYPE)
* node_list.fill(NULL_IDX)
*/
__pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__empty); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
__pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ITYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_node_list = ((PyArrayObject *)__pyx_t_1);
__pyx_t_1 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":270
*
* cdef np.ndarray node_list = np.empty(N, dtype=ITYPE)
* cdef np.ndarray predecessors = np.empty(N, dtype=ITYPE) # <<<<<<<<<<<<<<
* node_list.fill(NULL_IDX)
* predecessors.fill(NULL_IDX)
*/
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__ITYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_predecessors = ((PyArrayObject *)__pyx_t_4);
__pyx_t_4 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":271
* cdef np.ndarray node_list = np.empty(N, dtype=ITYPE)
* cdef np.ndarray predecessors = np.empty(N, dtype=ITYPE)
* node_list.fill(NULL_IDX) # <<<<<<<<<<<<<<
* predecessors.fill(NULL_IDX)
*
*/
__pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_node_list), __pyx_n_s__fill); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_1 = __Pyx_PyInt_to_py_npy_int32(__pyx_v_5scipy_6sparse_7csgraph_10_traversal_NULL_IDX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
__pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":272
* cdef np.ndarray predecessors = np.empty(N, dtype=ITYPE)
* node_list.fill(NULL_IDX)
* predecessors.fill(NULL_IDX) # <<<<<<<<<<<<<<
*
* if directed:
*/
__pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_predecessors), __pyx_n_s__fill); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyInt_to_py_npy_int32(__pyx_v_5scipy_6sparse_7csgraph_10_traversal_NULL_IDX); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
__pyx_t_2 = 0;
__pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":274
* predecessors.fill(NULL_IDX)
*
* if directed: # <<<<<<<<<<<<<<
* length = _breadth_first_directed(i_start,
* csgraph.indices, csgraph.indptr,
*/
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_directed); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_6) {
/* "scipy/sparse/csgraph/_traversal.pyx":275
*
* if directed:
* length = _breadth_first_directed(i_start, # <<<<<<<<<<<<<<
* csgraph.indices, csgraph.indptr,
* node_list, predecessors)
*/
__pyx_t_7 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_i_start); if (unlikely((__pyx_t_7 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":276
* if directed:
* length = _breadth_first_directed(i_start,
* csgraph.indices, csgraph.indptr, # <<<<<<<<<<<<<<
* node_list, predecessors)
* else:
*/
__pyx_t_2 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__indices); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_4 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__indptr); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":277
* length = _breadth_first_directed(i_start,
* csgraph.indices, csgraph.indptr,
* node_list, predecessors) # <<<<<<<<<<<<<<
* else:
* csgraph_T = csgraph.T.tocsr()
*/
__pyx_v_length = __pyx_f_5scipy_6sparse_7csgraph_10_traversal__breadth_first_directed(__pyx_t_7, ((PyArrayObject *)__pyx_t_2), ((PyArrayObject *)__pyx_t_4), ((PyArrayObject *)__pyx_v_node_list), ((PyArrayObject *)__pyx_v_predecessors));
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
goto __pyx_L3;
}
/*else*/ {
/* "scipy/sparse/csgraph/_traversal.pyx":279
* node_list, predecessors)
* else:
* csgraph_T = csgraph.T.tocsr() # <<<<<<<<<<<<<<
* length = _breadth_first_undirected(i_start,
* csgraph.indices, csgraph.indptr,
*/
__pyx_t_4 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__T); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__tocsr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v_csgraph_T = __pyx_t_4;
__pyx_t_4 = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":280
* else:
* csgraph_T = csgraph.T.tocsr()
* length = _breadth_first_undirected(i_start, # <<<<<<<<<<<<<<
* csgraph.indices, csgraph.indptr,
* csgraph_T.indices, csgraph_T.indptr,
*/
__pyx_t_7 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_i_start); if (unlikely((__pyx_t_7 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":281
* csgraph_T = csgraph.T.tocsr()
* length = _breadth_first_undirected(i_start,
* csgraph.indices, csgraph.indptr, # <<<<<<<<<<<<<<
* csgraph_T.indices, csgraph_T.indptr,
* node_list, predecessors)
*/
__pyx_t_4 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__indices); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_2 = PyObject_GetAttr(__pyx_v_csgraph, __pyx_n_s__indptr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":282
* length = _breadth_first_undirected(i_start,
* csgraph.indices, csgraph.indptr,
* csgraph_T.indices, csgraph_T.indptr, # <<<<<<<<<<<<<<
* node_list, predecessors)
*
*/
__pyx_t_1 = PyObject_GetAttr(__pyx_v_csgraph_T, __pyx_n_s__indices); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_3 = PyObject_GetAttr(__pyx_v_csgraph_T, __pyx_n_s__indptr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
/* "scipy/sparse/csgraph/_traversal.pyx":283
* csgraph.indices, csgraph.indptr,
* csgraph_T.indices, csgraph_T.indptr,
* node_list, predecessors) # <<<<<<<<<<<<<<
*
* if return_predecessors:
*/
__pyx_v_length = __pyx_f_5scipy_6sparse_7csgraph_10_traversal__breadth_first_undirected(__pyx_t_7, ((PyArrayObject *)__pyx_t_4), ((PyArrayObject *)__pyx_t_2), ((PyArrayObject *)__pyx_t_1), ((PyArrayObject *)__pyx_t_3), ((PyArrayObject *)__pyx_v_node_list), ((PyArrayObject *)__pyx_v_predecessors));
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
}
__pyx_L3:;
/* "scipy/sparse/csgraph/_traversal.pyx":285
* node_list, predecessors)
*
* if return_predecessors: # <<<<<<<<<<<<<<
* return node_list[:length], predecessors
* else:
*/
__pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_return_predecessors); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (__pyx_t_6) {
/* "scipy/sparse/csgraph/_traversal.pyx":286
*
* if return_predecessors:
* return node_list[:length], predecessors # <<<<<<<<<<<<<<
* else:
* return node_list[:length]
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_3 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_node_list), 0, __pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
__Pyx_GIVEREF(__pyx_t_3);
__Pyx_INCREF(((PyObject *)__pyx_v_predecessors));
PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_predecessors));
__Pyx_GIVEREF(((PyObject *)__pyx_v_predecessors));
__pyx_t_3 = 0;
__pyx_r = ((PyObject *)__pyx_t_1);
__pyx_t_1 = 0;
goto __pyx_L0;
goto __pyx_L4;
}
/*else*/ {
/* "scipy/sparse/csgraph/_traversal.pyx":288
* return node_list[:length], predecessors
* else:
* return node_list[:length] # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PySequence_GetSlice(((PyObject *)__pyx_v_node_list), 0, __pyx_v_length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
}
__pyx_L4:;
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("scipy.sparse.csgraph._traversal.breadth_first_order", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
__Pyx_XDECREF((PyObject *)__pyx_v_node_list);
__Pyx_XDECREF((PyObject *)__pyx_v_predecessors);
__Pyx_XDECREF(__pyx_v_csgraph_T);
__Pyx_XDECREF(__pyx_v_csgraph);
__Pyx_XGIVEREF(__pyx_r);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "scipy/sparse/csgraph/_traversal.pyx":291
*
*
* cdef unsigned int _breadth_first_directed( # <<<<<<<<<<<<<<
* unsigned int head_node,
* np.ndarray[ITYPE_t, ndim=1, mode='c'] indices,
*/
static unsigned int __pyx_f_5scipy_6sparse_7csgraph_10_traversal__breadth_first_directed(unsigned int __pyx_v_head_node, PyArrayObject *__pyx_v_indices, PyArrayObject *__pyx_v_indptr, PyArrayObject *__pyx_v_node_list, PyArrayObject *__pyx_v_predecessors) {
unsigned int __pyx_v_i;
unsigned int __pyx_v_pnode;
unsigned int __pyx_v_cnode;
unsigned int __pyx_v_i_nl;
unsigned int __pyx_v_i_nl_end;
CYTHON_UNUSED unsigned int __pyx_v_N;
__Pyx_LocalBuf_ND __pyx_pybuffernd_indices;
__Pyx_Buffer __pyx_pybuffer_indices;
__Pyx_LocalBuf_ND __pyx_pybuffernd_indptr;
__Pyx_Buffer __pyx_pybuffer_indptr;
__Pyx_LocalBuf_ND __pyx_pybuffernd_node_list;
__Pyx_Buffer __pyx_pybuffer_node_list;
__Pyx_LocalBuf_ND __pyx_pybuffernd_predecessors;
__Pyx_Buffer __pyx_pybuffer_predecessors;
unsigned int __pyx_r;
__Pyx_RefNannyDeclarations
long __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
unsigned int __pyx_t_4;
unsigned int __pyx_t_5;
long __pyx_t_6;
__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t __pyx_t_7;
unsigned int __pyx_t_8;
unsigned int __pyx_t_9;
unsigned int __pyx_t_10;
unsigned int __pyx_t_11;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("_breadth_first_directed", 0);
__pyx_pybuffer_indices.pybuffer.buf = NULL;
__pyx_pybuffer_indices.refcount = 0;
__pyx_pybuffernd_indices.data = NULL;
__pyx_pybuffernd_indices.rcbuffer = &__pyx_pybuffer_indices;
__pyx_pybuffer_indptr.pybuffer.buf = NULL;
__pyx_pybuffer_indptr.refcount = 0;
__pyx_pybuffernd_indptr.data = NULL;
__pyx_pybuffernd_indptr.rcbuffer = &__pyx_pybuffer_indptr;
__pyx_pybuffer_node_list.pybuffer.buf = NULL;
__pyx_pybuffer_node_list.refcount = 0;
__pyx_pybuffernd_node_list.data = NULL;
__pyx_pybuffernd_node_list.rcbuffer = &__pyx_pybuffer_node_list;
__pyx_pybuffer_predecessors.pybuffer.buf = NULL;
__pyx_pybuffer_predecessors.refcount = 0;
__pyx_pybuffernd_predecessors.data = NULL;
__pyx_pybuffernd_predecessors.rcbuffer = &__pyx_pybuffer_predecessors;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices, &__Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_pybuffernd_indices.diminfo[0].strides = __pyx_pybuffernd_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices.diminfo[0].shape = __pyx_pybuffernd_indices.rcbuffer->pybuffer.shape[0];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer, (PyObject*)__pyx_v_indptr, &__Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_pybuffernd_indptr.diminfo[0].strides = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indptr.diminfo[0].shape = __pyx_pybuffernd_indptr.rcbuffer->pybuffer.shape[0];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_node_list.rcbuffer->pybuffer, (PyObject*)__pyx_v_node_list, &__Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_pybuffernd_node_list.diminfo[0].strides = __pyx_pybuffernd_node_list.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_node_list.diminfo[0].shape = __pyx_pybuffernd_node_list.rcbuffer->pybuffer.shape[0];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_predecessors.rcbuffer->pybuffer, (PyObject*)__pyx_v_predecessors, &__Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_pybuffernd_predecessors.diminfo[0].strides = __pyx_pybuffernd_predecessors.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_predecessors.diminfo[0].shape = __pyx_pybuffernd_predecessors.rcbuffer->pybuffer.shape[0];
/* "scipy/sparse/csgraph/_traversal.pyx":310
* cdef unsigned int i, pnode, cnode
* cdef unsigned int i_nl, i_nl_end
* cdef unsigned int N = node_list.shape[0] # <<<<<<<<<<<<<<
*
* node_list[0] = head_node
*/
__pyx_v_N = (__pyx_v_node_list->dimensions[0]);
/* "scipy/sparse/csgraph/_traversal.pyx":312
* cdef unsigned int N = node_list.shape[0]
*
* node_list[0] = head_node # <<<<<<<<<<<<<<
* i_nl = 0
* i_nl_end = 1
*/
__pyx_t_1 = 0;
__pyx_t_2 = -1;
if (__pyx_t_1 < 0) {
__pyx_t_1 += __pyx_pybuffernd_node_list.diminfo[0].shape;
if (unlikely(__pyx_t_1 < 0)) __pyx_t_2 = 0;
} else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_node_list.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_node_list.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_node_list.diminfo[0].strides) = __pyx_v_head_node;
/* "scipy/sparse/csgraph/_traversal.pyx":313
*
* node_list[0] = head_node
* i_nl = 0 # <<<<<<<<<<<<<<
* i_nl_end = 1
*
*/
__pyx_v_i_nl = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":314
* node_list[0] = head_node
* i_nl = 0
* i_nl_end = 1 # <<<<<<<<<<<<<<
*
* while i_nl < i_nl_end:
*/
__pyx_v_i_nl_end = 1;
/* "scipy/sparse/csgraph/_traversal.pyx":316
* i_nl_end = 1
*
* while i_nl < i_nl_end: # <<<<<<<<<<<<<<
* pnode = node_list[i_nl]
*
*/
while (1) {
__pyx_t_3 = (__pyx_v_i_nl < __pyx_v_i_nl_end);
if (!__pyx_t_3) break;
/* "scipy/sparse/csgraph/_traversal.pyx":317
*
* while i_nl < i_nl_end:
* pnode = node_list[i_nl] # <<<<<<<<<<<<<<
*
* for i from indptr[pnode] <= i < indptr[pnode + 1]:
*/
__pyx_t_4 = __pyx_v_i_nl;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_4 >= (size_t)__pyx_pybuffernd_node_list.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_pnode = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_node_list.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_node_list.diminfo[0].strides));
/* "scipy/sparse/csgraph/_traversal.pyx":319
* pnode = node_list[i_nl]
*
* for i from indptr[pnode] <= i < indptr[pnode + 1]: # <<<<<<<<<<<<<<
* cnode = indices[i]
* if (cnode == head_node):
*/
__pyx_t_5 = __pyx_v_pnode;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_5 >= (size_t)__pyx_pybuffernd_indptr.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_6 = (__pyx_v_pnode + 1);
__pyx_t_2 = -1;
if (__pyx_t_6 < 0) {
__pyx_t_6 += __pyx_pybuffernd_indptr.diminfo[0].shape;
if (unlikely(__pyx_t_6 < 0)) __pyx_t_2 = 0;
} else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_indptr.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_indptr.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_indptr.diminfo[0].strides));
for (__pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_indptr.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_indptr.diminfo[0].strides)); __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
/* "scipy/sparse/csgraph/_traversal.pyx":320
*
* for i from indptr[pnode] <= i < indptr[pnode + 1]:
* cnode = indices[i] # <<<<<<<<<<<<<<
* if (cnode == head_node):
* continue
*/
__pyx_t_8 = __pyx_v_i;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_8 >= (size_t)__pyx_pybuffernd_indices.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_cnode = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_indices.diminfo[0].strides));
/* "scipy/sparse/csgraph/_traversal.pyx":321
* for i from indptr[pnode] <= i < indptr[pnode + 1]:
* cnode = indices[i]
* if (cnode == head_node): # <<<<<<<<<<<<<<
* continue
* elif (predecessors[cnode] == NULL_IDX):
*/
__pyx_t_3 = (__pyx_v_cnode == __pyx_v_head_node);
if (__pyx_t_3) {
/* "scipy/sparse/csgraph/_traversal.pyx":322
* cnode = indices[i]
* if (cnode == head_node):
* continue # <<<<<<<<<<<<<<
* elif (predecessors[cnode] == NULL_IDX):
* node_list[i_nl_end] = cnode
*/
goto __pyx_L5_continue;
goto __pyx_L7;
}
/* "scipy/sparse/csgraph/_traversal.pyx":323
* if (cnode == head_node):
* continue
* elif (predecessors[cnode] == NULL_IDX): # <<<<<<<<<<<<<<
* node_list[i_nl_end] = cnode
* predecessors[cnode] = pnode
*/
__pyx_t_9 = __pyx_v_cnode;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_9 >= (size_t)__pyx_pybuffernd_predecessors.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = ((*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_predecessors.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_predecessors.diminfo[0].strides)) == __pyx_v_5scipy_6sparse_7csgraph_10_traversal_NULL_IDX);
if (__pyx_t_3) {
/* "scipy/sparse/csgraph/_traversal.pyx":324
* continue
* elif (predecessors[cnode] == NULL_IDX):
* node_list[i_nl_end] = cnode # <<<<<<<<<<<<<<
* predecessors[cnode] = pnode
* i_nl_end += 1
*/
__pyx_t_10 = __pyx_v_i_nl_end;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_10 >= (size_t)__pyx_pybuffernd_node_list.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_node_list.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_node_list.diminfo[0].strides) = __pyx_v_cnode;
/* "scipy/sparse/csgraph/_traversal.pyx":325
* elif (predecessors[cnode] == NULL_IDX):
* node_list[i_nl_end] = cnode
* predecessors[cnode] = pnode # <<<<<<<<<<<<<<
* i_nl_end += 1
*
*/
__pyx_t_11 = __pyx_v_cnode;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_11 >= (size_t)__pyx_pybuffernd_predecessors.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_predecessors.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_predecessors.diminfo[0].strides) = __pyx_v_pnode;
/* "scipy/sparse/csgraph/_traversal.pyx":326
* node_list[i_nl_end] = cnode
* predecessors[cnode] = pnode
* i_nl_end += 1 # <<<<<<<<<<<<<<
*
* i_nl += 1
*/
__pyx_v_i_nl_end = (__pyx_v_i_nl_end + 1);
goto __pyx_L7;
}
__pyx_L7:;
__pyx_L5_continue:;
}
/* "scipy/sparse/csgraph/_traversal.pyx":328
* i_nl_end += 1
*
* i_nl += 1 # <<<<<<<<<<<<<<
*
* return i_nl
*/
__pyx_v_i_nl = (__pyx_v_i_nl + 1);
}
/* "scipy/sparse/csgraph/_traversal.pyx":330
* i_nl += 1
*
* return i_nl # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_i_nl;
goto __pyx_L0;
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_node_list.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_predecessors.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_WriteUnraisable("scipy.sparse.csgraph._traversal._breadth_first_directed", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_node_list.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_predecessors.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "scipy/sparse/csgraph/_traversal.pyx":333
*
*
* cdef unsigned int _breadth_first_undirected( # <<<<<<<<<<<<<<
* unsigned int head_node,
* np.ndarray[ITYPE_t, ndim=1, mode='c'] indices1,
*/
static unsigned int __pyx_f_5scipy_6sparse_7csgraph_10_traversal__breadth_first_undirected(unsigned int __pyx_v_head_node, PyArrayObject *__pyx_v_indices1, PyArrayObject *__pyx_v_indptr1, PyArrayObject *__pyx_v_indices2, PyArrayObject *__pyx_v_indptr2, PyArrayObject *__pyx_v_node_list, PyArrayObject *__pyx_v_predecessors) {
unsigned int __pyx_v_i;
unsigned int __pyx_v_pnode;
unsigned int __pyx_v_cnode;
unsigned int __pyx_v_i_nl;
unsigned int __pyx_v_i_nl_end;
CYTHON_UNUSED unsigned int __pyx_v_N;
__Pyx_LocalBuf_ND __pyx_pybuffernd_indices1;
__Pyx_Buffer __pyx_pybuffer_indices1;
__Pyx_LocalBuf_ND __pyx_pybuffernd_indices2;
__Pyx_Buffer __pyx_pybuffer_indices2;
__Pyx_LocalBuf_ND __pyx_pybuffernd_indptr1;
__Pyx_Buffer __pyx_pybuffer_indptr1;
__Pyx_LocalBuf_ND __pyx_pybuffernd_indptr2;
__Pyx_Buffer __pyx_pybuffer_indptr2;
__Pyx_LocalBuf_ND __pyx_pybuffernd_node_list;
__Pyx_Buffer __pyx_pybuffer_node_list;
__Pyx_LocalBuf_ND __pyx_pybuffernd_predecessors;
__Pyx_Buffer __pyx_pybuffer_predecessors;
unsigned int __pyx_r;
__Pyx_RefNannyDeclarations
long __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
unsigned int __pyx_t_4;
unsigned int __pyx_t_5;
long __pyx_t_6;
__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t __pyx_t_7;
unsigned int __pyx_t_8;
unsigned int __pyx_t_9;
unsigned int __pyx_t_10;
unsigned int __pyx_t_11;
unsigned int __pyx_t_12;
long __pyx_t_13;
unsigned int __pyx_t_14;
unsigned int __pyx_t_15;
unsigned int __pyx_t_16;
unsigned int __pyx_t_17;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("_breadth_first_undirected", 0);
__pyx_pybuffer_indices1.pybuffer.buf = NULL;
__pyx_pybuffer_indices1.refcount = 0;
__pyx_pybuffernd_indices1.data = NULL;
__pyx_pybuffernd_indices1.rcbuffer = &__pyx_pybuffer_indices1;
__pyx_pybuffer_indptr1.pybuffer.buf = NULL;
__pyx_pybuffer_indptr1.refcount = 0;
__pyx_pybuffernd_indptr1.data = NULL;
__pyx_pybuffernd_indptr1.rcbuffer = &__pyx_pybuffer_indptr1;
__pyx_pybuffer_indices2.pybuffer.buf = NULL;
__pyx_pybuffer_indices2.refcount = 0;
__pyx_pybuffernd_indices2.data = NULL;
__pyx_pybuffernd_indices2.rcbuffer = &__pyx_pybuffer_indices2;
__pyx_pybuffer_indptr2.pybuffer.buf = NULL;
__pyx_pybuffer_indptr2.refcount = 0;
__pyx_pybuffernd_indptr2.data = NULL;
__pyx_pybuffernd_indptr2.rcbuffer = &__pyx_pybuffer_indptr2;
__pyx_pybuffer_node_list.pybuffer.buf = NULL;
__pyx_pybuffer_node_list.refcount = 0;
__pyx_pybuffernd_node_list.data = NULL;
__pyx_pybuffernd_node_list.rcbuffer = &__pyx_pybuffer_node_list;
__pyx_pybuffer_predecessors.pybuffer.buf = NULL;
__pyx_pybuffer_predecessors.refcount = 0;
__pyx_pybuffernd_predecessors.data = NULL;
__pyx_pybuffernd_predecessors.rcbuffer = &__pyx_pybuffer_predecessors;
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices1.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices1, &__Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_pybuffernd_indices1.diminfo[0].strides = __pyx_pybuffernd_indices1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices1.diminfo[0].shape = __pyx_pybuffernd_indices1.rcbuffer->pybuffer.shape[0];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr1.rcbuffer->pybuffer, (PyObject*)__pyx_v_indptr1, &__Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_pybuffernd_indptr1.diminfo[0].strides = __pyx_pybuffernd_indptr1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indptr1.diminfo[0].shape = __pyx_pybuffernd_indptr1.rcbuffer->pybuffer.shape[0];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices2.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices2, &__Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_pybuffernd_indices2.diminfo[0].strides = __pyx_pybuffernd_indices2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices2.diminfo[0].shape = __pyx_pybuffernd_indices2.rcbuffer->pybuffer.shape[0];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indptr2.rcbuffer->pybuffer, (PyObject*)__pyx_v_indptr2, &__Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_pybuffernd_indptr2.diminfo[0].strides = __pyx_pybuffernd_indptr2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indptr2.diminfo[0].shape = __pyx_pybuffernd_indptr2.rcbuffer->pybuffer.shape[0];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_node_list.rcbuffer->pybuffer, (PyObject*)__pyx_v_node_list, &__Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_pybuffernd_node_list.diminfo[0].strides = __pyx_pybuffernd_node_list.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_node_list.diminfo[0].shape = __pyx_pybuffernd_node_list.rcbuffer->pybuffer.shape[0];
{
__Pyx_BufFmt_StackElem __pyx_stack[1];
if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_predecessors.rcbuffer->pybuffer, (PyObject*)__pyx_v_predecessors, &__Pyx_TypeInfo_nn___pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_pybuffernd_predecessors.diminfo[0].strides = __pyx_pybuffernd_predecessors.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_predecessors.diminfo[0].shape = __pyx_pybuffernd_predecessors.rcbuffer->pybuffer.shape[0];
/* "scipy/sparse/csgraph/_traversal.pyx":356
* cdef unsigned int i, pnode, cnode
* cdef unsigned int i_nl, i_nl_end
* cdef unsigned int N = node_list.shape[0] # <<<<<<<<<<<<<<
*
* node_list[0] = head_node
*/
__pyx_v_N = (__pyx_v_node_list->dimensions[0]);
/* "scipy/sparse/csgraph/_traversal.pyx":358
* cdef unsigned int N = node_list.shape[0]
*
* node_list[0] = head_node # <<<<<<<<<<<<<<
* i_nl = 0
* i_nl_end = 1
*/
__pyx_t_1 = 0;
__pyx_t_2 = -1;
if (__pyx_t_1 < 0) {
__pyx_t_1 += __pyx_pybuffernd_node_list.diminfo[0].shape;
if (unlikely(__pyx_t_1 < 0)) __pyx_t_2 = 0;
} else if (unlikely(__pyx_t_1 >= __pyx_pybuffernd_node_list.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_node_list.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_node_list.diminfo[0].strides) = __pyx_v_head_node;
/* "scipy/sparse/csgraph/_traversal.pyx":359
*
* node_list[0] = head_node
* i_nl = 0 # <<<<<<<<<<<<<<
* i_nl_end = 1
*
*/
__pyx_v_i_nl = 0;
/* "scipy/sparse/csgraph/_traversal.pyx":360
* node_list[0] = head_node
* i_nl = 0
* i_nl_end = 1 # <<<<<<<<<<<<<<
*
* while i_nl < i_nl_end:
*/
__pyx_v_i_nl_end = 1;
/* "scipy/sparse/csgraph/_traversal.pyx":362
* i_nl_end = 1
*
* while i_nl < i_nl_end: # <<<<<<<<<<<<<<
* pnode = node_list[i_nl]
*
*/
while (1) {
__pyx_t_3 = (__pyx_v_i_nl < __pyx_v_i_nl_end);
if (!__pyx_t_3) break;
/* "scipy/sparse/csgraph/_traversal.pyx":363
*
* while i_nl < i_nl_end:
* pnode = node_list[i_nl] # <<<<<<<<<<<<<<
*
* for i from indptr1[pnode] <= i < indptr1[pnode + 1]:
*/
__pyx_t_4 = __pyx_v_i_nl;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_4 >= (size_t)__pyx_pybuffernd_node_list.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_pnode = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_node_list.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_node_list.diminfo[0].strides));
/* "scipy/sparse/csgraph/_traversal.pyx":365
* pnode = node_list[i_nl]
*
* for i from indptr1[pnode] <= i < indptr1[pnode + 1]: # <<<<<<<<<<<<<<
* cnode = indices1[i]
* if (cnode == head_node):
*/
__pyx_t_5 = __pyx_v_pnode;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_5 >= (size_t)__pyx_pybuffernd_indptr1.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_6 = (__pyx_v_pnode + 1);
__pyx_t_2 = -1;
if (__pyx_t_6 < 0) {
__pyx_t_6 += __pyx_pybuffernd_indptr1.diminfo[0].shape;
if (unlikely(__pyx_t_6 < 0)) __pyx_t_2 = 0;
} else if (unlikely(__pyx_t_6 >= __pyx_pybuffernd_indptr1.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_indptr1.rcbuffer->pybuffer.buf, __pyx_t_6, __pyx_pybuffernd_indptr1.diminfo[0].strides));
for (__pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_indptr1.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_indptr1.diminfo[0].strides)); __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
/* "scipy/sparse/csgraph/_traversal.pyx":366
*
* for i from indptr1[pnode] <= i < indptr1[pnode + 1]:
* cnode = indices1[i] # <<<<<<<<<<<<<<
* if (cnode == head_node):
* continue
*/
__pyx_t_8 = __pyx_v_i;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_8 >= (size_t)__pyx_pybuffernd_indices1.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_cnode = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_indices1.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_indices1.diminfo[0].strides));
/* "scipy/sparse/csgraph/_traversal.pyx":367
* for i from indptr1[pnode] <= i < indptr1[pnode + 1]:
* cnode = indices1[i]
* if (cnode == head_node): # <<<<<<<<<<<<<<
* continue
* elif (predecessors[cnode] == NULL_IDX):
*/
__pyx_t_3 = (__pyx_v_cnode == __pyx_v_head_node);
if (__pyx_t_3) {
/* "scipy/sparse/csgraph/_traversal.pyx":368
* cnode = indices1[i]
* if (cnode == head_node):
* continue # <<<<<<<<<<<<<<
* elif (predecessors[cnode] == NULL_IDX):
* node_list[i_nl_end] = cnode
*/
goto __pyx_L5_continue;
goto __pyx_L7;
}
/* "scipy/sparse/csgraph/_traversal.pyx":369
* if (cnode == head_node):
* continue
* elif (predecessors[cnode] == NULL_IDX): # <<<<<<<<<<<<<<
* node_list[i_nl_end] = cnode
* predecessors[cnode] = pnode
*/
__pyx_t_9 = __pyx_v_cnode;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_9 >= (size_t)__pyx_pybuffernd_predecessors.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = ((*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_predecessors.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_predecessors.diminfo[0].strides)) == __pyx_v_5scipy_6sparse_7csgraph_10_traversal_NULL_IDX);
if (__pyx_t_3) {
/* "scipy/sparse/csgraph/_traversal.pyx":370
* continue
* elif (predecessors[cnode] == NULL_IDX):
* node_list[i_nl_end] = cnode # <<<<<<<<<<<<<<
* predecessors[cnode] = pnode
* i_nl_end += 1
*/
__pyx_t_10 = __pyx_v_i_nl_end;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_10 >= (size_t)__pyx_pybuffernd_node_list.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_node_list.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_node_list.diminfo[0].strides) = __pyx_v_cnode;
/* "scipy/sparse/csgraph/_traversal.pyx":371
* elif (predecessors[cnode] == NULL_IDX):
* node_list[i_nl_end] = cnode
* predecessors[cnode] = pnode # <<<<<<<<<<<<<<
* i_nl_end += 1
*
*/
__pyx_t_11 = __pyx_v_cnode;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_11 >= (size_t)__pyx_pybuffernd_predecessors.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_predecessors.rcbuffer->pybuffer.buf, __pyx_t_11, __pyx_pybuffernd_predecessors.diminfo[0].strides) = __pyx_v_pnode;
/* "scipy/sparse/csgraph/_traversal.pyx":372
* node_list[i_nl_end] = cnode
* predecessors[cnode] = pnode
* i_nl_end += 1 # <<<<<<<<<<<<<<
*
* for i from indptr2[pnode] <= i < indptr2[pnode + 1]:
*/
__pyx_v_i_nl_end = (__pyx_v_i_nl_end + 1);
goto __pyx_L7;
}
__pyx_L7:;
__pyx_L5_continue:;
}
/* "scipy/sparse/csgraph/_traversal.pyx":374
* i_nl_end += 1
*
* for i from indptr2[pnode] <= i < indptr2[pnode + 1]: # <<<<<<<<<<<<<<
* cnode = indices2[i]
* if (cnode == head_node):
*/
__pyx_t_12 = __pyx_v_pnode;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_12 >= (size_t)__pyx_pybuffernd_indptr2.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_13 = (__pyx_v_pnode + 1);
__pyx_t_2 = -1;
if (__pyx_t_13 < 0) {
__pyx_t_13 += __pyx_pybuffernd_indptr2.diminfo[0].shape;
if (unlikely(__pyx_t_13 < 0)) __pyx_t_2 = 0;
} else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_indptr2.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_7 = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_indptr2.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_indptr2.diminfo[0].strides));
for (__pyx_v_i = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_indptr2.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_indptr2.diminfo[0].strides)); __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
/* "scipy/sparse/csgraph/_traversal.pyx":375
*
* for i from indptr2[pnode] <= i < indptr2[pnode + 1]:
* cnode = indices2[i] # <<<<<<<<<<<<<<
* if (cnode == head_node):
* continue
*/
__pyx_t_14 = __pyx_v_i;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_14 >= (size_t)__pyx_pybuffernd_indices2.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_v_cnode = (*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_indices2.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_indices2.diminfo[0].strides));
/* "scipy/sparse/csgraph/_traversal.pyx":376
* for i from indptr2[pnode] <= i < indptr2[pnode + 1]:
* cnode = indices2[i]
* if (cnode == head_node): # <<<<<<<<<<<<<<
* continue
* elif (predecessors[cnode] == NULL_IDX):
*/
__pyx_t_3 = (__pyx_v_cnode == __pyx_v_head_node);
if (__pyx_t_3) {
/* "scipy/sparse/csgraph/_traversal.pyx":377
* cnode = indices2[i]
* if (cnode == head_node):
* continue # <<<<<<<<<<<<<<
* elif (predecessors[cnode] == NULL_IDX):
* node_list[i_nl_end] = cnode
*/
goto __pyx_L8_continue;
goto __pyx_L10;
}
/* "scipy/sparse/csgraph/_traversal.pyx":378
* if (cnode == head_node):
* continue
* elif (predecessors[cnode] == NULL_IDX): # <<<<<<<<<<<<<<
* node_list[i_nl_end] = cnode
* predecessors[cnode] = pnode
*/
__pyx_t_15 = __pyx_v_cnode;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_15 >= (size_t)__pyx_pybuffernd_predecessors.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_3 = ((*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_predecessors.rcbuffer->pybuffer.buf, __pyx_t_15, __pyx_pybuffernd_predecessors.diminfo[0].strides)) == __pyx_v_5scipy_6sparse_7csgraph_10_traversal_NULL_IDX);
if (__pyx_t_3) {
/* "scipy/sparse/csgraph/_traversal.pyx":379
* continue
* elif (predecessors[cnode] == NULL_IDX):
* node_list[i_nl_end] = cnode # <<<<<<<<<<<<<<
* predecessors[cnode] = pnode
* i_nl_end += 1
*/
__pyx_t_16 = __pyx_v_i_nl_end;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_16 >= (size_t)__pyx_pybuffernd_node_list.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_node_list.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_node_list.diminfo[0].strides) = __pyx_v_cnode;
/* "scipy/sparse/csgraph/_traversal.pyx":380
* elif (predecessors[cnode] == NULL_IDX):
* node_list[i_nl_end] = cnode
* predecessors[cnode] = pnode # <<<<<<<<<<<<<<
* i_nl_end += 1
*
*/
__pyx_t_17 = __pyx_v_cnode;
__pyx_t_2 = -1;
if (unlikely(__pyx_t_17 >= (size_t)__pyx_pybuffernd_predecessors.diminfo[0].shape)) __pyx_t_2 = 0;
if (unlikely(__pyx_t_2 != -1)) {
__Pyx_RaiseBufferIndexError(__pyx_t_2);
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
*__Pyx_BufPtrCContig1d(__pyx_t_5scipy_6sparse_7csgraph_10_traversal_ITYPE_t *, __pyx_pybuffernd_predecessors.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_predecessors.diminfo[0].strides) = __pyx_v_pnode;
/* "scipy/sparse/csgraph/_traversal.pyx":381
* node_list[i_nl_end] = cnode
* predecessors[cnode] = pnode
* i_nl_end += 1 # <<<<<<<<<<<<<<
*
* i_nl += 1
*/
__pyx_v_i_nl_end = (__pyx_v_i_nl_end + 1);
goto __pyx_L10;
}
__pyx_L10:;
__pyx_L8_continue:;
}
/* "scipy/sparse/csgraph/_traversal.pyx":383
* i_nl_end += 1
*
* i_nl += 1 # <<<<<<<<<<<<<<
*
* return i_nl
*/
__pyx_v_i_nl = (__pyx_v_i_nl + 1);
}
/* "scipy/sparse/csgraph/_traversal.pyx":385
* i_nl += 1
*
* return i_nl # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_i_nl;
goto __pyx_L0;
__pyx_r = 0;
goto __pyx_L0;
__pyx_L1_error:;
{ PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices1.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices2.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr1.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr2.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_node_list.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_predecessors.rcbuffer->pybuffer);
__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
__Pyx_WriteUnraisable("scipy.sparse.csgraph._traversal._breadth_first_undirected", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = 0;
goto __pyx_L2;
__pyx_L0:;
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices1.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices2.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr1.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indptr2.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_node_list.rcbuffer->pybuffer);
__Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_predecessors.rcbuffer->pybuffer);
__pyx_L2:;
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* Python wrapper */
static PyObject *__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_9depth_first_order(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_5scipy_6sparse_7csgraph_10_traversal_8depth_first_order[] = "\n depth_first_order(csgraph, i_start, directed=True, return_predecessors=True)\n\n Return a depth-first ordering starting with specified node.\n\n Note that a depth-first order is not unique. Furthermore, for graphs\n with cycles, the tree generated by a depth-first search is not\n unique either.\n\n Parameters\n ----------\n csgraph: array_like or sparse matrix\n The N x N compressed sparse graph. The input csgraph will be\n converted to csr format for the calculation.\n i_start: int\n The index of starting node.\n directed: bool, optional\n If True (default), then operate on a directed graph: only\n move from point i to point j along paths csgraph[i, j].\n If False, then find the shortest path on an undirected graph: the\n algorithm can progress from point i to j along csgraph[i, j] or\n csgraph[j, i].\n return_predecessors: bool, optional\n If True (default), then return the predecesor array (see below).\n\n Returns\n -------\n node_array: ndarray, one dimension\n The breadth-first list of nodes, starting with specified node. The\n length of node_array is the number of nodes reachable from the\n specified node.\n predecessors: ndarray, one dimension\n Returned only if return_predecessors is True.\n The length-N list of predecessors of each node in a breadth-first\n tree. If node i is in the tree, then its parent is given by\n predecessors[i]. If node i is not in the tree (and for the parent\n node) then predecessors[i] = -9999.\n ";
static PyMethodDef __pyx_mdef_5scipy_6sparse_7csgraph_10_traversal_9depth_first_order = {__Pyx_NAMESTR("depth_first_order"), (PyCFunction)__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_9depth_first_order, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5scipy_6sparse_7csgraph_10_traversal_8depth_first_order)};
static PyObject *__pyx_pw_5scipy_6sparse_7csgraph_10_traversal_9depth_first_order(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_csgraph = 0;
PyObject *__pyx_v_i_start = 0;
PyObject *__pyx_v_directed = 0;
PyObject *__pyx_v_return_predecessors = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("depth_first_order (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__csgraph,&__pyx_n_s__i_start,&__pyx_n_s__directed,&__pyx_n_s__return_predecessors,0};
PyObject* values[4] = {0,0,0,0};
values[2] = __pyx_k_9;
values[3] = __pyx_k_10;
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__csgraph)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
case 1:
if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i_start)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("depth_first_order", 0, 2, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__directed);
if (value) { values[2] = value; kw_args--; }
}
case 3:
if (kw_args > 0) {
PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__return_predecessors);
if (value) { values[3] = value; kw_args--; }
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "depth_first_order") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
break;
default: goto __pyx_L5_argtuple_error;
}
}
__pyx_v_csgraph = values[0];
__pyx_v_i_start = values[1];
__pyx_v_directed = values[2];
__pyx_v_return_predecessors = values[3];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("depth_first_order", 0, 2, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("scipy.sparse.csgraph._traversal.depth_first_order", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_5scipy_6sparse_7csgraph_10_traversal_8depth_first_order(__pyx_self, __pyx_v_csgraph, __pyx_v_i_start, __pyx_v_directed, __pyx_v_return_predecessors);
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
/* "scipy/sparse/csgraph/_traversal.pyx":388
*
*
* def depth_first_order(csgraph, i_start, # <<<<<<<<<<<<<<
* directed=True, return_predecessors=True):
* """
*/
static PyObject *__pyx_pf_5scipy_6sparse_7csgraph_10_traversal_8depth_first_order(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_csgraph, PyObject *__pyx_v_i_start, PyObject *__pyx_v_directed, PyObject *__pyx_v_return_predecessors) {
int __pyx_v_N;
PyObject *__pyx_v_node_list = NULL;
PyObject *__pyx_v_predecessors = NULL;
PyObject *__pyx_v_root_list = NULL;
PyObject *__pyx_v_flag = NULL;
unsigned int __pyx_v_length;
PyObject *__pyx_v_csgraph_T = NULL;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
int __pyx_t_5;
int __pyx_t_6;
unsigned int __pyx_t_7;
PyObject *__pyx_t_8 = NULL;
PyObject *__pyx_t_9 = NULL;
PyObject *__pyx_t_10 = NULL;
PyObject *__pyx_t_11 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("depth_first_order", 0);
__Pyx_INCREF(__pyx_v_csgraph);
/* "scipy/sparse/csgraph/_traversal.pyx":429
* """
* global NULL_IDX
* csgraph = validate_graph(csgraph, directed, dense_output=False) # <<<<<<<<<<<<<<
* cdef int N = csgraph.shape[0]
*
*/
__pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__validate_graph); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(__pyx_v_csgraph);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_csgraph);
__Pyx_GIVEREF(__pyx_v_csgraph);
__Pyx_INCREF(__pyx_v_directed);
PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_directed);
__Pyx_GIVEREF(__pyx_v_directed);
__pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
__pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__dense_output), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}