├── igraph ├── src │ ├── dummy.c │ ├── ctype.c │ ├── prpack_result.cpp │ ├── qsort_r.c │ ├── r_imag.c │ ├── d_imag.c │ ├── i_len.c │ ├── d_prod.c │ ├── h_len.c │ ├── h_mod.c │ ├── i_mod.c │ ├── r_dim.c │ ├── r_abs.c │ ├── i_abs.c │ ├── d_abs.c │ ├── h_abs.c │ ├── i_dim.c │ ├── d_dim.c │ ├── h_dim.c │ ├── r_cos.c │ ├── r_exp.c │ ├── r_log.c │ ├── r_sin.c │ ├── r_tan.c │ ├── derf_.c │ ├── r_acos.c │ ├── r_asin.c │ ├── r_atan.c │ ├── r_cosh.c │ ├── r_sinh.c │ ├── r_sqrt.c │ ├── r_tanh.c │ ├── d_cos.c │ ├── d_exp.c │ ├── d_log.c │ ├── d_sin.c │ ├── d_tan.c │ ├── r_cnjg.c │ ├── r_sign.c │ ├── d_acos.c │ ├── d_asin.c │ ├── d_atan.c │ ├── d_cosh.c │ ├── d_sinh.c │ ├── d_sqrt.c │ ├── d_tanh.c │ ├── lbitshft.c │ ├── r_atn2.c │ ├── d_cnjg.c │ ├── derfc_.c │ ├── i_sign.c │ ├── r_int.c │ ├── d_sign.c │ ├── h_sign.c │ ├── z_abs.c │ ├── d_int.c │ ├── d_atn2.c │ ├── i_nint.c │ ├── pow_dd.c │ ├── r_nint.c │ ├── erf_.c │ ├── h_nint.c │ ├── c_abs.c │ ├── d_nint.c │ ├── erfc_.c │ ├── i_dnnt.c │ ├── r_lg10.c │ ├── h_dnnt.c │ ├── d_lg10.c │ ├── signal_.c │ ├── abort_.c │ ├── l_ge.c │ ├── l_gt.c │ ├── l_le.c │ ├── l_lt.c │ ├── hl_ge.c │ ├── hl_gt.c │ ├── hl_le.c │ ├── hl_lt.c │ ├── signbit.c │ ├── z_sin.c │ ├── z_cos.c │ ├── z_exp.c │ ├── c_sin.c │ ├── c_cos.c │ ├── typesize.c │ ├── c_exp.c │ ├── c_log.c │ ├── ef1cmc_.c │ ├── pow_ci.c │ ├── i_indx.c │ ├── dolio.c │ ├── h_indx.c │ ├── rewind.c │ ├── wsne.c │ ├── pow_ri.c │ ├── ef1asc_.c │ ├── pow_di.c │ ├── cabs.c │ ├── pow_ii.c │ ├── pow_hh.c │ ├── pow_zz.c │ ├── exit_.c │ ├── z_sqrt.c │ ├── c_sqrt.c │ ├── system_.c │ ├── f77_aloc.c │ ├── r_mod.c │ ├── wsle.c │ ├── d_mod.c │ ├── s_rnge.c │ ├── sig_die.c │ ├── s_cmp.c │ ├── s_stop.c │ ├── sfe.c │ ├── len_trim.c │ ├── fmtlib.c │ ├── etime_.c │ ├── pow_zi.c │ ├── ftell_.c │ ├── z_div.c │ ├── c_div.c │ ├── util.c │ ├── defs.cc │ ├── cs_dropzeros.c │ ├── platform.c │ ├── dtime_.c │ ├── cs_droptol.c │ ├── second.c │ ├── s_copy.c │ ├── cs_ipvec.c │ ├── cs_pvec.c │ ├── lbitbits.c │ ├── cs_entry.c │ ├── cs_gaxpy.c │ ├── cs_pinv.c │ ├── getenv_.c │ ├── ilnw.c │ ├── cs_norm.c │ ├── xwsne.c │ ├── fortran_intrinsics.c │ ├── cs_lsolve.c │ ├── cs_usolve.c │ ├── cs_ltsolve.c │ ├── cs_utsolve.c │ ├── array.c │ ├── cs_cumsum.c │ ├── wsfe.c │ ├── interrupt.c │ ├── cs_happly.c │ ├── backspac.c │ ├── prpack_utils.cpp │ ├── dqueue.c │ ├── cs_reach.c │ ├── cs_load.c │ ├── s_cat.c │ ├── hacks.c │ ├── rsfe.c │ ├── uio.c │ ├── cs_cholsol.c │ ├── close.c │ ├── cs_lusol.c │ └── due.c ├── AUTHORS └── include │ ├── arith.h │ ├── prpack │ ├── prpack.h │ ├── prpack_csr.h │ ├── prpack_edge_list.h │ ├── prpack_preprocessed_graph.h │ ├── prpack_igraph_graph.h │ ├── prpack_csc.h │ ├── prpack_result.h │ ├── prpack_preprocessed_ge_graph.h │ ├── prpack_preprocessed_gs_graph.h │ ├── prpack_preprocessed_schur_graph.h │ ├── prpack_utils.h │ ├── prpack_preprocessed_scc_graph.h │ └── prpack_base_graph.h │ ├── igraph_lsap.h │ ├── igraph_handle_exceptions.h │ ├── igraph_decls.h │ ├── f2c │ ├── fp.h │ ├── signal1.h │ ├── sysdep1.h │ └── lio.h │ ├── cliquer │ ├── reorder.h │ └── misc.h │ ├── foreign-gml-header.h │ ├── config.h │ ├── igraph_vector_type.h │ ├── foreign-ncol-header.h │ ├── foreign-lgl-header.h │ ├── igraph_threading.h │ ├── igraph_threading.h.in │ ├── igraph_cliquer.h │ ├── plfit │ ├── kolmogorov.h │ └── platform.h │ ├── igraph_qsort.h │ ├── igraph_version.h │ ├── foreign-dl-header.h │ ├── igraph_cohesive_blocks.h │ ├── foreign-pajek-header.h │ ├── infomap_Node.h │ ├── igraph_version.h.in │ ├── igraph_memory.h │ ├── igraph_coloring.h │ ├── igraph_glpk_support.h │ ├── igraph_flow_internal.h │ ├── igraph_estack.h │ ├── igraph_hacks_internal.h │ ├── igraph_heap_pmt.h │ ├── structural_properties_internal.h │ ├── igraph_array.h │ ├── prpack.h │ └── igraph_mixing.h ├── Setup.hs ├── README.md ├── cbits ├── haskell_igraph.h └── haskell_igraph.c ├── stack.yaml ├── .gitignore ├── src └── IGraph │ ├── Internal │ ├── Initialization.chs │ └── Constants.chs │ ├── Random.hs │ ├── Algorithms.hs │ └── Types.hs ├── tests ├── test.hs └── Test │ ├── Utils.hs │ └── Attributes.hs ├── LICENSE └── ChangeLog.md /igraph/src/dummy.c: -------------------------------------------------------------------------------- 1 | 2 | int MAIN__(void) { return 0; } 3 | -------------------------------------------------------------------------------- /Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /igraph/src/ctype.c: -------------------------------------------------------------------------------- 1 | #define My_ctype_DEF 2 | #include "ctype.h" 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Haskell bindings to igraph C library 2 | ==================================== 3 | -------------------------------------------------------------------------------- /cbits/haskell_igraph.h: -------------------------------------------------------------------------------- 1 | #ifndef HASKELL_IGRAPH 2 | #define HASKELL_IGRAPH 3 | 4 | #include "igraph.h" 5 | 6 | void haskelligraph_init(); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /stack.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - '.' 3 | 4 | resolver: 5 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/17/10.yaml 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | cabal-dev 3 | *.o 4 | *.hi 5 | *.chi 6 | *.chs.h 7 | *.swp 8 | .virtualenv 9 | .hsenv 10 | .cabal-sandbox/ 11 | cabal.sandbox.config 12 | cabal.config 13 | -------------------------------------------------------------------------------- /igraph/AUTHORS: -------------------------------------------------------------------------------- 1 | Gabor Csardi 2 | Tamas Nepusz 3 | Szabolcs Horvat 4 | Vincent Traag 5 | Fabio Zanini 6 | 7 | -------------------------------------------------------------------------------- /igraph/include/arith.h: -------------------------------------------------------------------------------- 1 | #define IEEE_8087 2 | #define Arith_Kind_ASL 1 3 | #define Long int 4 | #define Intcast (int)(long) 5 | #define Double_Align 6 | #define X64_bit_pointers 7 | #define NANCHECK 8 | #define QNaN0 0x0 9 | #define QNaN1 0xfff80000 10 | -------------------------------------------------------------------------------- /igraph/src/prpack_result.cpp: -------------------------------------------------------------------------------- 1 | #include "prpack_result.h" 2 | #include 3 | using namespace prpack; 4 | 5 | prpack_result::prpack_result() { 6 | x = NULL; 7 | } 8 | 9 | prpack_result::~prpack_result() { 10 | delete[] x; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /igraph/src/qsort_r.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is in the public domain. Originally written by Garrett 3 | * A. Wollman. 4 | * 5 | * $FreeBSD: src/lib/libc/stdlib/qsort_r.c,v 1.1 2002/09/10 02:04:49 wollman Exp $ 6 | */ 7 | #define I_AM_QSORT_R 8 | #include "qsort.c" 9 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK 2 | #define PRPACK 3 | 4 | #include "prpack_csc.h" 5 | #include "prpack_csr.h" 6 | #include "prpack_edge_list.h" 7 | #include "prpack_base_graph.h" 8 | #include "prpack_solver.h" 9 | #include "prpack_result.h" 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /igraph/src/r_imag.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double r_imag(z) f2c_complex *z; 8 | #else 9 | double r_imag(f2c_complex *z) 10 | #endif 11 | { 12 | return(z->i); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/d_imag.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double d_imag(z) doublecomplex *z; 8 | #else 9 | double d_imag(doublecomplex *z) 10 | #endif 11 | { 12 | return(z->i); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/i_len.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_len(s, n) char *s; ftnlen n; 8 | #else 9 | integer i_len(char *s, ftnlen n) 10 | #endif 11 | { 12 | return(n); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/d_prod.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double d_prod(x,y) real *x, *y; 8 | #else 9 | double d_prod(real *x, real *y) 10 | #endif 11 | { 12 | return( (*x) * (*y) ); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/h_len.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_len(s, n) char *s; ftnlen n; 8 | #else 9 | shortint h_len(char *s, ftnlen n) 10 | #endif 11 | { 12 | return(n); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/h_mod.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_mod(a,b) short *a, *b; 8 | #else 9 | shortint h_mod(short *a, short *b) 10 | #endif 11 | { 12 | return( *a % *b); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/i_mod.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_mod(a,b) integer *a, *b; 8 | #else 9 | integer i_mod(integer *a, integer *b) 10 | #endif 11 | { 12 | return( *a % *b); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/r_dim.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double r_dim(a,b) real *a, *b; 8 | #else 9 | double r_dim(real *a, real *b) 10 | #endif 11 | { 12 | return( *a > *b ? *a - *b : 0); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/r_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double r_abs(x) real *x; 8 | #else 9 | double r_abs(real *x) 10 | #endif 11 | { 12 | if(*x >= 0) 13 | return(*x); 14 | return(- *x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/i_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_abs(x) integer *x; 8 | #else 9 | integer i_abs(integer *x) 10 | #endif 11 | { 12 | if(*x >= 0) 13 | return(*x); 14 | return(- *x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_csr.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_CSR 2 | #define PRPACK_CSR 3 | 4 | namespace prpack { 5 | 6 | class prpack_csr { 7 | public: 8 | int num_vs; 9 | int num_es; 10 | int* heads; 11 | int* tails; 12 | }; 13 | 14 | } 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/d_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double d_abs(x) doublereal *x; 8 | #else 9 | double d_abs(doublereal *x) 10 | #endif 11 | { 12 | if(*x >= 0) 13 | return(*x); 14 | return(- *x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/h_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_abs(x) shortint *x; 8 | #else 9 | shortint h_abs(shortint *x) 10 | #endif 11 | { 12 | if(*x >= 0) 13 | return(*x); 14 | return(- *x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/i_dim.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_dim(a,b) integer *a, *b; 8 | #else 9 | integer i_dim(integer *a, integer *b) 10 | #endif 11 | { 12 | return( *a > *b ? *a - *b : 0); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/d_dim.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double d_dim(a,b) doublereal *a, *b; 8 | #else 9 | double d_dim(doublereal *a, doublereal *b) 10 | #endif 11 | { 12 | return( *a > *b ? *a - *b : 0); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/h_dim.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_dim(a,b) shortint *a, *b; 8 | #else 9 | shortint h_dim(shortint *a, shortint *b) 10 | #endif 11 | { 12 | return( *a > *b ? *a - *b : 0); 13 | } 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/r_cos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double cos(); 5 | double r_cos(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_cos(real *x) 13 | #endif 14 | { 15 | return( cos(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_exp.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double exp(); 5 | double r_exp(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_exp(real *x) 13 | #endif 14 | { 15 | return( exp(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_log.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double log(); 5 | double r_log(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_log(real *x) 13 | #endif 14 | { 15 | return( log(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_sin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sin(); 5 | double r_sin(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_sin(real *x) 13 | #endif 14 | { 15 | return( sin(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_tan.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double tan(); 5 | double r_tan(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_tan(real *x) 13 | #endif 14 | { 15 | return( tan(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/derf_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double erf(); 8 | double derf_(x) doublereal *x; 9 | #else 10 | extern double erf(double); 11 | double derf_(doublereal *x) 12 | #endif 13 | { 14 | return( erf(*x) ); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/r_acos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double acos(); 5 | double r_acos(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_acos(real *x) 13 | #endif 14 | { 15 | return( acos(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_asin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double asin(); 5 | double r_asin(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_asin(real *x) 13 | #endif 14 | { 15 | return( asin(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_atan.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double atan(); 5 | double r_atan(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_atan(real *x) 13 | #endif 14 | { 15 | return( atan(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_cosh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double cosh(); 5 | double r_cosh(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_cosh(real *x) 13 | #endif 14 | { 15 | return( cosh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_sinh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sinh(); 5 | double r_sinh(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_sinh(real *x) 13 | #endif 14 | { 15 | return( sinh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_sqrt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sqrt(); 5 | double r_sqrt(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_sqrt(real *x) 13 | #endif 14 | { 15 | return( sqrt(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_tanh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double tanh(); 5 | double r_tanh(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_tanh(real *x) 13 | #endif 14 | { 15 | return( tanh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_edge_list.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_EDGE_LIST 2 | #define PRPACK_EDGE_LIST 3 | 4 | namespace prpack { 5 | 6 | class prpack_edge_list { 7 | public: 8 | int num_vs; 9 | int num_es; 10 | int* heads; 11 | int* tails; 12 | }; 13 | 14 | } 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/d_cos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double cos(); 5 | double d_cos(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_cos(doublereal *x) 13 | #endif 14 | { 15 | return( cos(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_exp.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double exp(); 5 | double d_exp(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_exp(doublereal *x) 13 | #endif 14 | { 15 | return( exp(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_log.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double log(); 5 | double d_log(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_log(doublereal *x) 13 | #endif 14 | { 15 | return( log(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_sin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sin(); 5 | double d_sin(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_sin(doublereal *x) 13 | #endif 14 | { 15 | return( sin(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_tan.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double tan(); 5 | double d_tan(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_tan(doublereal *x) 13 | #endif 14 | { 15 | return( tan(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_cnjg.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | VOID r_cnjg(r, z) f2c_complex *r, *z; 8 | #else 9 | VOID r_cnjg(f2c_complex *r, f2c_complex *z) 10 | #endif 11 | { 12 | real zi = z->i; 13 | r->r = z->r; 14 | r->i = -zi; 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/r_sign.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double r_sign(a,b) real *a, *b; 8 | #else 9 | double r_sign(real *a, real *b) 10 | #endif 11 | { 12 | double x; 13 | x = (*a >= 0 ? *a : - *a); 14 | return( *b >= 0 ? x : -x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/d_acos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double acos(); 5 | double d_acos(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_acos(doublereal *x) 13 | #endif 14 | { 15 | return( acos(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_asin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double asin(); 5 | double d_asin(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_asin(doublereal *x) 13 | #endif 14 | { 15 | return( asin(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_atan.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double atan(); 5 | double d_atan(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_atan(doublereal *x) 13 | #endif 14 | { 15 | return( atan(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_cosh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double cosh(); 5 | double d_cosh(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_cosh(doublereal *x) 13 | #endif 14 | { 15 | return( cosh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_sinh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sinh(); 5 | double d_sinh(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_sinh(doublereal *x) 13 | #endif 14 | { 15 | return( sinh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_sqrt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sqrt(); 5 | double d_sqrt(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_sqrt(doublereal *x) 13 | #endif 14 | { 15 | return( sqrt(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_tanh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double tanh(); 5 | double d_tanh(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_tanh(doublereal *x) 13 | #endif 14 | { 15 | return( tanh(*x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/lbitshft.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | integer 7 | #ifdef KR_headers 8 | lbit_shift(a, b) integer a; integer b; 9 | #else 10 | lbit_shift(integer a, integer b) 11 | #endif 12 | { 13 | return b >= 0 ? a << b : (integer)((uinteger)a >> -b); 14 | } 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | -------------------------------------------------------------------------------- /igraph/src/r_atn2.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double atan2(); 5 | double r_atn2(x,y) real *x, *y; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_atn2(real *x, real *y) 13 | #endif 14 | { 15 | return( atan2(*x,*y) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /src/IGraph/Internal/Initialization.chs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | module IGraph.Internal.Initialization where 3 | 4 | #include "haskell_igraph.h" 5 | 6 | data HasInit 7 | 8 | igraphInit :: IO HasInit 9 | igraphInit = do haskelligraphInit 10 | return undefined 11 | 12 | {#fun haskelligraph_init as ^ {} -> `()' #} 13 | -------------------------------------------------------------------------------- /igraph/src/d_cnjg.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | VOID 7 | #ifdef KR_headers 8 | d_cnjg(r, z) doublecomplex *r, *z; 9 | #else 10 | d_cnjg(doublecomplex *r, doublecomplex *z) 11 | #endif 12 | { 13 | doublereal zi = z->i; 14 | r->r = z->r; 15 | r->i = -zi; 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/derfc_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern double erfc(); 8 | 9 | double derfc_(x) doublereal *x; 10 | #else 11 | extern double erfc(double); 12 | 13 | double derfc_(doublereal *x) 14 | #endif 15 | { 16 | return( erfc(*x) ); 17 | } 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /igraph/src/i_sign.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_sign(a,b) integer *a, *b; 8 | #else 9 | integer i_sign(integer *a, integer *b) 10 | #endif 11 | { 12 | integer x; 13 | x = (*a >= 0 ? *a : - *a); 14 | return( *b >= 0 ? x : -x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/r_int.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | double r_int(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_int(real *x) 13 | #endif 14 | { 15 | return( (*x>0) ? floor(*x) : -floor(- *x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /tests/test.hs: -------------------------------------------------------------------------------- 1 | import qualified Test.Algorithms as Algorithms 2 | import qualified Test.Attributes as Attributes 3 | import qualified Test.Basic as Basic 4 | import Test.Tasty 5 | 6 | main :: IO () 7 | main = defaultMain $ testGroup "Haskell-igraph Tests" 8 | [ Basic.tests 9 | , Algorithms.tests 10 | , Attributes.tests 11 | ] 12 | -------------------------------------------------------------------------------- /igraph/src/d_sign.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double d_sign(a,b) doublereal *a, *b; 8 | #else 9 | double d_sign(doublereal *a, doublereal *b) 10 | #endif 11 | { 12 | double x; 13 | x = (*a >= 0 ? *a : - *a); 14 | return( *b >= 0 ? x : -x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/h_sign.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_sign(a,b) shortint *a, *b; 8 | #else 9 | shortint h_sign(shortint *a, shortint *b) 10 | #endif 11 | { 12 | shortint x; 13 | x = (*a >= 0 ? *a : - *a); 14 | return( *b >= 0 ? x : -x); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/z_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double f__cabs(); 8 | double z_abs(z) doublecomplex *z; 9 | #else 10 | double f__cabs(double, double); 11 | double z_abs(doublecomplex *z) 12 | #endif 13 | { 14 | return( f__cabs( z->r, z->i ) ); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/include/igraph_lsap.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef IGRAPH_LSAP_H 3 | #define IGRAPH_LSAP_H 4 | 5 | #include "igraph_types.h" 6 | #include "igraph_vector.h" 7 | #include "igraph_matrix.h" 8 | 9 | __BEGIN_DECLS 10 | 11 | int igraph_solve_lsap(igraph_matrix_t *c, igraph_integer_t n, 12 | igraph_vector_int_t *p); 13 | 14 | __END_DECLS 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /igraph/src/d_int.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | double d_int(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_int(doublereal *x) 13 | #endif 14 | { 15 | return( (*x>0) ? floor(*x) : -floor(- *x) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_atn2.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double atan2(); 5 | double d_atn2(x,y) doublereal *x, *y; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_atn2(doublereal *x, doublereal *y) 13 | #endif 14 | { 15 | return( atan2(*x,*y) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/i_nint.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | integer i_nint(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | integer i_nint(real *x) 13 | #endif 14 | { 15 | return (integer)(*x >= 0 ? floor(*x + .5) : -floor(.5 - *x)); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/pow_dd.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double pow(); 5 | double pow_dd(ap, bp) doublereal *ap, *bp; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double pow_dd(doublereal *ap, doublereal *bp) 13 | #endif 14 | { 15 | return(pow(*ap, *bp) ); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_nint.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | double r_nint(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double r_nint(real *x) 13 | #endif 14 | { 15 | return( (*x)>=0 ? 16 | floor(*x + .5) : -floor(.5 - *x) ); 17 | } 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /igraph/src/erf_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifndef REAL 7 | #define REAL double 8 | #endif 9 | 10 | #ifdef KR_headers 11 | double erf(); 12 | REAL erf_(x) real *x; 13 | #else 14 | extern double erf(double); 15 | REAL erf_(real *x) 16 | #endif 17 | { 18 | return( erf((double)*x) ); 19 | } 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /igraph/src/h_nint.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | shortint h_nint(x) real *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | shortint h_nint(real *x) 13 | #endif 14 | { 15 | return (shortint)(*x >= 0 ? floor(*x + .5) : -floor(.5 - *x)); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/c_abs.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern double f__cabs(); 8 | 9 | double c_abs(z) f2c_complex *z; 10 | #else 11 | extern double f__cabs(double, double); 12 | 13 | double c_abs(f2c_complex *z) 14 | #endif 15 | { 16 | return( f__cabs( z->r, z->i ) ); 17 | } 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /igraph/src/d_nint.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | double d_nint(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | double d_nint(doublereal *x) 13 | #endif 14 | { 15 | return( (*x)>=0 ? 16 | floor(*x + .5) : -floor(.5 - *x) ); 17 | } 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /igraph/src/erfc_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifndef REAL 7 | #define REAL double 8 | #endif 9 | 10 | #ifdef KR_headers 11 | double erfc(); 12 | REAL erfc_(x) real *x; 13 | #else 14 | extern double erfc(double); 15 | REAL erfc_(real *x) 16 | #endif 17 | { 18 | return( erfc((double)*x) ); 19 | } 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /igraph/src/i_dnnt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | integer i_dnnt(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | integer i_dnnt(doublereal *x) 13 | #endif 14 | { 15 | return (integer)(*x >= 0. ? floor(*x + .5) : -floor(.5 - *x)); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/r_lg10.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #define log10e 0.43429448190325182765 4 | 5 | #ifdef KR_headers 6 | double log(); 7 | double r_lg10(x) real *x; 8 | #else 9 | #undef abs 10 | #include "math.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | double r_lg10(real *x) 15 | #endif 16 | { 17 | return( log10e * log(*x) ); 18 | } 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /igraph/src/h_dnnt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double floor(); 5 | shortint h_dnnt(x) doublereal *x; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | shortint h_dnnt(doublereal *x) 13 | #endif 14 | { 15 | return (shortint)(*x >= 0. ? floor(*x + .5) : -floor(.5 - *x)); 16 | } 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /igraph/src/d_lg10.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #define log10e 0.43429448190325182765 4 | 5 | #ifdef KR_headers 6 | double log(); 7 | double d_lg10(x) doublereal *x; 8 | #else 9 | #undef abs 10 | #include "math.h" 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | double d_lg10(doublereal *x) 15 | #endif 16 | { 17 | return( log10e * log(*x) ); 18 | } 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /igraph/src/signal_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "signal1.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | ftnint 8 | #ifdef KR_headers 9 | signal_(sigp, proc) integer *sigp; sig_pf proc; 10 | #else 11 | signal_(integer *sigp, sig_pf proc) 12 | #endif 13 | { 14 | int sig; 15 | sig = (int)*sigp; 16 | 17 | return (ftnint)signal(sig, proc); 18 | } 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /igraph/src/abort_.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "f2c.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | #ifdef KR_headers 8 | extern VOID sig_die(); 9 | 10 | int abort_() 11 | #else 12 | extern void sig_die(const char*,int); 13 | 14 | int abort_(void) 15 | #endif 16 | { 17 | sig_die("Fortran abort routine called", 1); 18 | return 0; /* not reached */ 19 | } 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /igraph/src/l_ge.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | logical l_ge(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | logical l_ge(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) >= 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/l_gt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | logical l_gt(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | logical l_gt(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) > 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/l_le.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | logical l_le(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | logical l_le(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) <= 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/l_lt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | logical l_lt(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | logical l_lt(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) < 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/hl_ge.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | shortlogical hl_ge(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | shortlogical hl_ge(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) >= 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/hl_gt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | shortlogical hl_gt(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | shortlogical hl_gt(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) > 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/hl_le.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | shortlogical hl_le(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | shortlogical hl_le(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) <= 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/hl_lt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern integer s_cmp(); 8 | shortlogical hl_lt(a,b,la,lb) char *a, *b; ftnlen la, lb; 9 | #else 10 | extern integer s_cmp(char *, char *, ftnlen, ftnlen); 11 | shortlogical hl_lt(char *a, char *b, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | return(s_cmp(a,b,la,lb) < 0); 15 | } 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_preprocessed_graph.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_PREPROCESSED_GRAPH 2 | #define PRPACK_PREPROCESSED_GRAPH 3 | 4 | namespace prpack { 5 | 6 | // TODO: this class should not be seeable by the users of the library. 7 | // Super graph class. 8 | class prpack_preprocessed_graph { 9 | public: 10 | int num_vs; 11 | int num_es; 12 | double* d; 13 | }; 14 | 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /igraph/src/signbit.c: -------------------------------------------------------------------------------- 1 | #include "arith.h" 2 | 3 | #ifndef Long 4 | #define Long long 5 | #endif 6 | 7 | int 8 | #ifdef KR_headers 9 | signbit_f2c(x) double *x; 10 | #else 11 | signbit_f2c(double *x) 12 | #endif 13 | { 14 | #ifdef IEEE_MC68k 15 | if (*(Long*)x & 0x80000000) 16 | return 1; 17 | #else 18 | #ifdef IEEE_8087 19 | if (((Long*)x)[1] & 0x80000000) 20 | return 1; 21 | #endif /*IEEE_8087*/ 22 | #endif /*IEEE_MC68k*/ 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /igraph/src/z_sin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sin(), cos(), sinh(), cosh(); 5 | VOID z_sin(r, z) doublecomplex *r, *z; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | void z_sin(doublecomplex *r, doublecomplex *z) 13 | #endif 14 | { 15 | double zi = z->i, zr = z->r; 16 | r->r = sin(zr) * cosh(zi); 17 | r->i = cos(zr) * sinh(zi); 18 | } 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /igraph/src/z_cos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sin(), cos(), sinh(), cosh(); 5 | VOID z_cos(r, z) doublecomplex *r, *z; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | void z_cos(doublecomplex *r, doublecomplex *z) 13 | #endif 14 | { 15 | double zi = z->i, zr = z->r; 16 | r->r = cos(zr) * cosh(zi); 17 | r->i = - sin(zr) * sinh(zi); 18 | } 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /igraph/src/z_exp.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double exp(), cos(), sin(); 5 | VOID z_exp(r, z) doublecomplex *r, *z; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | void z_exp(doublecomplex *r, doublecomplex *z) 13 | #endif 14 | { 15 | double expx, zi = z->i; 16 | 17 | expx = exp(z->r); 18 | r->r = expx * cos(zi); 19 | r->i = expx * sin(zi); 20 | } 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /tests/Test/Utils.hs: -------------------------------------------------------------------------------- 1 | module Test.Utils where 2 | 3 | import Control.Monad 4 | import System.Random 5 | import Data.List.Ordered 6 | 7 | randEdges :: Int -- ^ number of edges to generate 8 | -> Int -- ^ number of nodes in the graph 9 | -> IO [(Int, Int)] 10 | randEdges n nd = do 11 | fr <- replicateM (2*n) $ randomRIO (0,nd-1) 12 | to <- replicateM (2*n) $ randomRIO (0,nd-1) 13 | return $ take n $ nubSort $ filter (uncurry (/=)) $ zip fr to 14 | -------------------------------------------------------------------------------- /igraph/src/c_sin.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | extern double sin(), cos(), sinh(), cosh(); 5 | 6 | VOID c_sin(r, z) f2c_complex *r, *z; 7 | #else 8 | #undef abs 9 | #include "math.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void c_sin(f2c_complex *r, f2c_complex *z) 15 | #endif 16 | { 17 | double zi = z->i, zr = z->r; 18 | r->r = sin(zr) * cosh(zi); 19 | r->i = cos(zr) * sinh(zi); 20 | } 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /igraph/src/c_cos.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | extern double sin(), cos(), sinh(), cosh(); 5 | 6 | VOID c_cos(r, z) f2c_complex *r, *z; 7 | #else 8 | #undef abs 9 | #include "math.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void c_cos(f2c_complex *r, f2c_complex *z) 15 | #endif 16 | { 17 | double zi = z->i, zr = z->r; 18 | r->r = cos(zr) * cosh(zi); 19 | r->i = - sin(zr) * sinh(zi); 20 | } 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /igraph/src/typesize.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | ftnlen f__typesize[] = { 0, 0, sizeof(shortint), sizeof(integer), 7 | sizeof(real), sizeof(doublereal), 8 | sizeof(f2c_complex), sizeof(doublecomplex), 9 | sizeof(logical), sizeof(char), 10 | 0, sizeof(integer1), 11 | sizeof(logical1), sizeof(shortlogical), 12 | #ifdef Allow_TYQUAD 13 | sizeof(longint), 14 | #endif 15 | 0}; 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | -------------------------------------------------------------------------------- /igraph/src/c_exp.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | extern double exp(), cos(), sin(); 5 | 6 | VOID c_exp(r, z) f2c_complex *r, *z; 7 | #else 8 | #undef abs 9 | #include "math.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | void c_exp(f2c_complex *r, f2c_complex *z) 15 | #endif 16 | { 17 | double expx, zi = z->i; 18 | 19 | expx = exp(z->r); 20 | r->r = expx * cos(zi); 21 | r->i = expx * sin(zi); 22 | } 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /src/IGraph/Random.hs: -------------------------------------------------------------------------------- 1 | module IGraph.Random 2 | ( Gen 3 | , withSeed 4 | ) where 5 | 6 | import IGraph.Internal 7 | 8 | -- | Random number generator 9 | data Gen = Gen 10 | 11 | {- 12 | withSystemRandom :: (Gen -> IO a) -> IO a 13 | withSystemRandom fun = fun Gen 14 | {-# INLINE withSystemRandom #-} 15 | -} 16 | 17 | withSeed :: Int -> (Gen -> IO a) -> IO a 18 | withSeed seed fun = do 19 | rng <- igraphRngDefault 20 | igraphRngSeed rng seed 21 | fun Gen 22 | {-# INLINE withSeed #-} -------------------------------------------------------------------------------- /igraph/src/c_log.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | extern double log(), f__cabs(), atan2(); 5 | VOID c_log(r, z) f2c_complex *r, *z; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | extern double f__cabs(double, double); 13 | 14 | void c_log(f2c_complex *r, f2c_complex *z) 15 | #endif 16 | { 17 | double zi, zr; 18 | r->i = atan2(zi = z->i, zr = z->r); 19 | r->r = log( f__cabs(zr, zi) ); 20 | } 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | -------------------------------------------------------------------------------- /igraph/src/ef1cmc_.c: -------------------------------------------------------------------------------- 1 | /* EFL support routine to compare two character strings */ 2 | 3 | #include "f2c.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #ifdef KR_headers 9 | extern integer s_cmp(); 10 | integer ef1cmc_(a, la, b, lb) ftnint *a, *b; ftnlen *la, *lb; 11 | #else 12 | extern integer s_cmp(char*,char*,ftnlen,ftnlen); 13 | integer ef1cmc_(ftnint *a, ftnlen *la, ftnint *b, ftnlen *lb) 14 | #endif 15 | { 16 | return( s_cmp( (char *)a, (char *)b, *la, *lb) ); 17 | } 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /igraph/include/igraph_handle_exceptions.h: -------------------------------------------------------------------------------- 1 | #ifndef IGRAPH_HANDLE_EXCEPTIONS_H 2 | #define IGRAPH_HANDLE_EXCEPTIONS_H 3 | 4 | #include 5 | #include 6 | 7 | #define IGRAPH_HANDLE_EXCEPTIONS(code) \ 8 | try { code; } \ 9 | catch (const std::bad_alloc &e) { IGRAPH_ERROR(e.what(), IGRAPH_ENOMEM); } \ 10 | catch (const std::exception &e) { IGRAPH_ERROR(e.what(), IGRAPH_FAILURE); } \ 11 | catch (...) { IGRAPH_ERROR("Unknown exception caught", IGRAPH_FAILURE); } 12 | 13 | 14 | #endif // IGRAPH_HANDLE_EXCEPTIONS_H 15 | -------------------------------------------------------------------------------- /igraph/src/pow_ci.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | VOID pow_ci(p, a, b) /* p = a**b */ 8 | f2c_complex *p, *a; integer *b; 9 | #else 10 | extern void pow_zi(doublecomplex*, doublecomplex*, integer*); 11 | void pow_ci(f2c_complex *p, f2c_complex *a, integer *b) /* p = a**b */ 12 | #endif 13 | { 14 | doublecomplex p1, a1; 15 | 16 | a1.r = a->r; 17 | a1.i = a->i; 18 | 19 | pow_zi(&p1, &a1, b); 20 | 21 | p->r = p1.r; 22 | p->i = p1.i; 23 | } 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /igraph/src/i_indx.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer i_indx(a, b, la, lb) char *a, *b; ftnlen la, lb; 8 | #else 9 | integer i_indx(char *a, char *b, ftnlen la, ftnlen lb) 10 | #endif 11 | { 12 | ftnlen i, n; 13 | char *s, *t, *bend; 14 | 15 | n = la - lb + 1; 16 | bend = b + lb; 17 | 18 | for(i = 0 ; i < n ; ++i) 19 | { 20 | s = a + i; 21 | t = b; 22 | while(t < bend) 23 | if(*s++ != *t++) 24 | goto no; 25 | return(i+1); 26 | no: ; 27 | } 28 | return(0); 29 | } 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /igraph/src/dolio.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | #ifdef KR_headers 10 | extern int (*f__lioproc)(); 11 | 12 | integer do_lio(type,number,ptr,len) ftnint *number,*type; char *ptr; ftnlen len; 13 | #else 14 | extern int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint); 15 | 16 | integer do_lio(ftnint *type, ftnint *number, char *ptr, ftnlen len) 17 | #endif 18 | { 19 | return((*f__lioproc)(number,ptr,len,*type)); 20 | } 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | -------------------------------------------------------------------------------- /igraph/src/h_indx.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint h_indx(a, b, la, lb) char *a, *b; ftnlen la, lb; 8 | #else 9 | shortint h_indx(char *a, char *b, ftnlen la, ftnlen lb) 10 | #endif 11 | { 12 | ftnlen i, n; 13 | char *s, *t, *bend; 14 | 15 | n = la - lb + 1; 16 | bend = b + lb; 17 | 18 | for(i = 0 ; i < n ; ++i) 19 | { 20 | s = a + i; 21 | t = b; 22 | while(t < bend) 23 | if(*s++ != *t++) 24 | goto no; 25 | return((shortint)i+1); 26 | no: ; 27 | } 28 | return(0); 29 | } 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /igraph/src/rewind.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | #ifdef KR_headers 7 | integer f_rew(a) alist *a; 8 | #else 9 | integer f_rew(alist *a) 10 | #endif 11 | { 12 | unit *b; 13 | if(a->aunit>=MXUNIT || a->aunit<0) 14 | err(a->aerr,101,"rewind"); 15 | b = &f__units[a->aunit]; 16 | if(b->ufd == NULL || b->uwrt == 3) 17 | return(0); 18 | if(!b->useek) 19 | err(a->aerr,106,"rewind") 20 | if(b->uwrt) { 21 | (void) t_runc(a); 22 | b->uwrt = 3; 23 | } 24 | rewind(b->ufd); 25 | b->uend=0; 26 | return(0); 27 | } 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /igraph/src/wsne.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #include "lio.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | integer 9 | #ifdef KR_headers 10 | s_wsne(a) cilist *a; 11 | #else 12 | s_wsne(cilist *a) 13 | #endif 14 | { 15 | int n; 16 | 17 | if(n=c_le(a)) 18 | return(n); 19 | f__reading=0; 20 | f__external=1; 21 | f__formatted=1; 22 | f__putn = x_putc; 23 | L_len = LINE; 24 | f__donewrec = x_wSL; 25 | if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) 26 | err(a->cierr, errno, "namelist output start"); 27 | x_wsne(a); 28 | return e_wsle(); 29 | } 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_igraph_graph.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_IGRAPH_GRAPH 2 | #define PRPACK_IGRAPH_GRAPH 3 | 4 | #ifdef PRPACK_IGRAPH_SUPPORT 5 | 6 | #include "igraph_interface.h" 7 | #include "prpack_base_graph.h" 8 | 9 | namespace prpack { 10 | 11 | class prpack_igraph_graph : public prpack_base_graph { 12 | 13 | public: 14 | // constructors 15 | explicit prpack_igraph_graph(const igraph_t* g, 16 | const igraph_vector_t* weights = 0, 17 | igraph_bool_t directed = true); 18 | }; 19 | 20 | } 21 | 22 | // PRPACK_IGRAPH_SUPPORT 23 | #endif 24 | 25 | // PRPACK_IGRAPH_GRAPH 26 | #endif 27 | -------------------------------------------------------------------------------- /igraph/src/pow_ri.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double pow_ri(ap, bp) real *ap; integer *bp; 8 | #else 9 | double pow_ri(real *ap, integer *bp) 10 | #endif 11 | { 12 | double pow, x; 13 | integer n; 14 | unsigned long u; 15 | 16 | pow = 1; 17 | x = *ap; 18 | n = *bp; 19 | 20 | if(n != 0) 21 | { 22 | if(n < 0) 23 | { 24 | n = -n; 25 | x = 1/x; 26 | } 27 | for(u = n; ; ) 28 | { 29 | if(u & 01) 30 | pow *= x; 31 | if(u >>= 1) 32 | x *= x; 33 | else 34 | break; 35 | } 36 | } 37 | return(pow); 38 | } 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /igraph/src/ef1asc_.c: -------------------------------------------------------------------------------- 1 | /* EFL support routine to copy string b to string a */ 2 | 3 | #include "f2c.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | 9 | #define M ( (long) (sizeof(long) - 1) ) 10 | #define EVEN(x) ( ( (x)+ M) & (~M) ) 11 | 12 | #ifdef KR_headers 13 | extern VOID s_copy(); 14 | ef1asc_(a, la, b, lb) ftnint *a, *b; ftnlen *la, *lb; 15 | #else 16 | extern void s_copy(char*,char*,ftnlen,ftnlen); 17 | int ef1asc_(ftnint *a, ftnlen *la, ftnint *b, ftnlen *lb) 18 | #endif 19 | { 20 | s_copy( (char *)a, (char *)b, EVEN(*la), *lb ); 21 | return 0; /* ignored return value */ 22 | } 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | -------------------------------------------------------------------------------- /igraph/src/pow_di.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | double pow_di(ap, bp) doublereal *ap; integer *bp; 8 | #else 9 | double pow_di(doublereal *ap, integer *bp) 10 | #endif 11 | { 12 | double pow, x; 13 | integer n; 14 | unsigned long u; 15 | 16 | pow = 1; 17 | x = *ap; 18 | n = *bp; 19 | 20 | if(n != 0) 21 | { 22 | if(n < 0) 23 | { 24 | n = -n; 25 | x = 1/x; 26 | } 27 | for(u = n; ; ) 28 | { 29 | if(u & 01) 30 | pow *= x; 31 | if(u >>= 1) 32 | x *= x; 33 | else 34 | break; 35 | } 36 | } 37 | return(pow); 38 | } 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /igraph/src/cabs.c: -------------------------------------------------------------------------------- 1 | #ifdef KR_headers 2 | extern double sqrt(); 3 | double f__cabs(real, imag) double real, imag; 4 | #else 5 | #undef abs 6 | #include "math.h" 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | double f__cabs(double real, double imag) 11 | #endif 12 | { 13 | double temp; 14 | 15 | if(real < 0) 16 | real = -real; 17 | if(imag < 0) 18 | imag = -imag; 19 | if(imag > real){ 20 | temp = real; 21 | real = imag; 22 | imag = temp; 23 | } 24 | if((real+imag) == real) 25 | return(real); 26 | 27 | temp = imag/real; 28 | temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/ 29 | return(temp); 30 | } 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /igraph/src/pow_ii.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | integer pow_ii(ap, bp) integer *ap, *bp; 8 | #else 9 | integer pow_ii(integer *ap, integer *bp) 10 | #endif 11 | { 12 | integer pow, x, n; 13 | unsigned long u; 14 | 15 | x = *ap; 16 | n = *bp; 17 | 18 | if (n <= 0) { 19 | if (n == 0 || x == 1) 20 | return 1; 21 | if (x != -1) 22 | return x == 0 ? 1/x : 0; 23 | n = -n; 24 | } 25 | u = n; 26 | for(pow = 1; ; ) 27 | { 28 | if(u & 01) 29 | pow *= x; 30 | if(u >>= 1) 31 | x *= x; 32 | else 33 | break; 34 | } 35 | return(pow); 36 | } 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /igraph/src/pow_hh.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | shortint pow_hh(ap, bp) shortint *ap, *bp; 8 | #else 9 | shortint pow_hh(shortint *ap, shortint *bp) 10 | #endif 11 | { 12 | shortint pow, x, n; 13 | unsigned u; 14 | 15 | x = *ap; 16 | n = *bp; 17 | 18 | if (n <= 0) { 19 | if (n == 0 || x == 1) 20 | return 1; 21 | if (x != -1) 22 | return x == 0 ? 1/x : 0; 23 | n = -n; 24 | } 25 | u = n; 26 | for(pow = 1; ; ) 27 | { 28 | if(u & 01) 29 | pow *= x; 30 | if(u >>= 1) 31 | x *= x; 32 | else 33 | break; 34 | } 35 | return(pow); 36 | } 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /igraph/include/igraph_decls.h: -------------------------------------------------------------------------------- 1 | #undef __BEGIN_DECLS 2 | #undef __END_DECLS 3 | #ifdef __cplusplus 4 | #define __BEGIN_DECLS extern "C" { 5 | #define __END_DECLS } 6 | #else 7 | #define __BEGIN_DECLS /* empty */ 8 | #define __END_DECLS /* empty */ 9 | #endif 10 | 11 | /* In igraph 0.8, we use DECLDIR only with MSVC, not other compilers on Windows. */ 12 | #undef DECLDIR 13 | #if defined (_MSC_VER) 14 | #ifdef IGRAPH_EXPORTS 15 | #define DECLDIR __declspec(dllexport) 16 | #elif defined(IGRAPH_STATIC) 17 | #define DECLDIR /**/ 18 | #else 19 | #define DECLDIR __declspec(dllimport) 20 | #endif 21 | #else 22 | #define DECLDIR /**/ 23 | #endif 24 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_csc.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_CSC 2 | #define PRPACK_CSC 3 | 4 | #if !defined(_MSC_VER) && !defined (__MINGW32__) && !defined (__MINGW64__) 5 | # include 6 | #else 7 | # include 8 | typedef __int64 int64_t; 9 | #endif 10 | 11 | namespace prpack { 12 | 13 | class prpack_csc { 14 | public: 15 | int num_vs; 16 | int num_es; 17 | int* heads; 18 | int* tails; 19 | }; 20 | 21 | class prpack_int64_csc { 22 | public: 23 | int64_t num_vs; 24 | int64_t num_es; 25 | int64_t* heads; 26 | int64_t* tails; 27 | }; 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /igraph/src/pow_zz.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double log(), exp(), cos(), sin(), atan2(), f__cabs(); 5 | VOID pow_zz(r,a,b) doublecomplex *r, *a, *b; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | extern double f__cabs(double,double); 13 | void pow_zz(doublecomplex *r, doublecomplex *a, doublecomplex *b) 14 | #endif 15 | { 16 | double logr, logi, x, y; 17 | 18 | logr = log( f__cabs(a->r, a->i) ); 19 | logi = atan2(a->i, a->r); 20 | 21 | x = exp( logr * b->r - logi * b->i ); 22 | y = logr * b->i + logi * b->r; 23 | 24 | r->r = x * cos(y); 25 | r->i = x * sin(y); 26 | } 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_result.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_RESULT 2 | #define PRPACK_RESULT 3 | 4 | #include 5 | 6 | namespace prpack { 7 | 8 | // Result class. 9 | class prpack_result { 10 | public: 11 | // instance variables 12 | int num_vs; 13 | int num_es; 14 | double* x; 15 | double read_time; 16 | double preprocess_time; 17 | double compute_time; 18 | long num_es_touched; 19 | std::string method; 20 | int converged; 21 | // constructor 22 | prpack_result(); 23 | // destructor 24 | ~prpack_result(); 25 | }; 26 | 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/IGraph/Algorithms.hs: -------------------------------------------------------------------------------- 1 | module IGraph.Algorithms 2 | ( module IGraph.Algorithms.Structure 3 | , module IGraph.Algorithms.Community 4 | , module IGraph.Algorithms.Clique 5 | , module IGraph.Algorithms.Layout 6 | , module IGraph.Algorithms.Motif 7 | , module IGraph.Algorithms.Generators 8 | , module IGraph.Algorithms.Isomorphism 9 | , module IGraph.Algorithms.Centrality 10 | ) where 11 | 12 | import IGraph.Algorithms.Structure 13 | import IGraph.Algorithms.Community 14 | import IGraph.Algorithms.Clique 15 | import IGraph.Algorithms.Layout 16 | import IGraph.Algorithms.Motif 17 | import IGraph.Algorithms.Generators 18 | import IGraph.Algorithms.Isomorphism 19 | import IGraph.Algorithms.Centrality 20 | -------------------------------------------------------------------------------- /igraph/src/exit_.c: -------------------------------------------------------------------------------- 1 | /* This gives the effect of 2 | 3 | subroutine exit(rc) 4 | integer*4 rc 5 | stop 6 | end 7 | 8 | * with the added side effect of supplying rc as the program's exit code. 9 | */ 10 | 11 | #include "f2c.h" 12 | #undef abs 13 | #undef min 14 | #undef max 15 | #ifndef KR_headers 16 | #include "stdlib.h" 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | extern void f_exit(void); 24 | #endif 25 | 26 | void 27 | #ifdef KR_headers 28 | exit_(rc) integer *rc; 29 | #else 30 | exit_(integer *rc) 31 | #endif 32 | { 33 | #ifdef NO_ONEXIT 34 | f_exit(); 35 | #endif 36 | exit(*rc); 37 | } 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | -------------------------------------------------------------------------------- /igraph/src/z_sqrt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | double sqrt(), f__cabs(); 5 | VOID z_sqrt(r, z) doublecomplex *r, *z; 6 | #else 7 | #undef abs 8 | #include "math.h" 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | extern double f__cabs(double, double); 13 | void z_sqrt(doublecomplex *r, doublecomplex *z) 14 | #endif 15 | { 16 | double mag, zi = z->i, zr = z->r; 17 | 18 | if( (mag = f__cabs(zr, zi)) == 0.) 19 | r->r = r->i = 0.; 20 | else if(zr > 0) 21 | { 22 | r->r = sqrt(0.5 * (mag + zr) ); 23 | r->i = zi / r->r / 2; 24 | } 25 | else 26 | { 27 | r->i = sqrt(0.5 * (mag - zr) ); 28 | if(zi < 0) 29 | r->i = - r->i; 30 | r->r = zi / r->i / 2; 31 | } 32 | } 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /igraph/include/f2c/fp.h: -------------------------------------------------------------------------------- 1 | #define FMAX 40 2 | #define EXPMAXDIGS 8 3 | #define EXPMAX 99999999 4 | /* FMAX = max number of nonzero digits passed to atof() */ 5 | /* EXPMAX = 10^EXPMAXDIGS - 1 = largest allowed exponent absolute value */ 6 | 7 | #ifdef V10 /* Research Tenth-Edition Unix */ 8 | #include "local.h" 9 | #endif 10 | 11 | /* MAXFRACDIGS and MAXINTDIGS are for wrt_F -- bounds (not necessarily 12 | tight) on the maximum number of digits to the right and left of 13 | * the decimal point. 14 | */ 15 | 16 | #ifdef VAX 17 | #define MAXFRACDIGS 56 18 | #define MAXINTDIGS 38 19 | #else 20 | #ifdef CRAY 21 | #define MAXFRACDIGS 9880 22 | #define MAXINTDIGS 9864 23 | #else 24 | /* values that suffice for IEEE double */ 25 | #define MAXFRACDIGS 344 26 | #define MAXINTDIGS 308 27 | #endif 28 | #endif 29 | -------------------------------------------------------------------------------- /igraph/src/c_sqrt.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | extern double sqrt(), f__cabs(); 5 | 6 | VOID c_sqrt(r, z) f2c_complex *r, *z; 7 | #else 8 | #undef abs 9 | #include "math.h" 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | extern double f__cabs(double, double); 14 | 15 | void c_sqrt(f2c_complex *r, f2c_complex *z) 16 | #endif 17 | { 18 | double mag, t; 19 | double zi = z->i, zr = z->r; 20 | 21 | if( (mag = f__cabs(zr, zi)) == 0.) 22 | r->r = r->i = 0.; 23 | else if(zr > 0) 24 | { 25 | r->r = t = sqrt(0.5 * (mag + zr) ); 26 | t = zi / t; 27 | r->i = 0.5 * t; 28 | } 29 | else 30 | { 31 | t = sqrt(0.5 * (mag - zr) ); 32 | if(zi < 0) 33 | t = -t; 34 | r->i = t; 35 | t = zi / t; 36 | r->r = 0.5 * t; 37 | } 38 | } 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | -------------------------------------------------------------------------------- /igraph/src/system_.c: -------------------------------------------------------------------------------- 1 | /* f77 interface to system routine */ 2 | 3 | #include "f2c.h" 4 | 5 | #ifdef KR_headers 6 | extern char *F77_aloc(); 7 | 8 | integer 9 | system_(s, n) register char *s; ftnlen n; 10 | #else 11 | #undef abs 12 | #undef min 13 | #undef max 14 | #include "stdlib.h" 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | extern char *F77_aloc(ftnlen, const char*); 19 | 20 | integer 21 | system_(register char *s, ftnlen n) 22 | #endif 23 | { 24 | char buff0[256], *buff; 25 | register char *bp, *blast; 26 | integer rv; 27 | 28 | buff = bp = n < sizeof(buff0) 29 | ? buff0 : F77_aloc(n+1, "system_"); 30 | blast = bp + n; 31 | 32 | while(bp < blast && *s) 33 | *bp++ = *s++; 34 | *bp = 0; 35 | rv = system(buff); 36 | if (buff != buff0) 37 | free(buff); 38 | return rv; 39 | } 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /igraph/src/f77_aloc.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #undef abs 3 | #undef min 4 | #undef max 5 | #include "stdio.h" 6 | 7 | static integer memfailure = 3; 8 | 9 | #ifdef KR_headers 10 | extern char *malloc(); 11 | extern void exit_(); 12 | 13 | char * 14 | F77_aloc(Len, whence) integer Len; char *whence; 15 | #else 16 | #include "stdlib.h" 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | extern void exit_(integer*); 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | char * 29 | F77_aloc(integer Len, const char *whence) 30 | #endif 31 | { 32 | char *rv; 33 | unsigned int uLen = (unsigned int) Len; /* for K&R C */ 34 | 35 | if (!(rv = (char*)malloc(uLen))) { 36 | fprintf(stderr, "malloc(%u) failure in %s\n", 37 | uLen, whence); 38 | exit_(&memfailure); 39 | } 40 | return rv; 41 | } 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /igraph/src/r_mod.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | #ifdef IEEE_drem 5 | double drem(); 6 | #else 7 | double floor(); 8 | #endif 9 | double r_mod(x,y) real *x, *y; 10 | #else 11 | #ifdef IEEE_drem 12 | double drem(double, double); 13 | #else 14 | #undef abs 15 | #include "math.h" 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | #endif 20 | double r_mod(real *x, real *y) 21 | #endif 22 | { 23 | #ifdef IEEE_drem 24 | double xa, ya, z; 25 | if ((ya = *y) < 0.) 26 | ya = -ya; 27 | z = drem(xa = *x, ya); 28 | if (xa > 0) { 29 | if (z < 0) 30 | z += ya; 31 | } 32 | else if (z > 0) 33 | z -= ya; 34 | return z; 35 | #else 36 | double quotient; 37 | if( (quotient = (double)*x / *y) >= 0) 38 | quotient = floor(quotient); 39 | else 40 | quotient = -floor(-quotient); 41 | return(*x - (*y) * quotient ); 42 | #endif 43 | } 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /igraph/src/wsle.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #include "fmt.h" 4 | #include "lio.h" 5 | #include "string.h" 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifdef KR_headers 11 | integer s_wsle(a) cilist *a; 12 | #else 13 | integer s_wsle(cilist *a) 14 | #endif 15 | { 16 | int n; 17 | if(n=c_le(a)) return(n); 18 | f__reading=0; 19 | f__external=1; 20 | f__formatted=1; 21 | f__putn = x_putc; 22 | f__lioproc = l_write; 23 | L_len = LINE; 24 | f__donewrec = x_wSL; 25 | if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) 26 | err(a->cierr, errno, "list output start"); 27 | return(0); 28 | } 29 | 30 | integer e_wsle(Void) 31 | { 32 | int n = f__putbuf('\n'); 33 | f__recpos=0; 34 | #ifdef ALWAYS_FLUSH 35 | if (!n && fflush(f__cf)) 36 | err(f__elist->cierr, errno, "write end"); 37 | #endif 38 | return(n); 39 | } 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_preprocessed_ge_graph.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_PREPROCESSED_GE_GRAPH 2 | #define PRPACK_PREPROCESSED_GE_GRAPH 3 | #include "prpack_preprocessed_graph.h" 4 | #include "prpack_base_graph.h" 5 | 6 | namespace prpack { 7 | 8 | // Pre-processed graph class 9 | class prpack_preprocessed_ge_graph : public prpack_preprocessed_graph { 10 | private: 11 | // helper methods 12 | void initialize(); 13 | void initialize_weighted(const prpack_base_graph* bg); 14 | void initialize_unweighted(const prpack_base_graph* bg); 15 | public: 16 | // instance variables 17 | double* matrix; 18 | // constructors 19 | prpack_preprocessed_ge_graph(const prpack_base_graph* bg); 20 | // destructor 21 | ~prpack_preprocessed_ge_graph(); 22 | }; 23 | 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /igraph/src/d_mod.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | 3 | #ifdef KR_headers 4 | #ifdef IEEE_drem 5 | double drem(); 6 | #else 7 | double floor(); 8 | #endif 9 | double d_mod(x,y) doublereal *x, *y; 10 | #else 11 | #ifdef IEEE_drem 12 | double drem(double, double); 13 | #else 14 | #undef abs 15 | #include "math.h" 16 | #ifdef __cplusplus 17 | extern "C" { 18 | #endif 19 | #endif 20 | double d_mod(doublereal *x, doublereal *y) 21 | #endif 22 | { 23 | #ifdef IEEE_drem 24 | double xa, ya, z; 25 | if ((ya = *y) < 0.) 26 | ya = -ya; 27 | z = drem(xa = *x, ya); 28 | if (xa > 0) { 29 | if (z < 0) 30 | z += ya; 31 | } 32 | else if (z > 0) 33 | z -= ya; 34 | return z; 35 | #else 36 | double quotient; 37 | if( (quotient = *x / *y) >= 0) 38 | quotient = floor(quotient); 39 | else 40 | quotient = -floor(-quotient); 41 | return(*x - (*y) * quotient ); 42 | #endif 43 | } 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /igraph/src/s_rnge.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "f2c.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | /* called when a subscript is out of range */ 8 | 9 | #ifdef KR_headers 10 | extern VOID sig_die(); 11 | integer s_rnge(varn, offset, procn, line) char *varn, *procn; ftnint offset, line; 12 | #else 13 | extern VOID sig_die(const char*,int); 14 | integer s_rnge(char *varn, ftnint offset, char *procn, ftnint line) 15 | #endif 16 | { 17 | register int i; 18 | 19 | fprintf(stderr, "Subscript out of range on file line %ld, procedure ", 20 | (long)line); 21 | while((i = *procn) && i != '_' && i != ' ') 22 | putc(*procn++, stderr); 23 | fprintf(stderr, ".\nAttempt to access the %ld-th element of variable ", 24 | (long)offset+1); 25 | while((i = *varn) && i != ' ') 26 | putc(*varn++, stderr); 27 | sig_die(".", 1); 28 | return 0; /* not reached */ 29 | } 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /igraph/src/sig_die.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "signal.h" 3 | 4 | #ifndef SIGIOT 5 | #ifdef SIGABRT 6 | #define SIGIOT SIGABRT 7 | #endif 8 | #endif 9 | 10 | #ifdef KR_headers 11 | void sig_die(s, kill) char *s; int kill; 12 | #else 13 | #include "stdlib.h" 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | extern void f_exit(void); 21 | 22 | void sig_die(const char *s, int kill) 23 | #endif 24 | { 25 | /* print error message, then clear buffers */ 26 | fprintf(stderr, "%s\n", s); 27 | 28 | if(kill) 29 | { 30 | fflush(stderr); 31 | f_exit(); 32 | fflush(stderr); 33 | /* now get a core */ 34 | #ifdef SIGIOT 35 | signal(SIGIOT, SIG_DFL); 36 | #endif 37 | abort(); 38 | } 39 | else { 40 | #ifdef NO_ONEXIT 41 | f_exit(); 42 | #endif 43 | exit(1); 44 | } 45 | } 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /igraph/src/s_cmp.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | /* compare two strings */ 7 | 8 | #ifdef KR_headers 9 | integer s_cmp(a0, b0, la, lb) char *a0, *b0; ftnlen la, lb; 10 | #else 11 | integer s_cmp(char *a0, char *b0, ftnlen la, ftnlen lb) 12 | #endif 13 | { 14 | register unsigned char *a, *aend, *b, *bend; 15 | a = (unsigned char *)a0; 16 | b = (unsigned char *)b0; 17 | aend = a + la; 18 | bend = b + lb; 19 | 20 | if(la <= lb) 21 | { 22 | while(a < aend) 23 | if(*a != *b) 24 | return( *a - *b ); 25 | else 26 | { ++a; ++b; } 27 | 28 | while(b < bend) 29 | if(*b != ' ') 30 | return( ' ' - *b ); 31 | else ++b; 32 | } 33 | 34 | else 35 | { 36 | while(b < bend) 37 | if(*a == *b) 38 | { ++a; ++b; } 39 | else 40 | return( *a - *b ); 41 | while(a < aend) 42 | if(*a != ' ') 43 | return(*a - ' '); 44 | else ++a; 45 | } 46 | return(0); 47 | } 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /igraph/src/s_stop.c: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "f2c.h" 3 | 4 | #ifdef KR_headers 5 | extern void f_exit(); 6 | int s_stop(s, n) char *s; ftnlen n; 7 | #else 8 | #undef abs 9 | #undef min 10 | #undef max 11 | #include "stdlib.h" 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | void f_exit(void); 19 | 20 | int s_stop(char *s, ftnlen n) 21 | #endif 22 | { 23 | int i; 24 | 25 | if(n > 0) 26 | { 27 | fprintf(stderr, "STOP "); 28 | for(i = 0; i 9 | 10 | #ifndef Sigret_t 11 | #define Sigret_t void 12 | #endif 13 | #ifndef Sigarg_t 14 | #ifdef KR_headers 15 | #define Sigarg_t 16 | #else 17 | #define Sigarg_t int 18 | #endif 19 | #endif /*Sigarg_t*/ 20 | 21 | #ifdef USE_SIG_PF /* compile with -DUSE_SIG_PF under IRIX */ 22 | #define sig_pf SIG_PF 23 | #else 24 | typedef Sigret_t (*sig_pf)(Sigarg_t); 25 | #endif 26 | 27 | #define signal1(a,b) signal(a,(sig_pf)b) 28 | 29 | #ifdef __cplusplus 30 | #define Sigarg ... 31 | #define Use_Sigarg 32 | #else 33 | #define Sigarg Int n 34 | #define Use_Sigarg n = n /* shut up compiler warning */ 35 | #endif 36 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_preprocessed_gs_graph.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_PREPROCESSED_GS_GRAPH 2 | #define PRPACK_PREPROCESSED_GS_GRAPH 3 | #include "prpack_preprocessed_graph.h" 4 | #include "prpack_base_graph.h" 5 | 6 | namespace prpack { 7 | 8 | // Pre-processed graph class 9 | class prpack_preprocessed_gs_graph : public prpack_preprocessed_graph { 10 | private: 11 | // helper methods 12 | void initialize(); 13 | void initialize_weighted(const prpack_base_graph* bg); 14 | void initialize_unweighted(const prpack_base_graph* bg); 15 | public: 16 | // instance variables 17 | int* heads; 18 | int* tails; 19 | double* vals; 20 | double* ii; 21 | double* num_outlinks; 22 | // constructors 23 | prpack_preprocessed_gs_graph(const prpack_base_graph* bg); 24 | // destructor 25 | ~prpack_preprocessed_gs_graph(); 26 | }; 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /igraph/src/sfe.c: -------------------------------------------------------------------------------- 1 | /* sequential formatted external common routines*/ 2 | #include "f2c.h" 3 | #include "fio.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #ifdef KR_headers 9 | extern char *f__fmtbuf; 10 | #else 11 | extern const char *f__fmtbuf; 12 | #endif 13 | 14 | integer e_rsfe(Void) 15 | { int n; 16 | n=en_fio(); 17 | f__fmtbuf=NULL; 18 | return(n); 19 | } 20 | 21 | int 22 | #ifdef KR_headers 23 | c_sfe(a) cilist *a; /* check */ 24 | #else 25 | c_sfe(cilist *a) /* check */ 26 | #endif 27 | { unit *p; 28 | f__curunit = p = &f__units[a->ciunit]; 29 | if(a->ciunit >= MXUNIT || a->ciunit<0) 30 | err(a->cierr,101,"startio"); 31 | if(p->ufd==NULL && fk_open(SEQ,FMT,a->ciunit)) err(a->cierr,114,"sfe") 32 | if(!p->ufmt) err(a->cierr,102,"sfe") 33 | return(0); 34 | } 35 | integer e_wsfe(Void) 36 | { 37 | int n = en_fio(); 38 | f__fmtbuf = NULL; 39 | #ifdef ALWAYS_FLUSH 40 | if (!n && fflush(f__cf)) 41 | err(f__elist->cierr, errno, "write end"); 42 | #endif 43 | return n; 44 | } 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /igraph/src/len_trim.c: -------------------------------------------------------------------------------- 1 | /* -- translated by f2c (version 20100827). 2 | You must link the resulting object file with libf2c: 3 | on Microsoft Windows system, link with libf2c.lib; 4 | on Linux or Unix systems, link with .../path/to/libf2c.a -lm 5 | or, if you install libf2c.a in a standard place, with -lf2c -lm 6 | -- in that order, at the end of the command line, as in 7 | cc *.o -lf2c -lm 8 | Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 9 | 10 | http://www.netlib.org/f2c/libf2c.zip 11 | */ 12 | 13 | #include "f2c.h" 14 | 15 | 16 | /* -- LEN_TRIM is Fortran 95, so we use a replacement here */ 17 | 18 | integer igraphlen_trim__(char *s, ftnlen s_len) 19 | { 20 | /* System generated locals */ 21 | integer ret_val; 22 | 23 | /* Builtin functions */ 24 | integer i_len(char *, ftnlen); 25 | 26 | 27 | 28 | 29 | for (ret_val = i_len(s, s_len); ret_val >= 1; --ret_val) { 30 | if (*(unsigned char *)&s[ret_val - 1] != ' ') { 31 | return ret_val; 32 | } 33 | } 34 | return ret_val; 35 | } /* igraphlen_trim__ */ 36 | 37 | -------------------------------------------------------------------------------- /igraph/include/cliquer/reorder.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CLIQUER_REORDER_H 3 | #define CLIQUER_REORDER_H 4 | 5 | #include "set.h" 6 | #include "graph.h" 7 | 8 | extern void reorder_set(set_t s,int *order); 9 | extern void reorder_graph(graph_t *g, int *order); 10 | extern int *reorder_duplicate(int *order,int n); 11 | extern void reorder_invert(int *order,int n); 12 | extern void reorder_reverse(int *order,int n); 13 | extern int *reorder_ident(int n); 14 | extern boolean reorder_is_bijection(int *order,int n); 15 | 16 | 17 | #define reorder_by_default reorder_by_greedy_coloring 18 | extern int *reorder_by_greedy_coloring(graph_t *g, boolean weighted); 19 | extern int *reorder_by_weighted_greedy_coloring(graph_t *g, boolean weighted); 20 | extern int *reorder_by_unweighted_greedy_coloring(graph_t *g,boolean weighted); 21 | extern int *reorder_by_degree(graph_t *g, boolean weighted); 22 | extern int *reorder_by_random(graph_t *g, boolean weighted); 23 | extern int *reorder_by_ident(graph_t *g, boolean weighted); 24 | extern int *reorder_by_reverse(graph_t *g, boolean weighted); 25 | 26 | #endif /* !CLIQUER_REORDER_H */ 27 | -------------------------------------------------------------------------------- /igraph/src/fmtlib.c: -------------------------------------------------------------------------------- 1 | /* @(#)fmtlib.c 1.2 */ 2 | #define MAXINTLENGTH 23 3 | 4 | #include "f2c.h" 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | #ifndef Allow_TYQUAD 9 | #undef longint 10 | #define longint long 11 | #undef ulongint 12 | #define ulongint unsigned long 13 | #endif 14 | 15 | #ifdef KR_headers 16 | char *f__icvt(value,ndigit,sign, base) longint value; int *ndigit,*sign; 17 | register int base; 18 | #else 19 | char *f__icvt(longint value, int *ndigit, int *sign, int base) 20 | #endif 21 | { 22 | static char buf[MAXINTLENGTH+1]; 23 | register int i; 24 | ulongint uvalue; 25 | 26 | if(value > 0) { 27 | uvalue = value; 28 | *sign = 0; 29 | } 30 | else if (value < 0) { 31 | uvalue = -value; 32 | *sign = 1; 33 | } 34 | else { 35 | *sign = 0; 36 | *ndigit = 1; 37 | buf[MAXINTLENGTH-1] = '0'; 38 | return &buf[MAXINTLENGTH-1]; 39 | } 40 | i = MAXINTLENGTH; 41 | do { 42 | buf[--i] = (uvalue%base) + '0'; 43 | uvalue /= base; 44 | } 45 | while(uvalue > 0); 46 | *ndigit = MAXINTLENGTH - i; 47 | return &buf[i]; 48 | } 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /igraph/src/etime_.c: -------------------------------------------------------------------------------- 1 | #include "time.h" 2 | 3 | #ifdef MSDOS 4 | #undef USE_CLOCK 5 | #define USE_CLOCK 6 | #endif 7 | 8 | #ifndef REAL 9 | #define REAL double 10 | #endif 11 | 12 | #ifndef USE_CLOCK 13 | #define _INCLUDE_POSIX_SOURCE /* for HP-UX */ 14 | #define _INCLUDE_XOPEN_SOURCE /* for HP-UX */ 15 | #include "sys/types.h" 16 | #include "sys/times.h" 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | #endif 21 | 22 | #undef Hz 23 | #ifdef CLK_TCK 24 | #define Hz CLK_TCK 25 | #else 26 | #ifdef HZ 27 | #define Hz HZ 28 | #else 29 | #define Hz 60 30 | #endif 31 | #endif 32 | 33 | REAL 34 | #ifdef KR_headers 35 | etime_(tarray) float *tarray; 36 | #else 37 | etime_(float *tarray) 38 | #endif 39 | { 40 | #ifdef USE_CLOCK 41 | #ifndef CLOCKS_PER_SECOND 42 | #define CLOCKS_PER_SECOND Hz 43 | #endif 44 | double t = clock(); 45 | tarray[1] = 0; 46 | return tarray[0] = t / CLOCKS_PER_SECOND; 47 | #else 48 | struct tms t; 49 | 50 | times(&t); 51 | return (tarray[0] = (double)t.tms_utime/Hz) 52 | + (tarray[1] = (double)t.tms_stime/Hz); 53 | #endif 54 | } 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-2021 Kai Zhang 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included 12 | in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /igraph/src/pow_zi.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | VOID pow_zi(p, a, b) /* p = a**b */ 8 | doublecomplex *p, *a; integer *b; 9 | #else 10 | extern void z_div(doublecomplex*, doublecomplex*, doublecomplex*); 11 | void pow_zi(doublecomplex *p, doublecomplex *a, integer *b) /* p = a**b */ 12 | #endif 13 | { 14 | integer n; 15 | unsigned long u; 16 | double t; 17 | doublecomplex q, x; 18 | static doublecomplex one = {1.0, 0.0}; 19 | 20 | n = *b; 21 | q.r = 1; 22 | q.i = 0; 23 | 24 | if(n == 0) 25 | goto done; 26 | if(n < 0) 27 | { 28 | n = -n; 29 | z_div(&x, &one, a); 30 | } 31 | else 32 | { 33 | x.r = a->r; 34 | x.i = a->i; 35 | } 36 | 37 | for(u = n; ; ) 38 | { 39 | if(u & 01) 40 | { 41 | t = q.r * x.r - q.i * x.i; 42 | q.i = q.r * x.i + q.i * x.r; 43 | q.r = t; 44 | } 45 | if(u >>= 1) 46 | { 47 | t = x.r * x.r - x.i * x.i; 48 | x.i = 2 * x.r * x.i; 49 | x.r = t; 50 | } 51 | else 52 | break; 53 | } 54 | done: 55 | p->i = q.i; 56 | p->r = q.r; 57 | } 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_preprocessed_schur_graph.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_PREPROCESSED_SCHUR_GRAPH 2 | #define PRPACK_PREPROCESSED_SCHUR_GRAPH 3 | #include "prpack_preprocessed_graph.h" 4 | #include "prpack_base_graph.h" 5 | 6 | namespace prpack { 7 | 8 | class prpack_preprocessed_schur_graph : public prpack_preprocessed_graph { 9 | private: 10 | // helper methods 11 | void initialize(); 12 | void initialize_weighted(const prpack_base_graph* bg); 13 | void initialize_unweighted(const prpack_base_graph* bg); 14 | public: 15 | // instance variables 16 | int num_no_in_vs; 17 | int num_no_out_vs; 18 | int* heads; 19 | int* tails; 20 | double* vals; 21 | double* ii; 22 | double* num_outlinks; 23 | int* encoding; 24 | int* decoding; 25 | // constructors 26 | prpack_preprocessed_schur_graph(const prpack_base_graph* bg); 27 | // destructor 28 | ~prpack_preprocessed_schur_graph(); 29 | }; 30 | 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_UTILS 2 | #define PRPACK_UTILS 3 | #ifdef MATLAB_MEX_FILE 4 | #include "mex.h" 5 | #endif 6 | #include 7 | 8 | // Computes the time taken to do X and stores it in T. 9 | #define TIME(T, X) \ 10 | (T) = prpack_utils::get_time(); \ 11 | (X); \ 12 | (T) = prpack_utils::get_time() - (T) 13 | 14 | // Computes S += A using C as a carry-over. 15 | // This is a macro over a function as it is faster this way. 16 | #define COMPENSATED_SUM(S, A, C) \ 17 | double compensated_sum_y = (A) - (C); \ 18 | double compensated_sum_t = (S) + compensated_sum_y; \ 19 | (C) = compensated_sum_t - (S) - compensated_sum_y; \ 20 | (S) = compensated_sum_t 21 | 22 | namespace prpack { 23 | 24 | class prpack_utils { 25 | public: 26 | static double get_time(); 27 | static void validate(const bool condition, const std::string& msg); 28 | static double* permute(const int length, const double* a, const int* coding); 29 | }; 30 | 31 | } 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /igraph/src/ftell_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | static FILE * 8 | #ifdef KR_headers 9 | unit_chk(Unit, who) integer Unit; char *who; 10 | #else 11 | unit_chk(integer Unit, const char *who) 12 | #endif 13 | { 14 | if (Unit >= MXUNIT || Unit < 0) 15 | f__fatal(101, who); 16 | return f__units[Unit].ufd; 17 | } 18 | 19 | integer 20 | #ifdef KR_headers 21 | ftell_(Unit) integer *Unit; 22 | #else 23 | ftell_(integer *Unit) 24 | #endif 25 | { 26 | FILE *f; 27 | return (f = unit_chk(*Unit, "ftell")) ? ftell(f) : -1L; 28 | } 29 | 30 | int 31 | #ifdef KR_headers 32 | fseek_(Unit, offset, whence) integer *Unit, *offset, *whence; 33 | #else 34 | fseek_(integer *Unit, integer *offset, integer *whence) 35 | #endif 36 | { 37 | FILE *f; 38 | int w = (int)*whence; 39 | #ifdef SEEK_SET 40 | static int wohin[3] = { SEEK_SET, SEEK_CUR, SEEK_END }; 41 | #endif 42 | if (w < 0 || w > 2) 43 | w = 0; 44 | #ifdef SEEK_SET 45 | w = wohin[w]; 46 | #endif 47 | return !(f = unit_chk(*Unit, "fseek")) 48 | || fseek(f, *offset, w) ? 1 : 0; 49 | } 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /igraph/src/z_div.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern VOID sig_die(); 8 | VOID z_div(c, a, b) doublecomplex *a, *b, *c; 9 | #else 10 | extern void sig_die(const char*, int); 11 | void z_div(doublecomplex *c, doublecomplex *a, doublecomplex *b) 12 | #endif 13 | { 14 | double ratio, den; 15 | double abr, abi, cr; 16 | 17 | if( (abr = b->r) < 0.) 18 | abr = - abr; 19 | if( (abi = b->i) < 0.) 20 | abi = - abi; 21 | if( abr <= abi ) 22 | { 23 | if(abi == 0) { 24 | #ifdef IEEE_COMPLEX_DIVIDE 25 | if (a->i != 0 || a->r != 0) 26 | abi = 1.; 27 | c->i = c->r = abi / abr; 28 | return; 29 | #else 30 | sig_die("complex division by zero", 1); 31 | #endif 32 | } 33 | ratio = b->r / b->i ; 34 | den = b->i * (1 + ratio*ratio); 35 | cr = (a->r*ratio + a->i) / den; 36 | c->i = (a->i*ratio - a->r) / den; 37 | } 38 | 39 | else 40 | { 41 | ratio = b->i / b->r ; 42 | den = b->r * (1 + ratio*ratio); 43 | cr = (a->r + a->i*ratio) / den; 44 | c->i = (a->i - a->r*ratio) / den; 45 | } 46 | c->r = cr; 47 | } 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | -------------------------------------------------------------------------------- /igraph/include/foreign-gml-header.h: -------------------------------------------------------------------------------- 1 | /* 2 | IGraph library. 3 | Copyright (C) 2011-2012 Gabor Csardi 4 | 334 Harvard street, Cambridge MA, 02139 USA 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 | 02110-1301 USA 20 | 21 | */ 22 | 23 | #include "igraph_gml_tree.h" 24 | 25 | typedef struct { 26 | void *scanner; 27 | int eof; 28 | char errmsg[300]; 29 | igraph_gml_tree_t *tree; 30 | } igraph_i_gml_parsedata_t; 31 | -------------------------------------------------------------------------------- /igraph/include/config.h: -------------------------------------------------------------------------------- 1 | /* functions */ 2 | #define HAVE_EXPM1 1 3 | #define HAVE_FABSL 1 4 | #define HAVE_FINITE 1 5 | #define HAVE_FMIN 1 6 | #define HAVE_FTRUNCATE 1 7 | #define HAVE_ISNAN 1 8 | #define HAVE_LOG1P 1 9 | #define HAVE_LOG2 1 10 | #define HAVE_RINT 1 11 | #define HAVE_RINTF 1 12 | #define HAVE_ROUND 1 13 | #define HAVE_SNPRINTF 1 14 | #undef HAVE_ISFINITE 15 | 16 | /* libraries */ 17 | #define HAVE_MEMORY_H 1 18 | #define HAVE_STDINT_H 1 19 | #define HAVE_STRINGS_H 1 20 | #define HAVE_STRING_H 1 21 | 22 | #define HAVE_TLS 1 23 | #define IGRAPH_F77_SAVE static IGRAPH_THREAD_LOCAL 24 | #define IGRAPH_THREAD_LOCAL __thread 25 | #define TLS __thread 26 | 27 | #define INTERNAL_ARPACK 1 28 | #define INTERNAL_BLAS 1 29 | #define INTERNAL_F2C 1 30 | #define INTERNAL_GLPK 1 31 | #define INTERNAL_LAPACK 1 32 | 33 | 34 | #define LT_OBJDIR ".libs/" 35 | #define PACKAGE "igraph" 36 | #define PACKAGE_BUGREPORT "igraph@igraph.org" 37 | #define PACKAGE_NAME "igraph" 38 | #define PACKAGE_STRING "igraph 0.8.5" 39 | #define PACKAGE_TARNAME "igraph" 40 | #define PACKAGE_URL "" 41 | #define PACKAGE_VERSION "0.8.5" 42 | #define STDC_HEADERS 1 43 | #define VERSION "0.8.5" 44 | #undef YYTEXT_POINTER 45 | -------------------------------------------------------------------------------- /igraph/src/c_div.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifdef KR_headers 7 | extern VOID sig_die(); 8 | VOID c_div(c, a, b) 9 | f2c_complex *a, *b, *c; 10 | #else 11 | extern void sig_die(const char*,int); 12 | void c_div(f2c_complex *c, f2c_complex *a, f2c_complex *b) 13 | #endif 14 | { 15 | double ratio, den; 16 | double abr, abi, cr; 17 | 18 | if( (abr = b->r) < 0.) 19 | abr = - abr; 20 | if( (abi = b->i) < 0.) 21 | abi = - abi; 22 | if( abr <= abi ) 23 | { 24 | if(abi == 0) { 25 | #ifdef IEEE_COMPLEX_DIVIDE 26 | float af, bf; 27 | af = bf = abr; 28 | if (a->i != 0 || a->r != 0) 29 | af = 1.; 30 | c->i = c->r = af / bf; 31 | return; 32 | #else 33 | sig_die("complex division by zero", 1); 34 | #endif 35 | } 36 | ratio = (double)b->r / b->i ; 37 | den = b->i * (1 + ratio*ratio); 38 | cr = (a->r*ratio + a->i) / den; 39 | c->i = (a->i*ratio - a->r) / den; 40 | } 41 | 42 | else 43 | { 44 | ratio = (double)b->i / b->r ; 45 | den = b->r * (1 + ratio*ratio); 46 | cr = (a->r + a->i*ratio) / den; 47 | c->i = (a->i - a->r*ratio) / den; 48 | } 49 | c->r = cr; 50 | } 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | Revision history for haskell-igraph 2 | =================================== 3 | 4 | v0.8.1 -- 2020-02-XX 5 | -------------------- 6 | 7 | Add more functions 8 | 9 | v0.8.0 -- 2020-02-22 10 | -------------------- 11 | 12 | * Ship igraph C sources v0.8.0 13 | 14 | * Add random number generator. 15 | 16 | v0.7.1 -- 2018-11-26 17 | -------------------- 18 | 19 | * Add a few more functions. 20 | 21 | v0.7.0 -- 2018-05-23 22 | -------------------- 23 | 24 | * Add more functions and tests. 25 | * Internal interface redesign. 26 | 27 | v0.6.0 -- 2018-05-10 28 | -------------------- 29 | 30 | * Breaking change: Drop `Graph` type class. Change `LGraph` and `MLGraph` to 31 | `Graph` and `MGraph`. The new `Graph` and `MGraph` types are now dependently typed. 32 | 33 | v0.5.0 -- 2018-04-25 34 | -------------------- 35 | 36 | * Fix memory leaks. 37 | * Interface change: `mapNodes`, `mapEdges`, `filterNodes`, `filterEdges` become 38 | `nmap`, `emap`, `nfilter`, `efilter`. 39 | 40 | 41 | v0.4.0 -- 2018-04-20 42 | -------------------- 43 | 44 | * A new attribute interface written in C. The graph attributes are now directly serialized into bytestring using "cereal" (before we used the `Show` instance). 45 | -------------------------------------------------------------------------------- /igraph/include/igraph_vector_type.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2013 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | /** 25 | * Vector, dealing with arrays efficiently. 26 | * \ingroup types 27 | */ 28 | 29 | typedef struct TYPE(igraph_vector) { 30 | BASE* stor_begin; 31 | BASE* stor_end; 32 | BASE* end; 33 | } TYPE(igraph_vector); 34 | 35 | -------------------------------------------------------------------------------- /igraph/src/util.c: -------------------------------------------------------------------------------- 1 | #include "sysdep1.h" /* here to get stat64 on some badly designed Linux systems */ 2 | #include "f2c.h" 3 | #include "fio.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | VOID 9 | #ifdef KR_headers 10 | #define Const /*nothing*/ 11 | g_char(a,alen,b) char *a,*b; ftnlen alen; 12 | #else 13 | #define Const const 14 | g_char(const char *a, ftnlen alen, char *b) 15 | #endif 16 | { 17 | Const char *x = a + alen; 18 | char *y = b + alen; 19 | 20 | for(;; y--) { 21 | if (x <= a) { 22 | *b = 0; 23 | return; 24 | } 25 | if (*--x != ' ') 26 | break; 27 | } 28 | *y-- = 0; 29 | do *y-- = *x; 30 | while(x-- > a); 31 | } 32 | 33 | VOID 34 | #ifdef KR_headers 35 | b_char(a,b,blen) char *a,*b; ftnlen blen; 36 | #else 37 | b_char(const char *a, char *b, ftnlen blen) 38 | #endif 39 | { int i; 40 | for(i=0;i 2 | #include 3 | #include 4 | #include "defs.hh" 5 | 6 | /* 7 | Copyright (c) 2003-2015 Tommi Junttila 8 | Released under the GNU Lesser General Public License version 3. 9 | 10 | This file is part of bliss. 11 | 12 | bliss is free software: you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as published by 14 | the Free Software Foundation, version 3 of the License. 15 | 16 | bliss is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU Lesser General Public License for more details. 20 | 21 | You should have received a copy of the GNU Lesser General Public License 22 | along with bliss. If not, see . 23 | */ 24 | 25 | namespace bliss { 26 | 27 | void 28 | fatal_error(const char* fmt, ...) 29 | { 30 | char buffer[1024]; 31 | va_list ap; 32 | va_start(ap, fmt); 33 | sprintf(buffer, "Bliss fatal error: "); 34 | vsprintf(buffer, fmt, ap); 35 | throw std::runtime_error(buffer); 36 | va_end(ap); 37 | exit(1); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /igraph/src/cs_dropzeros.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | static CS_INT cs_nonzero (CS_INT i, CS_INT j, CS_ENTRY aij, void *other) 23 | { 24 | return (aij != 0) ; 25 | } 26 | CS_INT cs_dropzeros (cs *A) 27 | { 28 | return (cs_fkeep (A, &cs_nonzero, NULL)) ; /* keep all nonzero entries */ 29 | } 30 | -------------------------------------------------------------------------------- /igraph/src/platform.c: -------------------------------------------------------------------------------- 1 | /* platform.c 2 | * 3 | * Copyright (C) 2014 Tamas Nepusz 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or (at 8 | * your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #include "platform.h" 21 | 22 | #ifdef _MSC_VER 23 | 24 | inline double _plfit_fmin(double a, double b) { 25 | return (a < b) ? a : b; 26 | } 27 | 28 | inline double _plfit_round(double x) { 29 | return floor(x+0.5); 30 | } 31 | 32 | #endif 33 | 34 | /* Dummy function to prevent a warning when compiling with Clang - the file 35 | * would contain no symbols */ 36 | void _plfit_i_unused() {} 37 | -------------------------------------------------------------------------------- /igraph/src/dtime_.c: -------------------------------------------------------------------------------- 1 | #include "time.h" 2 | 3 | #ifdef MSDOS 4 | #undef USE_CLOCK 5 | #define USE_CLOCK 6 | #endif 7 | 8 | #ifndef REAL 9 | #define REAL double 10 | #endif 11 | 12 | #ifndef USE_CLOCK 13 | #define _INCLUDE_POSIX_SOURCE /* for HP-UX */ 14 | #define _INCLUDE_XOPEN_SOURCE /* for HP-UX */ 15 | #include "sys/types.h" 16 | #include "sys/times.h" 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | #endif 21 | 22 | #undef Hz 23 | #ifdef CLK_TCK 24 | #define Hz CLK_TCK 25 | #else 26 | #ifdef HZ 27 | #define Hz HZ 28 | #else 29 | #define Hz 60 30 | #endif 31 | #endif 32 | 33 | REAL 34 | #ifdef KR_headers 35 | dtime_(tarray) float *tarray; 36 | #else 37 | dtime_(float *tarray) 38 | #endif 39 | { 40 | #ifdef USE_CLOCK 41 | #ifndef CLOCKS_PER_SECOND 42 | #define CLOCKS_PER_SECOND Hz 43 | #endif 44 | static double t0; 45 | double t = clock(); 46 | tarray[1] = 0; 47 | tarray[0] = (t - t0) / CLOCKS_PER_SECOND; 48 | t0 = t; 49 | return tarray[0]; 50 | #else 51 | struct tms t; 52 | static struct tms t0; 53 | 54 | times(&t); 55 | tarray[0] = (double)(t.tms_utime - t0.tms_utime) / Hz; 56 | tarray[1] = (double)(t.tms_stime - t0.tms_stime) / Hz; 57 | t0 = t; 58 | return tarray[0] + tarray[1]; 59 | #endif 60 | } 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | -------------------------------------------------------------------------------- /cbits/haskell_igraph.c: -------------------------------------------------------------------------------- 1 | #include "haskell_attributes.h" 2 | 3 | const igraph_attribute_table_t igraph_haskell_attribute_table={ 4 | &igraph_haskell_attribute_init, &igraph_haskell_attribute_destroy, 5 | &igraph_haskell_attribute_copy, &igraph_haskell_attribute_add_vertices, 6 | &igraph_haskell_attribute_permute_vertices, 7 | &igraph_haskell_attribute_combine_vertices, &igraph_haskell_attribute_add_edges, 8 | &igraph_haskell_attribute_permute_edges, 9 | &igraph_haskell_attribute_combine_edges, 10 | &igraph_haskell_attribute_get_info, 11 | &igraph_haskell_attribute_has_attr, &igraph_haskell_attribute_gettype, 12 | &igraph_haskell_attribute_get_numeric_graph_attr, 13 | &igraph_haskell_attribute_get_string_graph_attr, 14 | &igraph_haskell_attribute_get_bool_graph_attr, 15 | &igraph_haskell_attribute_get_numeric_vertex_attr, 16 | &igraph_haskell_attribute_get_string_vertex_attr, 17 | &igraph_haskell_attribute_get_bool_vertex_attr, 18 | &igraph_haskell_attribute_get_numeric_edge_attr, 19 | &igraph_haskell_attribute_get_string_edge_attr, 20 | &igraph_haskell_attribute_get_bool_edge_attr 21 | }; 22 | 23 | void haskelligraph_init() 24 | { 25 | /* attach attribute table */ 26 | igraph_i_set_attribute_table(&igraph_haskell_attribute_table); 27 | } 28 | -------------------------------------------------------------------------------- /igraph/src/cs_droptol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | static CS_INT cs_tol (CS_INT i, CS_INT j, CS_ENTRY aij, void *tol) 23 | { 24 | return (CS_ABS (aij) > *((double *) tol)) ; 25 | } 26 | CS_INT cs_droptol (cs *A, double tol) 27 | { 28 | return (cs_fkeep (A, &cs_tol, &tol)) ; /* keep all large entries */ 29 | } 30 | -------------------------------------------------------------------------------- /igraph/src/second.c: -------------------------------------------------------------------------------- 1 | /* -- translated by f2c (version 20100827). 2 | You must link the resulting object file with libf2c: 3 | on Microsoft Windows system, link with libf2c.lib; 4 | on Linux or Unix systems, link with .../path/to/libf2c.a -lm 5 | or, if you install libf2c.a in a standard place, with -lf2c -lm 6 | -- in that order, at the end of the command line, as in 7 | cc *.o -lf2c -lm 8 | Source for libf2c is in /netlib/f2c/libf2c.zip, e.g., 9 | 10 | http://www.netlib.org/f2c/libf2c.zip 11 | */ 12 | 13 | #include "f2c.h" 14 | 15 | /* Subroutine */ int igraphsecond_(real *t) 16 | { 17 | real t1; 18 | extern doublereal etime_(real *); 19 | real tarray[2]; 20 | 21 | 22 | 23 | /* -- LAPACK auxiliary routine (preliminary version) -- 24 | Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., 25 | Courant Institute, Argonne National Lab, and Rice University 26 | July 26, 1991 27 | 28 | Purpose 29 | ======= 30 | 31 | SECOND returns the user time for a process in seconds. 32 | This version gets the time from the system function ETIME. */ 33 | 34 | 35 | t1 = etime_(tarray); 36 | *t = tarray[0]; 37 | return 0; 38 | 39 | /* End of SECOND */ 40 | 41 | } /* igraphsecond_ */ 42 | 43 | -------------------------------------------------------------------------------- /igraph/include/foreign-ncol-header.h: -------------------------------------------------------------------------------- 1 | /* 2 | IGraph library. 3 | Copyright (C) 2011-2012 Gabor Csardi 4 | 334 Harvard street, Cambridge MA, 02139 USA 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 | 02110-1301 USA 20 | 21 | */ 22 | 23 | #include "igraph_vector.h" 24 | #include "igraph_types_internal.h" 25 | 26 | typedef struct { 27 | void *scanner; 28 | int eof; 29 | char errmsg[300]; 30 | int has_weights; 31 | igraph_vector_t *vector; 32 | igraph_vector_t *weights; 33 | igraph_trie_t *trie; 34 | } igraph_i_ncol_parsedata_t; 35 | -------------------------------------------------------------------------------- /igraph/src/s_copy.c: -------------------------------------------------------------------------------- 1 | /* Unless compiled with -DNO_OVERWRITE, this variant of s_copy allows the 2 | * target of an assignment to appear on its right-hand side (contrary 3 | * to the Fortran 77 Standard, but in accordance with Fortran 90), 4 | * as in a(2:5) = a(4:7) . 5 | */ 6 | 7 | #include "f2c.h" 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | /* assign strings: a = b */ 13 | 14 | #ifdef KR_headers 15 | VOID s_copy(a, b, la, lb) register char *a, *b; ftnlen la, lb; 16 | #else 17 | void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb) 18 | #endif 19 | { 20 | register char *aend, *bend; 21 | 22 | aend = a + la; 23 | 24 | if(la <= lb) 25 | #ifndef NO_OVERWRITE 26 | if (a <= b || a >= b + la) 27 | #endif 28 | while(a < aend) 29 | *a++ = *b++; 30 | #ifndef NO_OVERWRITE 31 | else 32 | for(b += la; a < aend; ) 33 | *--aend = *--b; 34 | #endif 35 | 36 | else { 37 | bend = b + lb; 38 | #ifndef NO_OVERWRITE 39 | if (a <= b || a >= bend) 40 | #endif 41 | while(b < bend) 42 | *a++ = *b++; 43 | #ifndef NO_OVERWRITE 44 | else { 45 | a += lb; 46 | while(b < bend) 47 | *--a = *--bend; 48 | a += lb; 49 | } 50 | #endif 51 | while(a < aend) 52 | *a++ = ' '; 53 | } 54 | } 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /igraph/include/foreign-lgl-header.h: -------------------------------------------------------------------------------- 1 | /* 2 | IGraph library. 3 | Copyright (C) 2011-2012 Gabor Csardi 4 | 334 Harvard street, Cambridge MA, 02139 USA 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 | 02110-1301 USA 20 | 21 | */ 22 | 23 | #include "igraph_vector.h" 24 | #include "igraph_types_internal.h" 25 | 26 | typedef struct { 27 | void *scanner; 28 | int eof; 29 | char errmsg[300]; 30 | int has_weights; 31 | igraph_vector_t *vector; 32 | igraph_vector_t *weights; 33 | igraph_trie_t *trie; 34 | int actvertex; 35 | } igraph_i_lgl_parsedata_t; 36 | -------------------------------------------------------------------------------- /igraph/src/cs_ipvec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* x(p) = b, for dense vectors x and b; p=NULL denotes identity */ 23 | CS_INT cs_ipvec (const CS_INT *p, const CS_ENTRY *b, CS_ENTRY *x, CS_INT n) 24 | { 25 | CS_INT k ; 26 | if (!x || !b) return (0) ; /* check inputs */ 27 | for (k = 0 ; k < n ; k++) x [p ? p [k] : k] = b [k] ; 28 | return (1) ; 29 | } 30 | -------------------------------------------------------------------------------- /igraph/src/cs_pvec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* x = b(p), for dense vectors x and b; p=NULL denotes identity */ 23 | CS_INT cs_pvec (const CS_INT *p, const CS_ENTRY *b, CS_ENTRY *x, CS_INT n) 24 | { 25 | CS_INT k ; 26 | if (!x || !b) return (0) ; /* check inputs */ 27 | for (k = 0 ; k < n ; k++) x [k] = b [p ? p [k] : k] ; 28 | return (1) ; 29 | } 30 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_preprocessed_scc_graph.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_PREPROCESSED_SCC_GRAPH 2 | #define PRPACK_PREPROCESSED_SCC_GRAPH 3 | #include "prpack_preprocessed_graph.h" 4 | #include "prpack_base_graph.h" 5 | 6 | namespace prpack { 7 | 8 | // Pre-processed graph class 9 | class prpack_preprocessed_scc_graph : public prpack_preprocessed_graph { 10 | private: 11 | // helper methods 12 | void initialize(); 13 | void initialize_weighted(const prpack_base_graph* bg); 14 | void initialize_unweighted(const prpack_base_graph* bg); 15 | public: 16 | // instance variables 17 | int num_es_inside; 18 | int* heads_inside; 19 | int* tails_inside; 20 | double* vals_inside; 21 | int num_es_outside; 22 | int* heads_outside; 23 | int* tails_outside; 24 | double* vals_outside; 25 | double* ii; 26 | double* num_outlinks; 27 | int num_comps; 28 | int* divisions; 29 | int* encoding; 30 | int* decoding; 31 | // constructors 32 | prpack_preprocessed_scc_graph(const prpack_base_graph* bg); 33 | // destructor 34 | ~prpack_preprocessed_scc_graph(); 35 | }; 36 | 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/IGraph/Types.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DataKinds #-} 2 | {-# LANGUAGE DeriveGeneric #-} 3 | {-# LANGUAGE EmptyCase #-} 4 | {-# LANGUAGE FlexibleContexts #-} 5 | {-# LANGUAGE FlexibleInstances #-} 6 | {-# LANGUAGE FunctionalDependencies #-} 7 | {-# LANGUAGE GADTs #-} 8 | {-# LANGUAGE InstanceSigs #-} 9 | {-# LANGUAGE MultiParamTypeClasses #-} 10 | {-# LANGUAGE ScopedTypeVariables #-} 11 | {-# LANGUAGE StandaloneDeriving #-} 12 | {-# LANGUAGE TemplateHaskell #-} 13 | {-# LANGUAGE TypeFamilies #-} 14 | {-# LANGUAGE TypeOperators #-} 15 | {-# LANGUAGE UndecidableInstances #-} 16 | {-# LANGUAGE StandaloneKindSignatures #-} 17 | 18 | module IGraph.Types where 19 | 20 | import Data.Serialize (Serialize) 21 | import Data.Singletons.Prelude 22 | import Data.Singletons.TH 23 | import GHC.Generics (Generic) 24 | 25 | $(singletons [d| 26 | data EdgeType = D 27 | | U 28 | deriving (Eq, Generic) 29 | |]) 30 | 31 | instance Serialize EdgeType 32 | 33 | type Node = Int 34 | type LNode a = (Node, a) 35 | 36 | type Edge = (Node, Node) 37 | type LEdge a = (Edge, a) 38 | 39 | vertexAttr :: String 40 | vertexAttr = "vertex_attribute" 41 | 42 | edgeAttr :: String 43 | edgeAttr = "edge_attribute" 44 | -------------------------------------------------------------------------------- /igraph/include/igraph_threading.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2011-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_THREADING_H 25 | #define IGRAPH_THREADING_H 26 | 27 | #include "igraph_decls.h" 28 | 29 | __BEGIN_DECLS 30 | 31 | /** 32 | * \define IGRAPH_THREAD_SAFE 33 | * 34 | * Macro that is defined to be 1 if the current build of the 35 | * igraph library is thread-safe, and 0 if it is not. 36 | */ 37 | 38 | #define IGRAPH_THREAD_SAFE 0 39 | 40 | __END_DECLS 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /igraph/include/igraph_threading.h.in: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2011-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_THREADING_H 25 | #define IGRAPH_THREADING_H 26 | 27 | #include "igraph_decls.h" 28 | 29 | __BEGIN_DECLS 30 | 31 | /** 32 | * \define IGRAPH_THREAD_SAFE 33 | * 34 | * Macro that is defined to be 1 if the current build of the 35 | * igraph library is thread-safe, and 0 if it is not. 36 | */ 37 | 38 | #define IGRAPH_THREAD_SAFE @HAVE_TLS@ 39 | 40 | __END_DECLS 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /igraph/src/lbitbits.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | 6 | #ifndef LONGBITS 7 | #define LONGBITS 32 8 | #endif 9 | 10 | integer 11 | #ifdef KR_headers 12 | lbit_bits(a, b, len) integer a, b, len; 13 | #else 14 | lbit_bits(integer a, integer b, integer len) 15 | #endif 16 | { 17 | /* Assume 2's complement arithmetic */ 18 | 19 | unsigned long x, y; 20 | 21 | x = (unsigned long) a; 22 | y = (unsigned long)-1L; 23 | x >>= b; 24 | y <<= len; 25 | return (integer)(x & ~y); 26 | } 27 | 28 | integer 29 | #ifdef KR_headers 30 | lbit_cshift(a, b, len) integer a, b, len; 31 | #else 32 | lbit_cshift(integer a, integer b, integer len) 33 | #endif 34 | { 35 | unsigned long x, y, z; 36 | 37 | x = (unsigned long)a; 38 | if (len <= 0) { 39 | if (len == 0) 40 | return 0; 41 | goto full_len; 42 | } 43 | if (len >= LONGBITS) { 44 | full_len: 45 | if (b >= 0) { 46 | b %= LONGBITS; 47 | return (integer)(x << b | x >> LONGBITS -b ); 48 | } 49 | b = -b; 50 | b %= LONGBITS; 51 | return (integer)(x << LONGBITS - b | x >> b); 52 | } 53 | y = z = (unsigned long)-1; 54 | y <<= len; 55 | z &= ~y; 56 | y &= x; 57 | x &= z; 58 | if (b >= 0) { 59 | b %= len; 60 | return (integer)(y | z & (x << b | x >> len - b)); 61 | } 62 | b = -b; 63 | b %= len; 64 | return (integer)(y | z & (x >> b | x << len - b)); 65 | } 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | -------------------------------------------------------------------------------- /igraph/include/igraph_cliquer.h: -------------------------------------------------------------------------------- 1 | #ifndef IGRAPH_CLIQUER_H 2 | #define IGRAPH_CLIQUER_H 3 | 4 | #include "igraph_types_internal.h" 5 | #include "igraph_interface.h" 6 | #include "igraph_cliques.h" 7 | 8 | int igraph_i_cliquer_cliques(const igraph_t *graph, igraph_vector_ptr_t *res, 9 | igraph_integer_t min_size, igraph_integer_t max_size); 10 | 11 | int igraph_i_cliquer_histogram(const igraph_t *graph, igraph_vector_t *hist, 12 | igraph_integer_t min_size, igraph_integer_t max_size); 13 | 14 | int igraph_i_cliquer_callback(const igraph_t *graph, 15 | igraph_integer_t min_size, igraph_integer_t max_size, 16 | igraph_clique_handler_t *cliquehandler_fn, void *arg); 17 | 18 | int igraph_i_weighted_cliques(const igraph_t *graph, 19 | const igraph_vector_t *vertex_weights, igraph_vector_ptr_t *res, 20 | igraph_real_t min_weight, igraph_real_t max_weight, igraph_bool_t maximal); 21 | 22 | int igraph_i_largest_weighted_cliques(const igraph_t *graph, 23 | const igraph_vector_t *vertex_weights, igraph_vector_ptr_t *res); 24 | 25 | int igraph_i_weighted_clique_number(const igraph_t *graph, 26 | const igraph_vector_t *vertex_weights, igraph_real_t *res); 27 | 28 | #endif // IGRAPH_CLIQUER_H 29 | 30 | -------------------------------------------------------------------------------- /igraph/include/plfit/kolmogorov.h: -------------------------------------------------------------------------------- 1 | /* kolmogorov.h 2 | * 3 | * Copyright (C) 2010-2011 Tamas Nepusz 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or (at 8 | * your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef __KOLMOGOROV_H__ 21 | #define __KOLMOGOROV_H__ 22 | 23 | #undef __BEGIN_DECLS 24 | #undef __END_DECLS 25 | #ifdef __cplusplus 26 | # define __BEGIN_DECLS extern "C" { 27 | # define __END_DECLS } 28 | #else 29 | # define __BEGIN_DECLS /* empty */ 30 | # define __END_DECLS /* empty */ 31 | #endif 32 | 33 | #include 34 | 35 | __BEGIN_DECLS 36 | 37 | double plfit_kolmogorov(double z); 38 | double plfit_ks_test_one_sample_p(double d, size_t n); 39 | double plfit_ks_test_two_sample_p(double d, size_t n1, size_t n2); 40 | 41 | __END_DECLS 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /igraph/include/igraph_qsort.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2011-2012 Gabor Csardi 5 | 334 Harvard st, Cambridge, MA 02139, USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_QSORT_H 25 | #define IGRAPH_QSORT_H 26 | 27 | #include "igraph_decls.h" 28 | 29 | #include 30 | 31 | __BEGIN_DECLS 32 | 33 | DECLDIR void igraph_qsort(void *base, size_t nel, size_t width, 34 | int (*compar)(const void *, const void *)); 35 | DECLDIR void igraph_qsort_r(void *base, size_t nel, size_t width, void *thunk, 36 | int (*compar)(void *, const void *, const void *)); 37 | 38 | __END_DECLS 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /igraph/include/prpack/prpack_base_graph.h: -------------------------------------------------------------------------------- 1 | #ifndef PRPACK_ADJACENCY_LIST 2 | #define PRPACK_ADJACENCY_LIST 3 | #include "prpack_csc.h" 4 | #include "prpack_csr.h" 5 | #include "prpack_edge_list.h" 6 | #include 7 | #include 8 | 9 | namespace prpack { 10 | 11 | class prpack_base_graph { 12 | private: 13 | // helper methods 14 | void initialize(); 15 | void read_smat(std::FILE* f, const bool weighted); 16 | void read_edges(std::FILE* f); 17 | void read_ascii(std::FILE* f); 18 | public: 19 | // instance variables 20 | int num_vs; 21 | int num_es; 22 | int num_self_es; 23 | int* heads; 24 | int* tails; 25 | double* vals; 26 | // constructors 27 | prpack_base_graph(); // only to support inheritance 28 | prpack_base_graph(const prpack_csc* g); 29 | prpack_base_graph(const prpack_int64_csc* g); 30 | prpack_base_graph(const prpack_csr* g); 31 | prpack_base_graph(const prpack_edge_list* g); 32 | prpack_base_graph(const char* filename, const char* format, const bool weighted); 33 | prpack_base_graph(int nverts, int nedges, std::pair* edges); 34 | // destructor 35 | ~prpack_base_graph(); 36 | // operations 37 | void normalize_weights(); 38 | }; 39 | 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /igraph/src/cs_entry.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* add an entry to a triplet matrix; return 1 if ok, 0 otherwise */ 23 | CS_INT cs_entry (cs *T, CS_INT i, CS_INT j, CS_ENTRY x) 24 | { 25 | if (!CS_TRIPLET (T) || i < 0 || j < 0) return (0) ; /* check inputs */ 26 | if (T->nz >= T->nzmax && !cs_sprealloc (T,2*(T->nzmax))) return (0) ; 27 | if (T->x) T->x [T->nz] = x ; 28 | T->i [T->nz] = i ; 29 | T->p [T->nz++] = j ; 30 | T->m = CS_MAX (T->m, i+1) ; 31 | T->n = CS_MAX (T->n, j+1) ; 32 | return (1) ; 33 | } 34 | -------------------------------------------------------------------------------- /igraph/src/cs_gaxpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* y = A*x+y */ 23 | CS_INT cs_gaxpy (const cs *A, const CS_ENTRY *x, CS_ENTRY *y) 24 | { 25 | CS_INT p, j, n, *Ap, *Ai ; 26 | CS_ENTRY *Ax ; 27 | if (!CS_CSC (A) || !x || !y) return (0) ; /* check inputs */ 28 | n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ; 29 | for (j = 0 ; j < n ; j++) 30 | { 31 | for (p = Ap [j] ; p < Ap [j+1] ; p++) 32 | { 33 | y [Ai [p]] += Ax [p] * x [j] ; 34 | } 35 | } 36 | return (1) ; 37 | } 38 | -------------------------------------------------------------------------------- /igraph/src/cs_pinv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* pinv = p', or p = pinv' */ 23 | CS_INT *cs_pinv (CS_INT const *p, CS_INT n) 24 | { 25 | CS_INT k, *pinv ; 26 | if (!p) return (NULL) ; /* p = NULL denotes identity */ 27 | pinv = cs_malloc (n, sizeof (CS_INT)) ; /* allocate result */ 28 | if (!pinv) return (NULL) ; /* out of memory */ 29 | for (k = 0 ; k < n ; k++) pinv [p [k]] = k ;/* invert the permutation */ 30 | return (pinv) ; /* return result */ 31 | } 32 | -------------------------------------------------------------------------------- /igraph/src/getenv_.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #undef abs 3 | #ifdef KR_headers 4 | extern char *F77_aloc(), *getenv(); 5 | #else 6 | #include 7 | #include 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | extern char *F77_aloc(ftnlen, const char*); 12 | #endif 13 | 14 | /* 15 | * getenv - f77 subroutine to return environment variables 16 | * 17 | * called by: 18 | * call getenv (ENV_NAME, char_var) 19 | * where: 20 | * ENV_NAME is the name of an environment variable 21 | * char_var is a character variable which will receive 22 | * the current value of ENV_NAME, or all blanks 23 | * if ENV_NAME is not defined 24 | */ 25 | 26 | #ifdef KR_headers 27 | VOID 28 | getenv_(fname, value, flen, vlen) char *value, *fname; ftnlen vlen, flen; 29 | #else 30 | void 31 | getenv_(char *fname, char *value, ftnlen flen, ftnlen vlen) 32 | #endif 33 | { 34 | char buf[256], *ep, *fp; 35 | integer i; 36 | 37 | if (flen <= 0) 38 | goto add_blanks; 39 | for(i = 0; i < sizeof(buf); i++) { 40 | if (i == flen || (buf[i] = fname[i]) == ' ') { 41 | buf[i] = 0; 42 | ep = getenv(buf); 43 | goto have_ep; 44 | } 45 | } 46 | while(i < flen && fname[i] != ' ') 47 | i++; 48 | strncpy(fp = F77_aloc(i+1, "getenv_"), fname, (int)i); 49 | fp[i] = 0; 50 | ep = getenv(fp); 51 | free(fp); 52 | have_ep: 53 | if (ep) 54 | while(*ep && vlen-- > 0) 55 | *value++ = *ep++; 56 | add_blanks: 57 | while(vlen-- > 0) 58 | *value++ = ' '; 59 | } 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | -------------------------------------------------------------------------------- /igraph/src/ilnw.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #include "lio.h" 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | extern char *f__icptr; 8 | extern char *f__icend; 9 | extern icilist *f__svic; 10 | extern int f__icnum; 11 | #ifdef KR_headers 12 | extern void z_putc(); 13 | #else 14 | extern void z_putc(int); 15 | #endif 16 | 17 | static int 18 | z_wSL(Void) 19 | { 20 | while(f__recpos < f__svic->icirlen) 21 | z_putc(' '); 22 | return z_rnew(); 23 | } 24 | 25 | static void 26 | #ifdef KR_headers 27 | c_liw(a) icilist *a; 28 | #else 29 | c_liw(icilist *a) 30 | #endif 31 | { 32 | f__reading = 0; 33 | f__external = 0; 34 | f__formatted = 1; 35 | f__putn = z_putc; 36 | L_len = a->icirlen; 37 | f__donewrec = z_wSL; 38 | f__svic = a; 39 | f__icnum = f__recpos = 0; 40 | f__cursor = 0; 41 | f__cf = 0; 42 | f__curunit = 0; 43 | f__icptr = a->iciunit; 44 | f__icend = f__icptr + a->icirlen*a->icirnum; 45 | f__elist = (cilist *)a; 46 | } 47 | 48 | integer 49 | #ifdef KR_headers 50 | s_wsni(a) icilist *a; 51 | #else 52 | s_wsni(icilist *a) 53 | #endif 54 | { 55 | cilist ca; 56 | 57 | c_liw(a); 58 | ca.cifmt = a->icifmt; 59 | x_wsne(&ca); 60 | z_wSL(); 61 | return 0; 62 | } 63 | 64 | integer 65 | #ifdef KR_headers 66 | s_wsli(a) icilist *a; 67 | #else 68 | s_wsli(icilist *a) 69 | #endif 70 | { 71 | f__lioproc = l_write; 72 | c_liw(a); 73 | return(0); 74 | } 75 | 76 | integer e_wsli(Void) 77 | { 78 | z_wSL(); 79 | return(0); 80 | } 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | -------------------------------------------------------------------------------- /igraph/include/igraph_version.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2010-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_VERSION_H 25 | #define IGRAPH_VERSION_H 26 | 27 | #include "igraph_decls.h" 28 | 29 | __BEGIN_DECLS 30 | 31 | #define IGRAPH_VERSION "0.8.5" 32 | #define IGRAPH_VERSION_MAJOR 0 33 | #define IGRAPH_VERSION_MINOR 8 34 | #define IGRAPH_VERSION_PATCH 5 35 | #define IGRAPH_VERSION_PRERELEASE "" 36 | 37 | DECLDIR int igraph_version(const char **version_string, 38 | int *major, 39 | int *minor, 40 | int *subminor); 41 | 42 | __END_DECLS 43 | 44 | #endif 45 | 46 | 47 | -------------------------------------------------------------------------------- /igraph/src/cs_norm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* 1-norm of a sparse matrix = max (sum (abs (A))), largest column sum */ 23 | double cs_norm (const cs *A) 24 | { 25 | CS_INT p, j, n, *Ap ; 26 | CS_ENTRY *Ax ; 27 | double norm = 0, s ; 28 | if (!CS_CSC (A) || !A->x) return (-1) ; /* check inputs */ 29 | n = A->n ; Ap = A->p ; Ax = A->x ; 30 | for (j = 0 ; j < n ; j++) 31 | { 32 | for (s = 0, p = Ap [j] ; p < Ap [j+1] ; p++) s += CS_ABS (Ax [p]) ; 33 | norm = CS_MAX (norm, s) ; 34 | } 35 | return (norm) ; 36 | } 37 | -------------------------------------------------------------------------------- /igraph/src/xwsne.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #include "lio.h" 4 | #include "fmt.h" 5 | 6 | extern int f__Aquote; 7 | 8 | static VOID 9 | nl_donewrec(Void) 10 | { 11 | (*f__donewrec)(); 12 | PUT(' '); 13 | } 14 | 15 | #ifdef KR_headers 16 | x_wsne(a) cilist *a; 17 | #else 18 | #include "string.h" 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | VOID 24 | x_wsne(cilist *a) 25 | #endif 26 | { 27 | Namelist *nl; 28 | char *s; 29 | Vardesc *v, **vd, **vde; 30 | ftnint number, type; 31 | ftnlen *dims; 32 | ftnlen size; 33 | extern ftnlen f__typesize[]; 34 | 35 | nl = (Namelist *)a->cifmt; 36 | PUT('&'); 37 | for(s = nl->name; *s; s++) 38 | PUT(*s); 39 | PUT(' '); 40 | f__Aquote = 1; 41 | vd = nl->vars; 42 | vde = vd + nl->nvars; 43 | while(vd < vde) { 44 | v = *vd++; 45 | s = v->name; 46 | #ifdef No_Extra_Namelist_Newlines 47 | if (f__recpos+strlen(s)+2 >= L_len) 48 | #endif 49 | nl_donewrec(); 50 | while(*s) 51 | PUT(*s++); 52 | PUT(' '); 53 | PUT('='); 54 | number = (dims = v->dims) ? dims[1] : 1; 55 | type = v->type; 56 | if (type < 0) { 57 | size = -type; 58 | type = TYCHAR; 59 | } 60 | else 61 | size = f__typesize[type]; 62 | l_write(&number, v->addr, size, type); 63 | if (vd < vde) { 64 | if (f__recpos+2 >= L_len) 65 | nl_donewrec(); 66 | PUT(','); 67 | PUT(' '); 68 | } 69 | else if (f__recpos+1 >= L_len) 70 | nl_donewrec(); 71 | } 72 | f__Aquote = 0; 73 | PUT('/'); 74 | } 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | -------------------------------------------------------------------------------- /igraph/include/foreign-dl-header.h: -------------------------------------------------------------------------------- 1 | /* 2 | IGraph library. 3 | Copyright (C) 2009-2012 Gabor Csardi 4 | 334 Harvard street, Cambridge, MA 02139 USA 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 | 02110-1301 USA 20 | 21 | */ 22 | 23 | #include "igraph_types.h" 24 | #include "igraph_types_internal.h" 25 | 26 | typedef enum { IGRAPH_DL_MATRIX, 27 | IGRAPH_DL_EDGELIST1, IGRAPH_DL_NODELIST1 28 | } igraph_i_dl_type_t; 29 | 30 | typedef struct { 31 | void *scanner; 32 | int eof; 33 | int mode; 34 | long int n; 35 | long int from, to; 36 | igraph_vector_t edges; 37 | igraph_vector_t weights; 38 | igraph_strvector_t labels; 39 | igraph_trie_t trie; 40 | igraph_i_dl_type_t type; 41 | char errmsg[300]; 42 | } igraph_i_dl_parsedata_t; 43 | -------------------------------------------------------------------------------- /igraph/include/igraph_cohesive_blocks.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2010-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_COHESIVE_BLOCKS_H 25 | #define IGRAPH_COHESIVE_BLOCKS_H 26 | 27 | #include "igraph_datatype.h" 28 | #include "igraph_vector.h" 29 | #include "igraph_vector_ptr.h" 30 | 31 | __BEGIN_DECLS 32 | 33 | DECLDIR int igraph_cohesive_blocks(const igraph_t *graph, 34 | igraph_vector_ptr_t *blocks, 35 | igraph_vector_t *cohesion, 36 | igraph_vector_t *parent, 37 | igraph_t *block_tree); 38 | 39 | __END_DECLS 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /igraph/src/fortran_intrinsics.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2011-12 Gabor Csardi 5 | 334 Harvard street, Cambridge MA, 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #include 25 | 26 | double digitsdbl_(double *x) { 27 | return (double) DBL_MANT_DIG; 28 | } 29 | 30 | double epsilondbl_(double *x) { 31 | return DBL_EPSILON; 32 | } 33 | 34 | double hugedbl_(double *x) { 35 | return DBL_MAX; 36 | } 37 | 38 | double tinydbl_(double *x) { 39 | return DBL_MIN; 40 | } 41 | 42 | int maxexponentdbl_(double *x) { 43 | return DBL_MAX_EXP; 44 | } 45 | 46 | int minexponentdbl_(double *x) { 47 | return DBL_MIN_EXP; 48 | } 49 | 50 | double radixdbl_(double *x) { 51 | return (double) FLT_RADIX; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /igraph/src/cs_lsolve.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* solve Lx=b where x and b are dense. x=b on input, solution on output. */ 23 | CS_INT cs_lsolve (const cs *L, CS_ENTRY *x) 24 | { 25 | CS_INT p, j, n, *Lp, *Li ; 26 | CS_ENTRY *Lx ; 27 | if (!CS_CSC (L) || !x) return (0) ; /* check inputs */ 28 | n = L->n ; Lp = L->p ; Li = L->i ; Lx = L->x ; 29 | for (j = 0 ; j < n ; j++) 30 | { 31 | x [j] /= Lx [Lp [j]] ; 32 | for (p = Lp [j]+1 ; p < Lp [j+1] ; p++) 33 | { 34 | x [Li [p]] -= Lx [p] * x [j] ; 35 | } 36 | } 37 | return (1) ; 38 | } 39 | -------------------------------------------------------------------------------- /igraph/src/cs_usolve.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* solve Ux=b where x and b are dense. x=b on input, solution on output. */ 23 | CS_INT cs_usolve (const cs *U, CS_ENTRY *x) 24 | { 25 | CS_INT p, j, n, *Up, *Ui ; 26 | CS_ENTRY *Ux ; 27 | if (!CS_CSC (U) || !x) return (0) ; /* check inputs */ 28 | n = U->n ; Up = U->p ; Ui = U->i ; Ux = U->x ; 29 | for (j = n-1 ; j >= 0 ; j--) 30 | { 31 | x [j] /= Ux [Up [j+1]-1] ; 32 | for (p = Up [j] ; p < Up [j+1]-1 ; p++) 33 | { 34 | x [Ui [p]] -= Ux [p] * x [j] ; 35 | } 36 | } 37 | return (1) ; 38 | } 39 | -------------------------------------------------------------------------------- /igraph/src/cs_ltsolve.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* solve L'x=b where x and b are dense. x=b on input, solution on output. */ 23 | CS_INT cs_ltsolve (const cs *L, CS_ENTRY *x) 24 | { 25 | CS_INT p, j, n, *Lp, *Li ; 26 | CS_ENTRY *Lx ; 27 | if (!CS_CSC (L) || !x) return (0) ; /* check inputs */ 28 | n = L->n ; Lp = L->p ; Li = L->i ; Lx = L->x ; 29 | for (j = n-1 ; j >= 0 ; j--) 30 | { 31 | for (p = Lp [j]+1 ; p < Lp [j+1] ; p++) 32 | { 33 | x [j] -= CS_CONJ (Lx [p]) * x [Li [p]] ; 34 | } 35 | x [j] /= CS_CONJ (Lx [Lp [j]]) ; 36 | } 37 | return (1) ; 38 | } 39 | -------------------------------------------------------------------------------- /igraph/src/cs_utsolve.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* solve U'x=b where x and b are dense. x=b on input, solution on output. */ 23 | CS_INT cs_utsolve (const cs *U, CS_ENTRY *x) 24 | { 25 | CS_INT p, j, n, *Up, *Ui ; 26 | CS_ENTRY *Ux ; 27 | if (!CS_CSC (U) || !x) return (0) ; /* check inputs */ 28 | n = U->n ; Up = U->p ; Ui = U->i ; Ux = U->x ; 29 | for (j = 0 ; j < n ; j++) 30 | { 31 | for (p = Up [j] ; p < Up [j+1]-1 ; p++) 32 | { 33 | x [j] -= CS_CONJ (Ux [p]) * x [Ui [p]] ; 34 | } 35 | x [j] /= CS_CONJ (Ux [Up [j+1]-1]) ; 36 | } 37 | return (1) ; 38 | } 39 | -------------------------------------------------------------------------------- /igraph/include/foreign-pajek-header.h: -------------------------------------------------------------------------------- 1 | /* 2 | IGraph library. 3 | Copyright (C) 2011-2012 Gabor Csardi 4 | 334 Harvard street, Cambridge MA, 02139 USA 5 | 6 | This program is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 2 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program; if not, write to the Free Software 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 | 02110-1301 USA 20 | 21 | */ 22 | 23 | #include "igraph_vector.h" 24 | #include "igraph_types_internal.h" 25 | 26 | typedef struct { 27 | void *scanner; 28 | int eof; 29 | char errmsg[300]; 30 | igraph_vector_t *vector; 31 | igraph_bool_t directed; 32 | int vcount, vcount2; 33 | int actfrom; 34 | int actto; 35 | int mode; /* 0: general, 1: vertex, 2: edge */ 36 | igraph_trie_t *vertex_attribute_names; 37 | igraph_vector_ptr_t *vertex_attributes; 38 | igraph_trie_t *edge_attribute_names; 39 | igraph_vector_ptr_t *edge_attributes; 40 | int vertexid; 41 | int actvertex; 42 | int actedge; 43 | } igraph_i_pajek_parsedata_t; 44 | -------------------------------------------------------------------------------- /igraph/include/infomap_Node.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* vim:set ts=4 sw=4 sts=4 et: */ 3 | /* 4 | IGraph library. 5 | Copyright (C) 2011-2012 Gabor Csardi 6 | 334 Harvard street, Cambridge, MA 02139 USA 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | 02110-1301 USA 22 | 23 | */ 24 | 25 | #ifndef NODE_H 26 | #define NODE_H 27 | 28 | #include 29 | #include 30 | 31 | #include "igraph_interface.h" 32 | 33 | class Node { 34 | public: 35 | 36 | Node(); 37 | Node(int modulenr, double tpweight); 38 | 39 | std::vector members; 40 | std::vector< std::pair > inLinks; 41 | std::vector< std::pair > outLinks; 42 | double selfLink; 43 | 44 | double teleportWeight; 45 | double danglingSize; 46 | double exit; 47 | double size; 48 | }; 49 | 50 | void cpyNode(Node *newNode, Node *oldNode); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /igraph/src/array.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2006-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #include "igraph_types.h" 25 | #include "igraph_vector.h" 26 | #include "igraph_array.h" 27 | 28 | #define BASE_IGRAPH_REAL 29 | #include "igraph_pmt.h" 30 | #include "array.pmt" 31 | #include "igraph_pmt_off.h" 32 | #undef BASE_IGRAPH_REAL 33 | 34 | #define BASE_LONG 35 | #include "igraph_pmt.h" 36 | #include "array.pmt" 37 | #include "igraph_pmt_off.h" 38 | #undef BASE_LONG 39 | 40 | #define BASE_CHAR 41 | #include "igraph_pmt.h" 42 | #include "array.pmt" 43 | #include "igraph_pmt_off.h" 44 | #undef BASE_CHAR 45 | 46 | #define BASE_BOOL 47 | #include "igraph_pmt.h" 48 | #include "array.pmt" 49 | #include "igraph_pmt_off.h" 50 | #undef BASE_BOOL 51 | -------------------------------------------------------------------------------- /igraph/include/igraph_version.h.in: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2010-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_VERSION_H 25 | #define IGRAPH_VERSION_H 26 | 27 | #include "igraph_decls.h" 28 | 29 | __BEGIN_DECLS 30 | 31 | #define IGRAPH_VERSION "@PACKAGE_VERSION@" 32 | #define IGRAPH_VERSION_MAJOR @PACKAGE_VERSION_MAJOR@ 33 | #define IGRAPH_VERSION_MINOR @PACKAGE_VERSION_MINOR@ 34 | #define IGRAPH_VERSION_PATCH @PACKAGE_VERSION_PATCH@ 35 | #define IGRAPH_VERSION_PRERELEASE "@PACKAGE_VERSION_PRERELEASE@" 36 | 37 | DECLDIR int igraph_version(const char **version_string, 38 | int *major, 39 | int *minor, 40 | int *subminor); 41 | 42 | __END_DECLS 43 | 44 | #endif 45 | 46 | 47 | -------------------------------------------------------------------------------- /igraph/src/cs_cumsum.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* p [0..n] = cumulative sum of c [0..n-1], and then copy p [0..n-1] into c */ 23 | double cs_cumsum (CS_INT *p, CS_INT *c, CS_INT n) 24 | { 25 | CS_INT i, nz = 0 ; 26 | double nz2 = 0 ; 27 | if (!p || !c) return (-1) ; /* check inputs */ 28 | for (i = 0 ; i < n ; i++) 29 | { 30 | p [i] = nz ; 31 | nz += c [i] ; 32 | nz2 += c [i] ; /* also in double to avoid CS_INT overflow */ 33 | c [i] = p [i] ; /* also copy p[0..n-1] back into c[0..n-1]*/ 34 | } 35 | p [n] = nz ; 36 | return (nz2) ; /* return sum (c [0..n-1]) */ 37 | } 38 | -------------------------------------------------------------------------------- /igraph/src/wsfe.c: -------------------------------------------------------------------------------- 1 | /*write sequential formatted external*/ 2 | #include "f2c.h" 3 | #include "fio.h" 4 | #include "fmt.h" 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | int 10 | x_wSL(Void) 11 | { 12 | int n = f__putbuf('\n'); 13 | f__hiwater = f__recpos = f__cursor = 0; 14 | return(n == 0); 15 | } 16 | 17 | static int 18 | xw_end(Void) 19 | { 20 | int n; 21 | 22 | if(f__nonl) { 23 | f__putbuf(n = 0); 24 | fflush(f__cf); 25 | } 26 | else 27 | n = f__putbuf('\n'); 28 | f__hiwater = f__recpos = f__cursor = 0; 29 | return n; 30 | } 31 | 32 | static int 33 | xw_rev(Void) 34 | { 35 | int n = 0; 36 | if(f__workdone) { 37 | n = f__putbuf('\n'); 38 | f__workdone = 0; 39 | } 40 | f__hiwater = f__recpos = f__cursor = 0; 41 | return n; 42 | } 43 | 44 | #ifdef KR_headers 45 | integer s_wsfe(a) cilist *a; /*start*/ 46 | #else 47 | integer s_wsfe(cilist *a) /*start*/ 48 | #endif 49 | { int n; 50 | if(!f__init) f_init(); 51 | f__reading=0; 52 | f__sequential=1; 53 | f__formatted=1; 54 | f__external=1; 55 | if(n=c_sfe(a)) return(n); 56 | f__elist=a; 57 | f__hiwater = f__cursor=f__recpos=0; 58 | f__nonl = 0; 59 | f__scale=0; 60 | f__fmtbuf=a->cifmt; 61 | f__cf=f__curunit->ufd; 62 | if(pars_f(f__fmtbuf)<0) err(a->cierr,100,"startio"); 63 | f__putn= x_putc; 64 | f__doed= w_ed; 65 | f__doned= w_ned; 66 | f__doend=xw_end; 67 | f__dorevert=xw_rev; 68 | f__donewrec=x_wSL; 69 | fmt_bg(); 70 | f__cplus=0; 71 | f__cblank=f__curunit->ublnk; 72 | if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) 73 | err(a->cierr,errno,"write start"); 74 | return(0); 75 | } 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | -------------------------------------------------------------------------------- /igraph/src/interrupt.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2005-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #include "igraph_interrupt.h" 25 | #include "config.h" 26 | 27 | IGRAPH_THREAD_LOCAL igraph_interruption_handler_t 28 | *igraph_i_interruption_handler = 0; 29 | 30 | int igraph_allow_interruption(void* data) { 31 | if (igraph_i_interruption_handler) { 32 | return igraph_i_interruption_handler(data); 33 | } 34 | return IGRAPH_SUCCESS; 35 | } 36 | 37 | igraph_interruption_handler_t * 38 | igraph_set_interruption_handler (igraph_interruption_handler_t * new_handler) { 39 | igraph_interruption_handler_t * previous_handler = igraph_i_interruption_handler; 40 | igraph_i_interruption_handler = new_handler; 41 | return previous_handler; 42 | } 43 | -------------------------------------------------------------------------------- /igraph/include/cliquer/misc.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef CLIQUER_MISC_H 3 | #define CLIQUER_MISC_H 4 | 5 | #include "cliquerconf.h" 6 | 7 | /* 8 | * We #define boolean instead of using a typedef because nauty.h uses it 9 | * also. AFAIK, there is no way to check for an existing typedef, and 10 | * re-typedefing is illegal (even when using exactly the same datatype!). 11 | */ 12 | #ifndef boolean 13 | #define boolean int 14 | #endif 15 | 16 | 17 | /* 18 | * The original cliquer source has some functions incorrectly marked as unused, 19 | * thus leave this undefined. 20 | */ 21 | #define UNUSED_FUNCTION 22 | 23 | 24 | /* 25 | * Default inlining directive: "inline" 26 | */ 27 | #ifndef INLINE 28 | #define INLINE inline 29 | #endif 30 | 31 | 32 | #include 33 | #include 34 | 35 | #ifndef ASSERT 36 | #ifdef USING_R 37 | #include 38 | #define ASSERT(expr) \ 39 | if (!(expr)) { \ 40 | error("cliquer file %s: line %d: assertion failed: " \ 41 | "(%s)\n",__FILE__,__LINE__,#expr); \ 42 | } 43 | #else 44 | #define ASSERT(expr) \ 45 | if (!(expr)) { \ 46 | fprintf(stderr,"cliquer file %s: line %d: assertion failed: " \ 47 | "(%s)\n",__FILE__,__LINE__,#expr); \ 48 | abort(); \ 49 | } 50 | #endif 51 | #endif /* !ASSERT */ 52 | 53 | 54 | #ifndef FALSE 55 | #define FALSE (0) 56 | #endif 57 | #ifndef TRUE 58 | #define TRUE (!FALSE) 59 | #endif 60 | 61 | 62 | #ifndef MIN 63 | #define MIN(a,b) (((a)<(b))?(a):(b)) 64 | #endif 65 | #ifndef MAX 66 | #define MAX(a,b) (((a)>(b))?(a):(b)) 67 | #endif 68 | #ifndef ABS 69 | #define ABS(v) (((v)<0)?(-(v)):(v)) 70 | #endif 71 | 72 | #endif /* !CLIQUER_MISC_H */ 73 | 74 | -------------------------------------------------------------------------------- /src/IGraph/Internal/Constants.chs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE ForeignFunctionInterface #-} 2 | module IGraph.Internal.Constants where 3 | 4 | #include "haskell_igraph.h" 5 | 6 | {#enum igraph_neimode_t as Neimode {underscoreToCase} 7 | deriving (Show, Eq) #} 8 | 9 | {#enum igraph_edgeorder_type_t as EdgeOrderType {underscoreToCase} 10 | deriving (Show, Eq) #} 11 | 12 | {#enum igraph_to_directed_t as ToDirected {underscoreToCase} 13 | deriving (Eq) #} 14 | 15 | {#enum igraph_spincomm_update_t as SpincommUpdate {underscoreToCase} 16 | deriving (Show, Eq) #} 17 | 18 | {#enum igraph_spinglass_implementation_t as SpinglassImplementation {underscoreToCase} 19 | deriving (Show, Eq) #} 20 | 21 | {#enum igraph_attribute_elemtype_t as AttributeElemtype {underscoreToCase} 22 | deriving (Show, Eq) #} 23 | 24 | {#enum igraph_subgraph_implementation_t as SubgraphImplementation {underscoreToCase} 25 | deriving (Show, Read, Eq) #} 26 | 27 | {#enum igraph_connectedness_t as Connectedness {underscoreToCase} 28 | deriving (Eq) #} 29 | 30 | {#enum igraph_pagerank_algo_t as PagerankAlgo {underscoreToCase} 31 | deriving (Show, Read, Eq) #} 32 | 33 | {#enum igraph_erdos_renyi_t as ErdosRenyi {underscoreToCase} 34 | deriving (Show, Read, Eq) #} 35 | 36 | {#enum igraph_rewiring_t as Rewiring {underscoreToCase} 37 | deriving (Show, Read, Eq) #} 38 | 39 | {#enum igraph_star_mode_t as StarMode {underscoreToCase} 40 | deriving (Show, Read, Eq) #} 41 | 42 | {#enum igraph_degseq_t as Degseq {underscoreToCase} 43 | deriving (Show, Read, Eq) #} 44 | 45 | {#enum igraph_reciprocity_t as Reciprocity {underscoreToCase} 46 | deriving (Show, Read, Eq) #} 47 | -------------------------------------------------------------------------------- /igraph/include/igraph_memory.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2003-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_MEMORY_H 25 | #define IGRAPH_MEMORY_H 26 | 27 | #include 28 | #include "igraph_decls.h" 29 | 30 | __BEGIN_DECLS 31 | 32 | #define igraph_Calloc(n,t) (t*) calloc( (size_t)(n), sizeof(t) ) 33 | #define igraph_Realloc(p,n,t) (t*) realloc((void*)(p), (size_t)((n)*sizeof(t))) 34 | #define igraph_Free(p) (free( (void *)(p) ), (p) = NULL) 35 | 36 | /* #ifndef IGRAPH_NO_CALLOC */ 37 | /* # define Calloc igraph_Calloc */ 38 | /* # define Realloc igraph_Realloc */ 39 | /* # define Free igraph_Free */ 40 | /* #endif */ 41 | 42 | DECLDIR int igraph_free(void *p); 43 | DECLDIR void *igraph_malloc(size_t n); 44 | 45 | __END_DECLS 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /igraph/src/cs_happly.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* apply the ith Householder vector to x */ 23 | CS_INT cs_happly (const cs *V, CS_INT i, double beta, CS_ENTRY *x) 24 | { 25 | CS_INT p, *Vp, *Vi ; 26 | CS_ENTRY *Vx, tau = 0 ; 27 | if (!CS_CSC (V) || !x) return (0) ; /* check inputs */ 28 | Vp = V->p ; Vi = V->i ; Vx = V->x ; 29 | for (p = Vp [i] ; p < Vp [i+1] ; p++) /* tau = v'*x */ 30 | { 31 | tau += CS_CONJ (Vx [p]) * x [Vi [p]] ; 32 | } 33 | tau *= beta ; /* tau = beta*(v'*x) */ 34 | for (p = Vp [i] ; p < Vp [i+1] ; p++) /* x = x - v*tau */ 35 | { 36 | x [Vi [p]] -= Vx [p] * tau ; 37 | } 38 | return (1) ; 39 | } 40 | -------------------------------------------------------------------------------- /igraph/include/igraph_coloring.h: -------------------------------------------------------------------------------- 1 | /* 2 | Heuristic graph coloring algorithms. 3 | Copyright (C) 2017 Szabolcs Horvat 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 18 | 02110-1301 USA 19 | */ 20 | 21 | #ifndef IGRAPH_COLORING_H 22 | #define IGRAPH_COLORING_H 23 | 24 | #include "igraph_datatype.h" 25 | 26 | __BEGIN_DECLS 27 | 28 | /** 29 | * \typedef igraph_coloring_greedy_t 30 | * \brief Ordering heuristics for greedy graph coloring. 31 | * 32 | * Ordering heuristics for \ref igraph_vertex_coloring_greedy(). 33 | * 34 | * \enumval IGRAPH_COLORING_GREEDY_COLORED_NEIGHBORS Choose vertex with largest number of already colored neighbors. 35 | * 36 | */ 37 | typedef enum { 38 | IGRAPH_COLORING_GREEDY_COLORED_NEIGHBORS = 0 39 | } igraph_coloring_greedy_t; 40 | 41 | DECLDIR int igraph_vertex_coloring_greedy(const igraph_t *graph, igraph_vector_int_t *colors, igraph_coloring_greedy_t heuristic); 42 | 43 | __END_DECLS 44 | 45 | #endif /* IGRAPH_COLORING_H */ 46 | -------------------------------------------------------------------------------- /igraph/src/backspac.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | #ifdef KR_headers 7 | integer f_back(a) alist *a; 8 | #else 9 | integer f_back(alist *a) 10 | #endif 11 | { unit *b; 12 | OFF_T v, w, x, y, z; 13 | uiolen n; 14 | FILE *f; 15 | 16 | f__curunit = b = &f__units[a->aunit]; /* curunit for error messages */ 17 | if(a->aunit >= MXUNIT || a->aunit < 0) 18 | err(a->aerr,101,"backspace") 19 | if(b->useek==0) err(a->aerr,106,"backspace") 20 | if(b->ufd == NULL) { 21 | fk_open(1, 1, a->aunit); 22 | return(0); 23 | } 24 | if(b->uend==1) 25 | { b->uend=0; 26 | return(0); 27 | } 28 | if(b->uwrt) { 29 | t_runc(a); 30 | if (f__nowreading(b)) 31 | err(a->aerr,errno,"backspace") 32 | } 33 | f = b->ufd; /* may have changed in t_runc() */ 34 | if(b->url>0) 35 | { 36 | x=FTELL(f); 37 | y = x % b->url; 38 | if(y == 0) x--; 39 | x /= b->url; 40 | x *= b->url; 41 | (void) FSEEK(f,x,SEEK_SET); 42 | return(0); 43 | } 44 | 45 | if(b->ufmt==0) 46 | { FSEEK(f,-(OFF_T)sizeof(uiolen),SEEK_CUR); 47 | fread((char *)&n,sizeof(uiolen),1,f); 48 | FSEEK(f,-(OFF_T)n-2*sizeof(uiolen),SEEK_CUR); 49 | return(0); 50 | } 51 | w = x = FTELL(f); 52 | z = 0; 53 | loop: 54 | while(x) { 55 | x -= x < 64 ? x : 64; 56 | FSEEK(f,x,SEEK_SET); 57 | for(y = x; y < w; y++) { 58 | if (getc(f) != '\n') 59 | continue; 60 | v = FTELL(f); 61 | if (v == w) { 62 | if (z) 63 | goto break2; 64 | goto loop; 65 | } 66 | z = v; 67 | } 68 | err(a->aerr,(EOF),"backspace") 69 | } 70 | break2: 71 | FSEEK(f, z, SEEK_SET); 72 | return 0; 73 | } 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | -------------------------------------------------------------------------------- /igraph/src/prpack_utils.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file prpack_utils.cpp 3 | * An assortment of utility functions for reporting errors, checking time, 4 | * and working with vectors. 5 | */ 6 | 7 | #include 8 | #include "prpack_utils.h" 9 | #include 10 | #include 11 | #include 12 | using namespace prpack; 13 | using namespace std; 14 | 15 | #ifdef PRPACK_IGRAPH_SUPPORT 16 | #include "igraph_error.h" 17 | #endif 18 | 19 | #if defined(_WIN32) 20 | #ifndef WIN32_LEAN_AND_MEAN 21 | #define WIN32_LEAN_AND_MEAN 22 | #include 23 | #endif 24 | double prpack_utils::get_time() { 25 | LARGE_INTEGER t, freq; 26 | QueryPerformanceCounter(&t); 27 | QueryPerformanceFrequency(&freq); 28 | return double(t.QuadPart)/double(freq.QuadPart); 29 | } 30 | #else 31 | #include 32 | #include 33 | double prpack_utils::get_time() { 34 | struct timeval t; 35 | gettimeofday(&t, 0); 36 | return (t.tv_sec*1.0 + t.tv_usec/1000000.0); 37 | } 38 | #endif 39 | 40 | // Fails and outputs 'msg' if 'condition' is false. 41 | void prpack_utils::validate(const bool condition, const string& msg) { 42 | if (!condition) { 43 | #ifdef PRPACK_IGRAPH_SUPPORT 44 | igraph_error("Internal error in PRPACK", __FILE__, __LINE__, 45 | IGRAPH_EINTERNAL); 46 | #else 47 | cerr << msg << endl; 48 | exit(-1); 49 | #endif 50 | } 51 | } 52 | 53 | // Permute a vector. 54 | double* prpack_utils::permute(const int length, const double* a, const int* coding) { 55 | double* ret = new double[length]; 56 | for (int i = 0; i < length; ++i) 57 | ret[coding[i]] = a[i]; 58 | return ret; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /igraph/include/f2c/sysdep1.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSDEP_H_INCLUDED 2 | #define SYSDEP_H_INCLUDED 3 | 4 | #ifdef _MSC_VER 5 | #define FTRUNCATE chsize 6 | #endif 7 | 8 | #undef USE_LARGEFILE 9 | #ifndef NO_LONG_LONG 10 | 11 | #ifdef __sun__ 12 | #define USE_LARGEFILE 13 | #define OFF_T off64_t 14 | #endif 15 | 16 | #ifdef __linux__ 17 | #define USE_LARGEFILE 18 | 19 | #ifdef __GLIBC__ 20 | #define OFF_T __off64_t 21 | #else 22 | #define OFF_T off64_t 23 | #endif /* __GLIBC__ */ 24 | #endif /* __linux__ */ 25 | 26 | #ifdef _AIX43 27 | #define _LARGE_FILES 28 | #define _LARGE_FILE_API 29 | #define USE_LARGEFILE 30 | #endif /*_AIX43*/ 31 | 32 | #ifdef __hpux 33 | #define _FILE64 34 | #define _LARGEFILE64_SOURCE 35 | #define USE_LARGEFILE 36 | #endif /*__hpux*/ 37 | 38 | #ifdef __sgi 39 | #define USE_LARGEFILE 40 | #endif /*__sgi*/ 41 | 42 | #ifdef __FreeBSD__ 43 | #define OFF_T off_t 44 | #define FSEEK fseeko 45 | #define FTELL ftello 46 | #endif 47 | 48 | #ifdef USE_LARGEFILE 49 | #ifndef OFF_T 50 | #define OFF_T off64_t 51 | #endif 52 | #define _LARGEFILE_SOURCE 53 | #define _LARGEFILE64_SOURCE 54 | #include 55 | #include 56 | #define FOPEN fopen64 57 | #define FREOPEN freopen64 58 | #define FSEEK fseeko64 59 | #define FSTAT fstat64 60 | #define FTELL ftello64 61 | #define FTRUNCATE ftruncate64 62 | #define STAT stat64 63 | #define STAT_ST stat64 64 | #endif /*USE_LARGEFILE*/ 65 | #endif /*NO_LONG_LONG*/ 66 | 67 | #ifndef NON_UNIX_STDIO 68 | #ifndef USE_LARGEFILE 69 | #define _INCLUDE_POSIX_SOURCE /* for HP-UX */ 70 | #define _INCLUDE_XOPEN_SOURCE /* for HP-UX */ 71 | #include "sys/types.h" 72 | #include "sys/stat.h" 73 | #endif 74 | #endif 75 | 76 | #endif /*SYSDEP_H_INCLUDED*/ 77 | -------------------------------------------------------------------------------- /igraph/include/igraph_glpk_support.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* vim:set ts=4 sw=4 sts=4 et: */ 3 | /* 4 | IGraph library. 5 | Copyright (C) 2007-2012 Gabor Csardi 6 | 334 Harvard street, Cambridge, MA 02139 USA 7 | 8 | This program is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU General Public License as published by 10 | the Free Software Foundation; either version 2 of the License, or 11 | (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | 02110-1301 USA 22 | 23 | */ 24 | 25 | #ifndef IGRAPH_GLPK_SUPPORT_H 26 | #define IGRAPH_GLPK_SUPPORT_H 27 | 28 | #include "config.h" 29 | 30 | /* Note: only files calling the GLPK routines directly need to 31 | include this header. 32 | */ 33 | 34 | #ifdef HAVE_GLPK 35 | 36 | #include 37 | 38 | int igraph_i_glpk_check(int retval, const char* message); 39 | void igraph_i_glpk_interruption_hook(glp_tree *tree, void *info); 40 | #define IGRAPH_GLPK_CHECK(func, message) do {\ 41 | int igraph_i_ret = igraph_i_glpk_check(func, message); \ 42 | if (IGRAPH_UNLIKELY(igraph_i_ret != 0)) {\ 43 | return igraph_i_ret; \ 44 | } } while (0) 45 | 46 | #endif 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /igraph/src/dqueue.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2007-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #include "igraph_types.h" 25 | #include "igraph_dqueue.h" 26 | 27 | #define BASE_IGRAPH_REAL 28 | #include "igraph_pmt.h" 29 | #include "dqueue.pmt" 30 | #include "igraph_pmt_off.h" 31 | #undef BASE_IGRAPH_REAL 32 | 33 | #define BASE_LONG 34 | #include "igraph_pmt.h" 35 | #include "dqueue.pmt" 36 | #include "igraph_pmt_off.h" 37 | #undef BASE_LONG 38 | 39 | #define BASE_CHAR 40 | #include "igraph_pmt.h" 41 | #include "dqueue.pmt" 42 | #include "igraph_pmt_off.h" 43 | #undef BASE_CHAR 44 | 45 | #define BASE_BOOL 46 | #include "igraph_pmt.h" 47 | #include "dqueue.pmt" 48 | #include "igraph_pmt_off.h" 49 | #undef BASE_BOOL 50 | 51 | #define BASE_INT 52 | #include "igraph_pmt.h" 53 | #include "dqueue.pmt" 54 | #include "igraph_pmt_off.h" 55 | #undef BASE_INT 56 | -------------------------------------------------------------------------------- /igraph/include/igraph_flow_internal.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2010-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_FLOW_INTERNAL_H 25 | #define IGRAPH_FLOW_INTERNAL_H 26 | 27 | #include "igraph_types.h" 28 | #include "igraph_marked_queue.h" 29 | #include "igraph_estack.h" 30 | #include "igraph_datatype.h" 31 | 32 | typedef int igraph_provan_shier_pivot_t(const igraph_t *graph, 33 | const igraph_marked_queue_t *S, 34 | const igraph_estack_t *T, 35 | long int source, 36 | long int target, 37 | long int *v, 38 | igraph_vector_t *Isv, 39 | void *arg); 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /igraph/src/cs_reach.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* xi [top...n-1] = nodes reachable from graph of G*P' via nodes in B(:,k). 23 | * xi [n...2n-1] used as workspace */ 24 | CS_INT cs_reach (cs *G, const cs *B, CS_INT k, CS_INT *xi, const CS_INT *pinv) 25 | { 26 | CS_INT p, n, top, *Bp, *Bi, *Gp ; 27 | if (!CS_CSC (G) || !CS_CSC (B) || !xi) return (-1) ; /* check inputs */ 28 | n = G->n ; Bp = B->p ; Bi = B->i ; Gp = G->p ; 29 | top = n ; 30 | for (p = Bp [k] ; p < Bp [k+1] ; p++) 31 | { 32 | if (!CS_MARKED (Gp, Bi [p])) /* start a dfs at unmarked node i */ 33 | { 34 | top = cs_dfs (Bi [p], G, top, xi, xi+n, pinv) ; 35 | } 36 | } 37 | for (p = top ; p < n ; p++) CS_MARK (Gp, xi [p]) ; /* restore G */ 38 | return (top) ; 39 | } 40 | -------------------------------------------------------------------------------- /igraph/src/cs_load.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* load a triplet matrix from a file */ 23 | cs *cs_load (FILE *f) 24 | { 25 | CS_INT i, j ; 26 | double x ; 27 | #ifdef CS_COMPLEX 28 | double xi ; 29 | #endif 30 | cs *T ; 31 | if (!f) return (NULL) ; /* check inputs */ 32 | T = cs_spalloc (0, 0, 1, 1, 1) ; /* allocate result */ 33 | #ifdef CS_COMPLEX 34 | while (fscanf (f, ""CS_ID" "CS_ID" %lg %lg\n", &i, &j, &x, &xi) == 4) 35 | #else 36 | while (fscanf (f, ""CS_ID" "CS_ID" %lg\n", &i, &j, &x) == 3) 37 | #endif 38 | { 39 | #ifdef CS_COMPLEX 40 | if (!cs_entry (T, i, j, x + xi*I)) return (cs_spfree (T)) ; 41 | #else 42 | if (!cs_entry (T, i, j, x)) return (cs_spfree (T)) ; 43 | #endif 44 | } 45 | return (T) ; 46 | } 47 | -------------------------------------------------------------------------------- /igraph/include/igraph_estack.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2010-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_ESTACK_H 25 | #define IGRAPH_ESTACK_H 26 | 27 | #include "igraph_stack.h" 28 | #include "igraph_vector.h" 29 | 30 | typedef struct igraph_estack_t { 31 | igraph_stack_long_t stack; 32 | igraph_vector_bool_t isin; 33 | } igraph_estack_t; 34 | 35 | int igraph_estack_init(igraph_estack_t *s, long int setsize, 36 | long int stacksize); 37 | void igraph_estack_destroy(igraph_estack_t *s); 38 | 39 | int igraph_estack_push(igraph_estack_t *s, long int elem); 40 | long int igraph_estack_pop(igraph_estack_t *s); 41 | igraph_bool_t igraph_estack_iselement(const igraph_estack_t *s, 42 | long int elem); 43 | long int igraph_estack_size(const igraph_estack_t *s); 44 | 45 | int igraph_estack_print(const igraph_estack_t *s); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /igraph/include/igraph_hacks_internal.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2003-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_HACKS_INTERNAL_H 25 | #define IGRAPH_HACKS_INTERNAL_H 26 | 27 | #include "config.h" 28 | 29 | #undef __BEGIN_DECLS 30 | #undef __END_DECLS 31 | #ifdef __cplusplus 32 | #define __BEGIN_DECLS extern "C" { 33 | #define __END_DECLS } 34 | #else 35 | #define __BEGIN_DECLS /* empty */ 36 | #define __END_DECLS /* empty */ 37 | #endif 38 | 39 | __BEGIN_DECLS 40 | 41 | #ifndef HAVE_STRDUP 42 | #define strdup igraph_i_strdup 43 | char* igraph_i_strdup(const char *s); 44 | #endif 45 | 46 | #ifndef HAVE_STPCPY 47 | #define stpcpy igraph_i_stpcpy 48 | char* igraph_i_stpcpy(char* s1, const char* s2); 49 | #else 50 | #ifndef HAVE_STPCPY_SIGNATURE 51 | char* stpcpy(char* s1, const char* s2); 52 | #endif 53 | #endif 54 | 55 | __END_DECLS 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /igraph/include/igraph_heap_pmt.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2007-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | typedef struct TYPE(igraph_heap) { 25 | BASE* stor_begin; 26 | BASE* stor_end; 27 | BASE* end; 28 | int destroy; 29 | } TYPE(igraph_heap); 30 | 31 | DECLDIR int FUNCTION(igraph_heap, init)(TYPE(igraph_heap)* h, long int size); 32 | DECLDIR int FUNCTION(igraph_heap, init_array)(TYPE(igraph_heap) *t, BASE* data, long int len); 33 | DECLDIR void FUNCTION(igraph_heap, destroy)(TYPE(igraph_heap)* h); 34 | DECLDIR igraph_bool_t FUNCTION(igraph_heap, empty)(TYPE(igraph_heap)* h); 35 | DECLDIR int FUNCTION(igraph_heap, push)(TYPE(igraph_heap)* h, BASE elem); 36 | DECLDIR BASE FUNCTION(igraph_heap, top)(TYPE(igraph_heap)* h); 37 | DECLDIR BASE FUNCTION(igraph_heap, delete_top)(TYPE(igraph_heap)* h); 38 | DECLDIR long int FUNCTION(igraph_heap, size)(TYPE(igraph_heap)* h); 39 | DECLDIR int FUNCTION(igraph_heap, reserve)(TYPE(igraph_heap)* h, long int size); -------------------------------------------------------------------------------- /igraph/src/s_cat.c: -------------------------------------------------------------------------------- 1 | /* Unless compiled with -DNO_OVERWRITE, this variant of s_cat allows the 2 | * target of a concatenation to appear on its right-hand side (contrary 3 | * to the Fortran 77 Standard, but in accordance with Fortran 90). 4 | */ 5 | 6 | #include "f2c.h" 7 | #ifndef NO_OVERWRITE 8 | #include "stdio.h" 9 | #undef abs 10 | #ifdef KR_headers 11 | extern char *F77_aloc(); 12 | extern void free(); 13 | extern void exit_(); 14 | #else 15 | #undef min 16 | #undef max 17 | #include "stdlib.h" 18 | extern 19 | #ifdef __cplusplus 20 | "C" 21 | #endif 22 | char *F77_aloc(ftnlen, const char*); 23 | #endif 24 | #include "string.h" 25 | #endif /* NO_OVERWRITE */ 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | VOID 32 | #ifdef KR_headers 33 | s_cat(lp, rpp, rnp, np, ll) char *lp, *rpp[]; ftnint rnp[], *np; ftnlen ll; 34 | #else 35 | s_cat(char *lp, char *rpp[], ftnint rnp[], ftnint *np, ftnlen ll) 36 | #endif 37 | { 38 | ftnlen i, nc; 39 | char *rp; 40 | ftnlen n = *np; 41 | #ifndef NO_OVERWRITE 42 | ftnlen L, m; 43 | char *lp0, *lp1; 44 | 45 | lp0 = 0; 46 | lp1 = lp; 47 | L = ll; 48 | i = 0; 49 | while(i < n) { 50 | rp = rpp[i]; 51 | m = rnp[i++]; 52 | if (rp >= lp1 || rp + m <= lp) { 53 | if ((L -= m) <= 0) { 54 | n = i; 55 | break; 56 | } 57 | lp1 += m; 58 | continue; 59 | } 60 | lp0 = lp; 61 | lp = lp1 = F77_aloc(L = ll, "s_cat"); 62 | break; 63 | } 64 | lp1 = lp; 65 | #endif /* NO_OVERWRITE */ 66 | for(i = 0 ; i < n ; ++i) { 67 | nc = ll; 68 | if(rnp[i] < nc) 69 | nc = rnp[i]; 70 | ll -= nc; 71 | rp = rpp[i]; 72 | while(--nc >= 0) 73 | *lp++ = *rp++; 74 | } 75 | while(--ll >= 0) 76 | *lp++ = ' '; 77 | #ifndef NO_OVERWRITE 78 | if (lp0) { 79 | memcpy(lp0, lp1, L); 80 | free(lp1); 81 | } 82 | #endif 83 | } 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | -------------------------------------------------------------------------------- /igraph/include/plfit/platform.h: -------------------------------------------------------------------------------- 1 | /* platform.h 2 | * 3 | * Copyright (C) 2010-2011 Tamas Nepusz 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or (at 8 | * your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef __PLATFORM_H__ 21 | #define __PLATFORM_H__ 22 | 23 | #undef __BEGIN_DECLS 24 | #undef __END_DECLS 25 | #ifdef __cplusplus 26 | # define __BEGIN_DECLS extern "C" { 27 | # define __END_DECLS } 28 | #else 29 | # define __BEGIN_DECLS /* empty */ 30 | # define __END_DECLS /* empty */ 31 | #endif 32 | 33 | #include 34 | 35 | __BEGIN_DECLS 36 | 37 | #if defined(_MSC_VER) && _MSC_VER < 1900 38 | #include 39 | 40 | #define snprintf igraph_i_snprintf 41 | #define isnan(x) ((x) != (x)) 42 | #define isfinite(x) _finite(x) 43 | 44 | extern double _plfit_fmin(double a, double b); 45 | extern double _plfit_round(double x); 46 | 47 | #define fmin _plfit_fmin 48 | #define round _plfit_round 49 | #endif 50 | 51 | #ifdef _MSC_VER 52 | #define inline __inline 53 | #endif 54 | 55 | #ifndef INFINITY 56 | # define INFINITY (1.0/0.0) 57 | #endif 58 | 59 | #ifndef NAN 60 | # define NAN ((double)0.0 / (double)DBL_MIN) 61 | #endif 62 | 63 | __END_DECLS 64 | 65 | #endif /* __PLATFORM_H__ */ 66 | -------------------------------------------------------------------------------- /igraph/include/structural_properties_internal.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2011-2016 Gabor Csardi 5 | 334 Harvard st, Cambridge, MA, 02138 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef STRUCTURAL_PROPERTIES_INTERNAL_H 25 | #define STRUCTURAL_PROPERTIES_INTERNAL_H 26 | 27 | #include "igraph_constants.h" 28 | #include "igraph_types.h" 29 | #include "igraph_iterators.h" 30 | 31 | int igraph_i_induced_subgraph_suggest_implementation( 32 | const igraph_t *graph, const igraph_vs_t vids, 33 | igraph_subgraph_implementation_t* result 34 | ); 35 | 36 | int igraph_i_subgraph_copy_and_delete(const igraph_t *graph, igraph_t *res, 37 | const igraph_vs_t vids, 38 | igraph_vector_t *map, 39 | igraph_vector_t *invmap); 40 | 41 | int igraph_i_subgraph_create_from_scratch(const igraph_t *graph, 42 | igraph_t *res, 43 | const igraph_vs_t vids, 44 | igraph_vector_t *map, 45 | igraph_vector_t *invmap); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /tests/Test/Attributes.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE DataKinds #-} 2 | module Test.Attributes 3 | ( tests 4 | ) where 5 | 6 | import Data.List 7 | import Data.Serialize 8 | import System.IO.Unsafe 9 | import Test.Tasty 10 | import Test.Tasty.HUnit 11 | import Test.Utils 12 | 13 | import IGraph 14 | import IGraph.Internal 15 | import IGraph.Mutable 16 | 17 | tests :: TestTree 18 | tests = testGroup "Attribute tests" 19 | [ nodeLabelTest 20 | , labelTest 21 | ] 22 | 23 | nodeLabelTest :: TestTree 24 | nodeLabelTest = testCase "node label test" $ do 25 | let ns = sort $ map show [38..7000] 26 | gr = mkGraph ns [] :: Graph 'D String () 27 | assertBool "" $ sort (map (nodeLab gr) $ nodes gr) == ns 28 | 29 | labelTest :: TestTree 30 | labelTest = testCase "edge label test" $ do 31 | dat <- randEdges 1000 10000 32 | let es = sort $ zipWith (\a b -> (a,b)) dat $ map show [1..] 33 | gr = fromLabeledEdges es :: Graph 'D Int String 34 | es' = sort $ map (\(a,b) -> ((nodeLab gr a, nodeLab gr b), edgeLab gr (a,b))) $ edges gr 35 | assertBool "" $ es == es' 36 | 37 | {- 38 | serializeTest :: TestTree 39 | serializeTest = testCase "serialize test" $ do 40 | dat <- randEdges 1000 10000 41 | let es = map ( \(a, b) -> ( 42 | ( defaultNodeAttributes{_nodeLabel= show a} 43 | , defaultNodeAttributes{_nodeLabel= show b}), defaultEdgeAttributes) ) dat 44 | gr = fromLabeledEdges es :: Graph 'D NodeAttr EdgeAttr 45 | gr' :: Graph 'D NodeAttr EdgeAttr 46 | gr' = case decode $ encode gr of 47 | Left msg -> error msg 48 | Right r -> r 49 | es' = map (\(a,b) -> ((nodeLab gr' a, nodeLab gr' b), edgeLab gr' (a,b))) $ edges gr' 50 | sort (map show es) @=? sort (map show es') 51 | -} 52 | -------------------------------------------------------------------------------- /igraph/src/hacks.c: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2010-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #include 25 | #include 26 | #include 27 | #include "igraph_hacks_internal.h" 28 | 29 | /* These are implementations of common C functions that may be missing from some 30 | * compilers; for instance, icc does not provide stpcpy so we implement it 31 | * here. */ 32 | 33 | /** 34 | * Drop-in replacement for strdup. 35 | * Used only in compilers that do not have strdup or _strdup 36 | */ 37 | char* igraph_i_strdup(const char *s) { 38 | size_t n = strlen(s) + 1; 39 | char* result = (char*)malloc(sizeof(char) * n); 40 | if (result) { 41 | memcpy(result, s, n); 42 | } 43 | return result; 44 | } 45 | 46 | /** 47 | * Drop-in replacement for stpcpy. 48 | * Used only in compilers that do not have stpcpy 49 | */ 50 | char* igraph_i_stpcpy(char* s1, const char* s2) { 51 | char* result = strcpy(s1, s2); 52 | return result + strlen(s1); 53 | } 54 | 55 | -------------------------------------------------------------------------------- /igraph/include/f2c/lio.h: -------------------------------------------------------------------------------- 1 | /* copy of ftypes from the compiler */ 2 | /* variable types 3 | * numeric assumptions: 4 | * int < reals < complexes 5 | * TYDREAL-TYREAL = TYDCOMPLEX-TYCOMPLEX 6 | */ 7 | 8 | /* 0-10 retain their old (pre LOGICAL*1, etc.) */ 9 | /* values to allow mixing old and new objects. */ 10 | 11 | #define TYUNKNOWN 0 12 | #define TYADDR 1 13 | #define TYSHORT 2 14 | #define TYLONG 3 15 | #define TYREAL 4 16 | #define TYDREAL 5 17 | #define TYCOMPLEX 6 18 | #define TYDCOMPLEX 7 19 | #define TYLOGICAL 8 20 | #define TYCHAR 9 21 | #define TYSUBR 10 22 | #define TYINT1 11 23 | #define TYLOGICAL1 12 24 | #define TYLOGICAL2 13 25 | #ifdef Allow_TYQUAD 26 | #undef TYQUAD 27 | #define TYQUAD 14 28 | #endif 29 | 30 | #define LINTW 24 31 | #define LINE 80 32 | #define LLOGW 2 33 | #ifdef Old_list_output 34 | #define LLOW 1.0 35 | #define LHIGH 1.e9 36 | #define LEFMT " %# .8E" 37 | #define LFFMT " %# .9g" 38 | #else 39 | #define LGFMT "%.9G" 40 | #endif 41 | /* LEFBL 20 should suffice; 24 overcomes a NeXT bug. */ 42 | #define LEFBL 24 43 | 44 | typedef union 45 | { 46 | char flchar; 47 | short flshort; 48 | ftnint flint; 49 | #ifdef Allow_TYQUAD 50 | longint fllongint; 51 | #endif 52 | real flreal; 53 | doublereal fldouble; 54 | } flex; 55 | #ifdef KR_headers 56 | extern int (*f__lioproc)(), (*l_getc)(), (*l_ungetc)(); 57 | extern int l_read(), l_write(); 58 | #else 59 | #ifdef __cplusplus 60 | extern "C" { 61 | #endif 62 | extern int (*f__lioproc)(ftnint*, char*, ftnlen, ftnint); 63 | extern int l_write(ftnint*, char*, ftnlen, ftnint); 64 | extern void x_wsne(cilist*); 65 | extern int c_le(cilist*), (*l_getc)(void), (*l_ungetc)(int,FILE*); 66 | extern int l_read(ftnint*,char*,ftnlen,ftnint); 67 | extern integer e_rsle(void), e_wsle(void), s_wsne(cilist*); 68 | extern int z_rnew(void); 69 | #endif 70 | extern ftnint L_len; 71 | extern int f__scale; 72 | #ifdef __cplusplus 73 | } 74 | #endif 75 | -------------------------------------------------------------------------------- /igraph/src/rsfe.c: -------------------------------------------------------------------------------- 1 | /* read sequential formatted external */ 2 | #include "f2c.h" 3 | #include "fio.h" 4 | #include "fmt.h" 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | int 10 | xrd_SL(Void) 11 | { int ch; 12 | if(!f__curunit->uend) 13 | while((ch=getc(f__cf))!='\n') 14 | if (ch == EOF) { 15 | f__curunit->uend = 1; 16 | break; 17 | } 18 | f__cursor=f__recpos=0; 19 | return(1); 20 | } 21 | 22 | int 23 | x_getc(Void) 24 | { int ch; 25 | if(f__curunit->uend) return(EOF); 26 | ch = getc(f__cf); 27 | if(ch!=EOF && ch!='\n') 28 | { f__recpos++; 29 | return(ch); 30 | } 31 | if(ch=='\n') 32 | { (void) ungetc(ch,f__cf); 33 | return(ch); 34 | } 35 | if(f__curunit->uend || feof(f__cf)) 36 | { errno=0; 37 | f__curunit->uend=1; 38 | return(-1); 39 | } 40 | return(-1); 41 | } 42 | 43 | int 44 | x_endp(Void) 45 | { 46 | xrd_SL(); 47 | return f__curunit->uend == 1 ? EOF : 0; 48 | } 49 | 50 | int 51 | x_rev(Void) 52 | { 53 | (void) xrd_SL(); 54 | return(0); 55 | } 56 | #ifdef KR_headers 57 | integer s_rsfe(a) cilist *a; /* start */ 58 | #else 59 | integer s_rsfe(cilist *a) /* start */ 60 | #endif 61 | { int n; 62 | if(!f__init) f_init(); 63 | f__reading=1; 64 | f__sequential=1; 65 | f__formatted=1; 66 | f__external=1; 67 | if(n=c_sfe(a)) return(n); 68 | f__elist=a; 69 | f__cursor=f__recpos=0; 70 | f__scale=0; 71 | f__fmtbuf=a->cifmt; 72 | f__cf=f__curunit->ufd; 73 | if(pars_f(f__fmtbuf)<0) err(a->cierr,100,"startio"); 74 | f__getn= x_getc; 75 | f__doed= rd_ed; 76 | f__doned= rd_ned; 77 | fmt_bg(); 78 | f__doend=x_endp; 79 | f__donewrec=xrd_SL; 80 | f__dorevert=x_rev; 81 | f__cblank=f__curunit->ublnk; 82 | f__cplus=0; 83 | if(f__curunit->uwrt && f__nowreading(f__curunit)) 84 | err(a->cierr,errno,"read start"); 85 | if(f__curunit->uend) 86 | err(f__elist->ciend,(EOF),"read start"); 87 | return(0); 88 | } 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | -------------------------------------------------------------------------------- /igraph/include/igraph_array.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2009-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_ARRAY_H 25 | #define IGRAPH_ARRAY_H 26 | 27 | #include "igraph_decls.h" 28 | 29 | __BEGIN_DECLS 30 | 31 | /* -------------------------------------------------- */ 32 | /* 3D array */ 33 | /* -------------------------------------------------- */ 34 | 35 | #define BASE_IGRAPH_REAL 36 | #include "igraph_pmt.h" 37 | #include "igraph_array_pmt.h" 38 | #include "igraph_pmt_off.h" 39 | #undef BASE_IGRAPH_REAL 40 | 41 | #define BASE_LONG 42 | #include "igraph_pmt.h" 43 | #include "igraph_array_pmt.h" 44 | #include "igraph_pmt_off.h" 45 | #undef BASE_LONG 46 | 47 | #define BASE_CHAR 48 | #include "igraph_pmt.h" 49 | #include "igraph_array_pmt.h" 50 | #include "igraph_pmt_off.h" 51 | #undef BASE_CHAR 52 | 53 | #define BASE_BOOL 54 | #include "igraph_pmt.h" 55 | #include "igraph_array_pmt.h" 56 | #include "igraph_pmt_off.h" 57 | #undef BASE_BOOL 58 | 59 | __END_DECLS 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /igraph/include/prpack.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2007-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_PRPACK 25 | #define IGRAPH_PRPACK 26 | 27 | #undef __BEGIN_DECLS 28 | #undef __END_DECLS 29 | #ifdef __cplusplus 30 | #define __BEGIN_DECLS extern "C" { 31 | #define __END_DECLS } 32 | #else 33 | #define __BEGIN_DECLS /* empty */ 34 | #define __END_DECLS /* empty */ 35 | #endif 36 | 37 | #include "igraph_types.h" 38 | #include "igraph_datatype.h" 39 | #include "igraph_iterators.h" 40 | 41 | #include "igraph_interface.h" 42 | 43 | __BEGIN_DECLS 44 | 45 | int igraph_personalized_pagerank_prpack(const igraph_t *graph, igraph_vector_t *vector, 46 | igraph_real_t *value, const igraph_vs_t vids, 47 | igraph_bool_t directed, igraph_real_t damping, 48 | igraph_vector_t *reset, 49 | const igraph_vector_t *weights); 50 | 51 | __END_DECLS 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /igraph/include/igraph_mixing.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: C -*- */ 2 | /* 3 | IGraph library. 4 | Copyright (C) 2009-2012 Gabor Csardi 5 | 334 Harvard street, Cambridge, MA 02139 USA 6 | 7 | This program is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 2 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 | 02110-1301 USA 21 | 22 | */ 23 | 24 | #ifndef IGRAPH_MIXING_H 25 | #define IGRAPH_MIXING_H 26 | 27 | #include "igraph_decls.h" 28 | #include "igraph_types.h" 29 | #include "igraph_datatype.h" 30 | #include "igraph_vector.h" 31 | 32 | __BEGIN_DECLS 33 | 34 | DECLDIR int igraph_assortativity_nominal(const igraph_t *graph, 35 | const igraph_vector_t *types, 36 | igraph_real_t *res, 37 | igraph_bool_t directed); 38 | 39 | DECLDIR int igraph_assortativity(const igraph_t *graph, 40 | const igraph_vector_t *types1, 41 | const igraph_vector_t *types2, 42 | igraph_real_t *res, 43 | igraph_bool_t directed); 44 | 45 | DECLDIR int igraph_assortativity_degree(const igraph_t *graph, 46 | igraph_real_t *res, 47 | igraph_bool_t directed); 48 | 49 | __END_DECLS 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /igraph/src/uio.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | uiolen f__reclen; 7 | 8 | int 9 | #ifdef KR_headers 10 | do_us(number,ptr,len) ftnint *number; char *ptr; ftnlen len; 11 | #else 12 | do_us(ftnint *number, char *ptr, ftnlen len) 13 | #endif 14 | { 15 | if(f__reading) 16 | { 17 | f__recpos += (int)(*number * len); 18 | if(f__recpos>f__reclen) 19 | err(f__elist->cierr, 110, "do_us"); 20 | if (fread(ptr,(int)len,(int)(*number),f__cf) != *number) 21 | err(f__elist->ciend, EOF, "do_us"); 22 | return(0); 23 | } 24 | else 25 | { 26 | f__reclen += *number * len; 27 | (void) fwrite(ptr,(int)len,(int)(*number),f__cf); 28 | return(0); 29 | } 30 | } 31 | #ifdef KR_headers 32 | integer do_ud(number,ptr,len) ftnint *number; char *ptr; ftnlen len; 33 | #else 34 | integer do_ud(ftnint *number, char *ptr, ftnlen len) 35 | #endif 36 | { 37 | f__recpos += (int)(*number * len); 38 | if(f__recpos > f__curunit->url && f__curunit->url!=1) 39 | err(f__elist->cierr,110,"do_ud"); 40 | if(f__reading) 41 | { 42 | #ifdef Pad_UDread 43 | #ifdef KR_headers 44 | int i; 45 | #else 46 | size_t i; 47 | #endif 48 | if (!(i = fread(ptr,(int)len,(int)(*number),f__cf)) 49 | && !(f__recpos - *number*len)) 50 | err(f__elist->cierr,EOF,"do_ud") 51 | if (i < *number) 52 | memset(ptr + i*len, 0, (*number - i)*len); 53 | return 0; 54 | #else 55 | if(fread(ptr,(int)len,(int)(*number),f__cf) != *number) 56 | err(f__elist->cierr,EOF,"do_ud") 57 | else return(0); 58 | #endif 59 | } 60 | (void) fwrite(ptr,(int)len,(int)(*number),f__cf); 61 | return(0); 62 | } 63 | #ifdef KR_headers 64 | integer do_uio(number,ptr,len) ftnint *number; char *ptr; ftnlen len; 65 | #else 66 | integer do_uio(ftnint *number, char *ptr, ftnlen len) 67 | #endif 68 | { 69 | if(f__sequential) 70 | return(do_us(number,ptr,len)); 71 | else return(do_ud(number,ptr,len)); 72 | } 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /igraph/src/cs_cholsol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * CXSPARSE: a Concise Sparse Matrix package - Extended. 3 | * Copyright (c) 2006-2009, Timothy A. Davis. 4 | * http://www.cise.ufl.edu/research/sparse/CXSparse 5 | * 6 | * CXSparse is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * CXSparse is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this Module; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "cs.h" 22 | /* x=A\b where A is symmetric positive definite; b overwritten with solution */ 23 | CS_INT cs_cholsol (CS_INT order, const cs *A, CS_ENTRY *b) 24 | { 25 | CS_ENTRY *x ; 26 | css *S ; 27 | csn *N ; 28 | CS_INT n, ok ; 29 | if (!CS_CSC (A) || !b) return (0) ; /* check inputs */ 30 | n = A->n ; 31 | S = cs_schol (order, A) ; /* ordering and symbolic analysis */ 32 | N = cs_chol (A, S) ; /* numeric Cholesky factorization */ 33 | x = cs_malloc (n, sizeof (CS_ENTRY)) ; /* get workspace */ 34 | ok = (S && N && x) ; 35 | if (ok) 36 | { 37 | cs_ipvec (S->pinv, b, x, n) ; /* x = P*b */ 38 | cs_lsolve (N->L, x) ; /* x = L\x */ 39 | cs_ltsolve (N->L, x) ; /* x = L'\x */ 40 | cs_pvec (S->pinv, x, b, n) ; /* b = P'*x */ 41 | } 42 | cs_free (x) ; 43 | cs_sfree (S) ; 44 | cs_nfree (N) ; 45 | return (ok) ; 46 | } 47 | -------------------------------------------------------------------------------- /igraph/src/close.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef KR_headers 4 | integer f_clos(a) cllist *a; 5 | #else 6 | #undef abs 7 | #undef min 8 | #undef max 9 | #include "stdlib.h" 10 | #ifdef NON_UNIX_STDIO 11 | #ifndef unlink 12 | #define unlink remove 13 | #endif 14 | #else 15 | #ifdef MSDOS 16 | #include "io.h" 17 | #else 18 | #ifdef __cplusplus 19 | extern "C" int unlink(const char*); 20 | #else 21 | extern int unlink(const char*); 22 | #endif 23 | #endif 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | integer f_clos(cllist *a) 31 | #endif 32 | { unit *b; 33 | 34 | if(a->cunit >= MXUNIT) return(0); 35 | b= &f__units[a->cunit]; 36 | if(b->ufd==NULL) 37 | goto done; 38 | if (b->uscrtch == 1) 39 | goto Delete; 40 | if (!a->csta) 41 | goto Keep; 42 | switch(*a->csta) { 43 | default: 44 | Keep: 45 | case 'k': 46 | case 'K': 47 | if(b->uwrt == 1) 48 | t_runc((alist *)a); 49 | if(b->ufnm) { 50 | fclose(b->ufd); 51 | free(b->ufnm); 52 | } 53 | break; 54 | case 'd': 55 | case 'D': 56 | Delete: 57 | fclose(b->ufd); 58 | if(b->ufnm) { 59 | unlink(b->ufnm); /*SYSDEP*/ 60 | free(b->ufnm); 61 | } 62 | } 63 | b->ufd=NULL; 64 | done: 65 | b->uend=0; 66 | b->ufnm=NULL; 67 | return(0); 68 | } 69 | void 70 | #ifdef KR_headers 71 | f_exit() 72 | #else 73 | f_exit(void) 74 | #endif 75 | { int i; 76 | static cllist xx; 77 | if (!xx.cerr) { 78 | xx.cerr=1; 79 | xx.csta=NULL; 80 | for(i=0;in ; 31 | S = cs_sqr (order, A, 0) ; /* ordering and symbolic analysis */ 32 | N = cs_lu (A, S, tol) ; /* numeric LU factorization */ 33 | x = cs_malloc (n, sizeof (CS_ENTRY)) ; /* get workspace */ 34 | ok = (S && N && x) ; 35 | if (ok) 36 | { 37 | cs_ipvec (N->pinv, b, x, n) ; /* x = b(p) */ 38 | cs_lsolve (N->L, x) ; /* x = L\x */ 39 | cs_usolve (N->U, x) ; /* x = U\x */ 40 | cs_ipvec (S->q, x, b, n) ; /* b(q) = x */ 41 | } 42 | cs_free (x) ; 43 | cs_sfree (S) ; 44 | cs_nfree (N) ; 45 | return (ok) ; 46 | } 47 | -------------------------------------------------------------------------------- /igraph/src/due.c: -------------------------------------------------------------------------------- 1 | #include "f2c.h" 2 | #include "fio.h" 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | 7 | int 8 | #ifdef KR_headers 9 | c_due(a) cilist *a; 10 | #else 11 | c_due(cilist *a) 12 | #endif 13 | { 14 | if(!f__init) f_init(); 15 | f__sequential=f__formatted=f__recpos=0; 16 | f__external=1; 17 | f__curunit = &f__units[a->ciunit]; 18 | if(a->ciunit>=MXUNIT || a->ciunit<0) 19 | err(a->cierr,101,"startio"); 20 | f__elist=a; 21 | if(f__curunit->ufd==NULL && fk_open(DIR,UNF,a->ciunit) ) err(a->cierr,104,"due"); 22 | f__cf=f__curunit->ufd; 23 | if(f__curunit->ufmt) err(a->cierr,102,"cdue") 24 | if(!f__curunit->useek) err(a->cierr,104,"cdue") 25 | if(f__curunit->ufd==NULL) err(a->cierr,114,"cdue") 26 | if(a->cirec <= 0) 27 | err(a->cierr,130,"due") 28 | FSEEK(f__cf,(OFF_T)(a->cirec-1)*f__curunit->url,SEEK_SET); 29 | f__curunit->uend = 0; 30 | return(0); 31 | } 32 | #ifdef KR_headers 33 | integer s_rdue(a) cilist *a; 34 | #else 35 | integer s_rdue(cilist *a) 36 | #endif 37 | { 38 | int n; 39 | f__reading=1; 40 | if(n=c_due(a)) return(n); 41 | if(f__curunit->uwrt && f__nowreading(f__curunit)) 42 | err(a->cierr,errno,"read start"); 43 | return(0); 44 | } 45 | #ifdef KR_headers 46 | integer s_wdue(a) cilist *a; 47 | #else 48 | integer s_wdue(cilist *a) 49 | #endif 50 | { 51 | int n; 52 | f__reading=0; 53 | if(n=c_due(a)) return(n); 54 | if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) 55 | err(a->cierr,errno,"write start"); 56 | return(0); 57 | } 58 | integer e_rdue(Void) 59 | { 60 | if(f__curunit->url==1 || f__recpos==f__curunit->url) 61 | return(0); 62 | FSEEK(f__cf,(OFF_T)(f__curunit->url-f__recpos),SEEK_CUR); 63 | if(FTELL(f__cf)%f__curunit->url) 64 | err(f__elist->cierr,200,"syserr"); 65 | return(0); 66 | } 67 | integer e_wdue(Void) 68 | { 69 | #ifdef ALWAYS_FLUSH 70 | if (fflush(f__cf)) 71 | err(f__elist->cierr,errno,"write end"); 72 | #endif 73 | return(e_rdue()); 74 | } 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | --------------------------------------------------------------------------------