gnu: igraph: Update to 0.9.9.
[jackhill/guix/guix.git] / gnu / packages / graph.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2018 Joshua Sierles, Nextjournal <joshua@nextjournal.com>
4 ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
7 ;;; Copyright © 2020 Alexander Krotov <krotov@iitp.ru>
8 ;;; Copyright © 2020 Pierre Langlois <pierre.langlos@gmx.com>
9 ;;; Copyright © 2021 Vinicius Monego <monego@posteo.net>
10 ;;; Copyright © 2021 Alexandre Hannud Abdo <abdo@member.fsf.org>
11 ;;; Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
12 ;;;
13 ;;; This file is part of GNU Guix.
14 ;;;
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
19 ;;;
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
24 ;;;
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28 (define-module (gnu packages graph)
29 #:use-module (guix download)
30 #:use-module (guix gexp)
31 #:use-module (guix git-download)
32 #:use-module (guix packages)
33 #:use-module (guix utils)
34 #:use-module (guix build-system cmake)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system python)
37 #:use-module (guix build-system r)
38 #:use-module ((guix licenses) #:prefix license:)
39 #:use-module (gnu packages)
40 #:use-module (gnu packages autotools)
41 #:use-module (gnu packages bioconductor)
42 #:use-module (gnu packages bioinformatics)
43 #:use-module (gnu packages boost)
44 #:use-module (gnu packages check)
45 #:use-module (gnu packages compression)
46 #:use-module (gnu packages cran)
47 #:use-module (gnu packages datastructures)
48 #:use-module (gnu packages gd)
49 #:use-module (gnu packages graphics)
50 #:use-module (gnu packages graphviz)
51 #:use-module (gnu packages gtk)
52 #:use-module (gnu packages maths)
53 #:use-module (gnu packages multiprecision)
54 #:use-module (gnu packages ncurses)
55 #:use-module (gnu packages pkg-config)
56 #:use-module (gnu packages python)
57 #:use-module (gnu packages python-science)
58 #:use-module (gnu packages python-web)
59 #:use-module (gnu packages python-xyz)
60 #:use-module (gnu packages statistics)
61 #:use-module (gnu packages swig)
62 #:use-module (gnu packages time)
63 #:use-module (gnu packages xml))
64
65 (define-public plfit
66 (package
67 (name "plfit")
68 (version "0.9.3")
69 (source (origin
70 (method git-fetch)
71 (uri (git-reference
72 (url "https://github.com/ntamas/plfit")
73 (commit version)))
74 (file-name (git-file-name name version))
75 (sha256
76 (base32
77 "03x5jbvg8vwr92682swy58ljxrhqwmga1xzd0cpfbfmda41gm2fb"))))
78 (build-system cmake-build-system)
79 (arguments
80 '(#:configure-flags (list "-DBUILD_SHARED_LIBS=ON")))
81 (home-page "https://github.com/ntamas/plfit")
82 (synopsis "Tool for fitting power-law distributions to empirical data")
83 (description "The @command{plfit} command fits power-law distributions to
84 empirical (discrete or continuous) data, according to the method of Clauset,
85 Shalizi and Newman (@cite{Clauset A, Shalizi CR and Newman MEJ: Power-law
86 distributions in empirical data. SIAM Review 51, 661-703 (2009)}).")
87 (license license:gpl2+)))
88
89 (define-public igraph
90 (package
91 (name "igraph")
92 (version "0.9.6")
93 (source
94 (origin
95 (method url-fetch)
96 (uri (string-append "https://github.com/igraph/igraph/releases/"
97 "download/" version "/igraph-" version ".tar.gz"))
98 (modules '((guix build utils)))
99 (snippet '(begin
100 ;; Fully unbundle igraph (see:
101 ;; https://github.com/igraph/igraph/issues/1897).
102 (delete-file-recursively "vendor")
103 (substitute* "CMakeLists.txt"
104 (("add_subdirectory\\(vendor\\).*")
105 ""))
106 ;; Help CMake to find our plfit headers.
107 (substitute* "etc/cmake/FindPLFIT.cmake"
108 (("^ NAMES plfit.h.*" all)
109 (string-append all
110 " PATH_SUFFIXES plfit")))
111 (substitute* '("src/CMakeLists.txt"
112 "etc/cmake/benchmark_helpers.cmake")
113 ;; Remove bundling related variables.
114 ((".*_IS_VENDORED.*")
115 ""))))
116 (sha256
117 (base32 "11zkj9bpqcadb0rc4ahvjp9047dp9hna8cn3b0vl3zpc9v2rwabw"))))
118 (build-system cmake-build-system)
119 (arguments
120 '(#:configure-flags (list "-DBUILD_SHARED_LIBS=ON")))
121 (native-inputs (list pkg-config))
122 (inputs
123 (list arpack-ng
124 gmp
125 glpk
126 libxml2
127 lapack
128 openblas
129 plfit
130 suitesparse))
131 (home-page "https://igraph.org")
132 (synopsis "Network analysis and visualization")
133 (description
134 "This package provides a library for the analysis of networks and graphs.
135 It can handle large graphs very well and provides functions for generating
136 random and regular graphs, graph visualization, centrality methods and much
137 more.")
138 (license license:gpl2+)))
139
140 (define-public python-igraph
141 (package/inherit igraph
142 (name "python-igraph")
143 (version "0.9.9")
144 (source (origin
145 (method git-fetch)
146 ;; The PyPI archive lacks tests.
147 (uri (git-reference
148 (url "https://github.com/igraph/python-igraph")
149 (commit version)))
150 (file-name (git-file-name name version))
151 (sha256
152 (base32
153 "0ravcww2jcr8fgi97gdxv00s5nkx59ljxy928nnniyd0231bqwlc"))))
154 (build-system python-build-system)
155 (arguments
156 (list
157 #:phases
158 #~(modify-phases %standard-phases
159 (add-after 'unpack 'specify-libigraph-location
160 (lambda _
161 (let ((igraph #$(this-package-input "igraph")))
162 (substitute* "setup.py"
163 (("(LIBIGRAPH_FALLBACK_INCLUDE_DIRS = ).*" _ var)
164 (string-append
165 var (format #f "[~s]~%" (string-append igraph
166 "/include/igraph"))))
167 (("(LIBIGRAPH_FALLBACK_LIBRARY_DIRS = ).*" _ var)
168 (string-append
169 var (format #f "[~s]~%" (string-append igraph "/lib"))))))))
170 (replace 'check
171 (lambda* (#:key tests? #:allow-other-keys)
172 (when tests?
173 (invoke "pytest" "-v")))))))
174 (inputs
175 (list igraph))
176 (propagated-inputs
177 (list python-texttable))
178 (native-inputs
179 (list python-pytest))
180 (home-page "https://igraph.org/python/")
181 (synopsis "Python bindings for the igraph network analysis library")))
182
183 (define-public r-rbiofabric
184 (let ((commit "666c2ae8b0a537c006592d067fac6285f71890ac")
185 (revision "1"))
186 (package
187 (name "r-rbiofabric")
188 (version (string-append "0.3-" revision "." (string-take commit 7)))
189 (source (origin
190 (method git-fetch)
191 (uri (git-reference
192 (url "https://github.com/wjrl/RBioFabric")
193 (commit commit)))
194 (file-name (string-append name "-" version "-checkout"))
195 (sha256
196 (base32
197 "1yahqrcrqpbcywv73y9rlmyz8apdnp08afialibrr93ch0p06f8z"))))
198 (build-system r-build-system)
199 (propagated-inputs
200 (list r-igraph))
201 (home-page "http://www.biofabric.org/")
202 (synopsis "BioFabric network visualization")
203 (description "This package provides an implementation of the function
204 @code{bioFabric} for creating scalable network digrams where nodes are
205 represented by horizontal lines, and edges are represented by vertical
206 lines.")
207 (license license:expat))))
208
209 (define-public python-plotly
210 (package
211 (name "python-plotly")
212 (version "4.14.3")
213 (source (origin
214 (method git-fetch)
215 (uri (git-reference
216 (url "https://github.com/plotly/plotly.py")
217 (commit (string-append "v" version))))
218 (file-name (git-file-name name version))
219 (sha256
220 (base32
221 "02wlgy7gf3v5ckiq9ab3prm53cckxkavlghqgkk9xw2sfmmrn61q"))))
222 (build-system python-build-system)
223 (arguments
224 `(#:phases
225 (modify-phases %standard-phases
226 (add-after 'unpack 'chdir
227 (lambda _
228 (chdir "packages/python/plotly")
229 #t))
230 (replace 'check
231 (lambda* (#:key tests? #:allow-other-keys)
232 (when tests?
233 (invoke "pytest" "-x" "plotly/tests/test_core")
234 (invoke "pytest" "-x" "plotly/tests/test_io")
235 ;; FIXME: Add optional dependencies and enable their tests.
236 ;; (invoke "pytest" "-x" "plotly/tests/test_optional")
237 (invoke "pytest" "_plotly_utils/tests")))))))
238 (native-inputs
239 (list python-ipywidgets python-pytest python-xarray))
240 (propagated-inputs
241 (list python-ipython
242 python-pandas
243 python-pillow
244 python-requests
245 python-retrying
246 python-six
247 python-statsmodels))
248 (home-page "https://plotly.com/python/")
249 (synopsis "Interactive plotting library for Python")
250 (description "Plotly's Python graphing library makes interactive,
251 publication-quality graphs online. Examples of how to make line plots, scatter
252 plots, area charts, bar charts, error bars, box plots, histograms, heatmaps,
253 subplots, multiple-axes, polar charts, and bubble charts.")
254 (license license:expat)))
255
256 (define-public python-plotly-2.4.1
257 (package (inherit python-plotly)
258 (version "2.4.1")
259 (source
260 (origin
261 (method url-fetch)
262 (uri (pypi-uri "plotly" version))
263 (sha256
264 (base32
265 "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
266 (native-inputs '())
267 (propagated-inputs
268 (list python-decorator
269 python-nbformat
270 python-pandas
271 python-pytz
272 python-requests
273 python-six))
274 (arguments
275 '(#:tests? #f)))) ; The tests are not distributed in the release
276
277 (define-public python-louvain
278 (package
279 (name "python-louvain")
280 (version "0.15")
281 (source
282 (origin
283 (method url-fetch)
284 (uri (pypi-uri "python-louvain" version))
285 (sha256
286 (base32 "1sqp97fwh4asx0jr72x8hil8z8fcg2xq92jklmh2m599pvgnx19a"))))
287 (build-system python-build-system)
288 (propagated-inputs
289 (list python-networkx python-numpy))
290 (home-page "https://github.com/taynaud/python-louvain")
291 (synopsis "Louvain algorithm for community detection")
292 (description
293 "This package provides a pure Python implementation of the Louvain
294 algorithm for community detection in large networks.")
295 (license license:bsd-3)))
296
297 (define-public python-louvain-0.6
298 (package
299 (name "python-louvain")
300 (version "0.6.1")
301 ;; The tarball on Pypi does not include the tests.
302 (source (origin
303 (method git-fetch)
304 (uri (git-reference
305 (url "https://github.com/vtraag/louvain-igraph")
306 (commit version)))
307 (file-name (git-file-name name version))
308 (sha256
309 (base32
310 "0w31537sifkf65sck1iaip5i6d8g64pa3wdwad83d6p9jwkck57k"))))
311 (build-system python-build-system)
312 (propagated-inputs
313 (list python-ddt python-igraph))
314 (inputs
315 (list igraph))
316 (native-inputs
317 (list pkg-config python-pytest))
318 (home-page "https://github.com/vtraag/louvain-igraph")
319 (synopsis "Algorithm for methods of community detection in large networks")
320 (description
321 "This package provides an implementation of the Louvain algorithm for use
322 with igraph. Louvain is a general algorithm for methods of community
323 detection in large networks.
324
325 This package has been superseded by the @code{leidenalg} package and should
326 not be used for new projects.")
327 (license license:gpl3+)))
328
329 (define-public faiss
330 (package
331 (name "faiss")
332 (version "1.5.0")
333 (source (origin
334 (method git-fetch)
335 (uri (git-reference
336 (url "https://github.com/facebookresearch/faiss")
337 (commit (string-append "v" version))))
338 (file-name (git-file-name name version))
339 (sha256
340 (base32
341 "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
342 (modules '((guix build utils)))
343 (snippet
344 '(begin
345 (substitute* "utils.cpp"
346 (("#include <immintrin.h>")
347 "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
348 #t))))
349 (build-system cmake-build-system)
350 (arguments
351 `(#:configure-flags
352 (list "-DBUILD_WITH_GPU=OFF" ; thanks, but no thanks, CUDA.
353 "-DBUILD_TUTORIAL=OFF") ; we don't need those
354 #:phases
355 (modify-phases %standard-phases
356 (add-after 'unpack 'prepare-build
357 (lambda _
358 (let ((features (list ,@(let ((system (or (%current-target-system)
359 (%current-system))))
360 (cond
361 ((string-prefix? "x86_64" system)
362 '("-mavx" "-msse2" "-mpopcnt"))
363 ((string-prefix? "i686" system)
364 '("-msse2" "-mpopcnt"))
365 (else
366 '()))))))
367 (substitute* "CMakeLists.txt"
368 (("-m64") "")
369 (("-mpopcnt") "") ; only some architectures
370 (("-msse4")
371 (string-append
372 (string-join features)
373 " -I" (getcwd)))
374 ;; Build also the shared library
375 (("ARCHIVE DESTINATION lib")
376 "LIBRARY DESTINATION lib")
377 (("add_library.*" m)
378 "\
379 add_library(objlib OBJECT ${faiss_cpu_headers} ${faiss_cpu_cpp})
380 set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
381 add_library(${faiss_lib}_static STATIC $<TARGET_OBJECTS:objlib>)
382 add_library(${faiss_lib} SHARED $<TARGET_OBJECTS:objlib>)
383 install(TARGETS ${faiss_lib}_static ARCHIVE DESTINATION lib)
384 \n")))
385
386 ;; See https://github.com/facebookresearch/faiss/issues/520
387 (substitute* "IndexScalarQuantizer.cpp"
388 (("#define USE_AVX") ""))
389
390 ;; Make header files available for compiling tests.
391 (mkdir-p "faiss")
392 (for-each (lambda (file)
393 (mkdir-p (string-append "faiss/" (dirname file)))
394 (copy-file file (string-append "faiss/" file)))
395 (find-files "." "\\.h$"))
396 #t))
397 (replace 'check
398 (lambda _
399 (invoke "make" "-C" "tests"
400 (format #f "-j~a" (parallel-job-count)))))
401 (add-after 'install 'remove-tests
402 (lambda* (#:key outputs #:allow-other-keys)
403 (delete-file-recursively
404 (string-append (assoc-ref outputs "out")
405 "/test"))
406 #t)))))
407 (inputs
408 (list openblas))
409 (native-inputs
410 (list googletest))
411 (home-page "https://github.com/facebookresearch/faiss")
412 (synopsis "Efficient similarity search and clustering of dense vectors")
413 (description "Faiss is a library for efficient similarity search and
414 clustering of dense vectors. It contains algorithms that search in sets of
415 vectors of any size, up to ones that possibly do not fit in RAM. It also
416 contains supporting code for evaluation and parameter tuning.")
417 (license license:bsd-3)))
418
419 (define-public python-faiss
420 (package (inherit faiss)
421 (name "python-faiss")
422 (build-system python-build-system)
423 (arguments
424 `(#:phases
425 (modify-phases %standard-phases
426 (add-after 'unpack 'chdir
427 (lambda _ (chdir "python") #t))
428 (add-after 'chdir 'build-swig
429 (lambda* (#:key inputs #:allow-other-keys)
430 (with-output-to-file "../makefile.inc"
431 (lambda ()
432 (let ((python-version ,(version-major+minor (package-version python))))
433 (format #t "\
434 PYTHONCFLAGS =-I~a/include/python~am/ -I~a/lib/python~a/site-packages/numpy/core/include
435 LIBS = -lpython~am -lfaiss
436 SHAREDFLAGS = -shared -fopenmp
437 CXXFLAGS = -fpermissive -fopenmp -fPIC
438 CPUFLAGS = ~{~a ~}~%"
439 (assoc-ref inputs "python*") python-version
440 (assoc-ref inputs "python-numpy") python-version
441 python-version
442 (list ,@(let ((system (or (%current-target-system)
443 (%current-system))))
444 (cond
445 ((string-prefix? "x86_64" system)
446 '("-mavx" "-msse2" "-mpopcnt"))
447 ((string-prefix? "i686" system)
448 '("-msse2" "-mpopcnt"))
449 (else
450 '()))))))))
451 (substitute* "Makefile"
452 (("../libfaiss.a") ""))
453 (invoke "make" "cpu"))))))
454 (inputs
455 `(("faiss" ,faiss)
456 ("openblas" ,openblas)
457 ("python*" ,python)
458 ("swig" ,swig)))
459 (propagated-inputs
460 (list python-matplotlib python-numpy))
461 (description "Faiss is a library for efficient similarity search and
462 clustering of dense vectors. This package provides Python bindings to the
463 Faiss library.")))
464
465 (define-public python-leidenalg
466 (package
467 (name "python-leidenalg")
468 (version "0.7.0")
469 (source
470 (origin
471 (method url-fetch)
472 (uri (pypi-uri "leidenalg" version))
473 (sha256
474 (base32
475 "15fwld9hdw357rd026mzcwpah5liy4f33vc9x9kwy37g71b2rjf1"))))
476 (build-system python-build-system)
477 (arguments '(#:tests? #f)) ; tests are not included
478 (native-inputs
479 (list pkg-config))
480 (inputs
481 (list igraph))
482 (propagated-inputs
483 (list python-igraph))
484 (home-page "https://github.com/vtraag/leidenalg")
485 (synopsis "Community detection in large networks")
486 (description
487 "Leiden is a general algorithm for methods of community detection in
488 large networks. This package implements the Leiden algorithm in C++ and
489 exposes it to Python. Besides the relative flexibility of the implementation,
490 it also scales well, and can be run on graphs of millions of nodes (as long as
491 they can fit in memory). The core function is @code{find_partition} which
492 finds the optimal partition using the Leiden algorithm, which is an extension
493 of the Louvain algorithm, for a number of different methods.")
494 (license license:gpl3+)))
495
496 (define-public edge-addition-planarity-suite
497 (package
498 (name "edge-addition-planarity-suite")
499 (version "3.0.0.5")
500 (source
501 (origin
502 (method git-fetch)
503 (uri (git-reference
504 (url (string-append "https://github.com/graph-algorithms/"
505 name))
506 (commit (string-append "Version_" version))))
507 (file-name (git-file-name name version))
508 (sha256
509 (base32
510 "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8"))))
511 (build-system gnu-build-system)
512 (native-inputs
513 (list autoconf automake libtool))
514 (synopsis "Embedding of planar graphs")
515 (description "The package provides a reference implementation of the
516 linear time edge addition algorithm for embedding planar graphs and
517 isolating planarity obstructions.")
518 (license license:bsd-3)
519 (home-page
520 "https://github.com/graph-algorithms/edge-addition-planarity-suite")))
521
522 (define-public rw
523 (package
524 (name "rw")
525 ;; There is a version 0.8, but the tarball is broken with symlinks
526 ;; to /usr/share.
527 (version "0.7")
528 (source (origin
529 (method url-fetch)
530 (uri (string-append "mirror://sourceforge/rankwidth/"
531 "rw-" version ".tar.gz"))
532 (sha256
533 (base32
534 "1rv2v42x2506x7f10349m1wpmmfxrv9l032bkminni2gbip9cjg0"))))
535 (build-system gnu-build-system)
536 (native-inputs
537 (list pkg-config))
538 (inputs
539 (list igraph))
540 (home-page "https://sourceforge.net/projects/rankwidth/")
541 (synopsis "Rank-width and rank-decomposition of graphs")
542 (description "rw computes rank-width and rank-decompositions
543 of graphs.")
544 (license license:gpl2+)))
545
546 (define-public mscgen
547 (package
548 (name "mscgen")
549 (version "0.20")
550 (source
551 (origin
552 (method url-fetch)
553 (uri (string-append "http://www.mcternan.me.uk/mscgen/software/mscgen-src-"
554 version ".tar.gz"))
555 (sha256
556 (base32
557 "08yw3maxhn5fl1lff81gmcrpa4j9aas4mmby1g9w5qcr0np82d1w"))))
558 (build-system gnu-build-system)
559 (native-inputs
560 (list pkg-config))
561 (inputs
562 (list gd))
563 (home-page "http://www.mcternan.me.uk/mscgen/")
564 (synopsis "Message Sequence Chart Generator")
565 (description "Mscgen is a small program that parses Message Sequence Chart
566 descriptions and produces PNG, SVG, EPS or server side image maps (ismaps) as
567 the output. Message Sequence Charts (MSCs) are a way of representing entities
568 and interactions over some time period and are often used in combination with
569 SDL. MSCs are popular in Telecoms to specify how protocols operate although
570 MSCs need not be complicated to create or use. Mscgen aims to provide a simple
571 text language that is clear to create, edit and understand, which can also be
572 transformed into common image formats for display or printing.")
573 (license license:gpl2+)))
574
575 (define-public python-graph-tool
576 (package
577 (name "python-graph-tool")
578 (version "2.43")
579 (source (origin
580 (method url-fetch)
581 (uri (string-append
582 "https://downloads.skewed.de/graph-tool/graph-tool-"
583 version ".tar.bz2"))
584 (sha256
585 (base32
586 "0v58in4rwk9fhjarjw6xfxpx5zz2z13sy3yvd14b5kr0884yw6sz"))))
587 (build-system gnu-build-system)
588 (arguments
589 `(#:imported-modules (,@%gnu-build-system-modules
590 (guix build python-build-system))
591 #:modules (,@%gnu-build-system-modules
592 ((guix build python-build-system) #:select (site-packages)))
593 #:configure-flags
594 (list (string-append "--with-boost="
595 (assoc-ref %build-inputs "boost"))
596 (string-append "--with-python-module-path="
597 (site-packages %build-inputs %outputs)))))
598 (native-inputs
599 (list ncurses pkg-config))
600 (inputs
601 (list boost
602 cairomm-1.14
603 cgal
604 expat
605 gmp
606 gtk+
607 python-wrapper
608 sparsehash))
609 (propagated-inputs
610 (list python-matplotlib python-numpy python-pycairo python-scipy))
611 (synopsis "Manipulate and analyze graphs with Python efficiently")
612 (description "Graph-tool is an efficient Python module for manipulation
613 and statistical analysis of graphs (a.k.a. networks). Contrary to most other
614 Python modules with similar functionality, the core data structures and
615 algorithms are implemented in C++, making extensive use of template
616 metaprogramming, based heavily on the Boost Graph Library. This confers it a
617 level of performance that is comparable (both in memory usage and computation
618 time) to that of a pure C/C++ library.")
619 (home-page "https://graph-tool.skewed.de/")
620 (license license:lgpl3+)))