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>
13 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
72 (url "https://github.com/ntamas/plfit")
74 (file-name (git-file-name name version))
77 "03x5jbvg8vwr92682swy58ljxrhqwmga1xzd0cpfbfmda41gm2fb"))))
78 (build-system cmake-build-system)
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+)))
96 (uri (string-append "https://github.com/igraph/igraph/releases/"
97 "download/" version "/igraph-" version ".tar.gz"))
98 (modules '((guix build utils)))
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\\).*")
106 ;; Help CMake to find our plfit headers.
107 (substitute* "etc/cmake/FindPLFIT.cmake"
108 (("^ NAMES plfit.h.*" all)
110 " PATH_SUFFIXES plfit")))
111 (substitute* '("src/CMakeLists.txt"
112 "etc/cmake/benchmark_helpers.cmake")
113 ;; Remove bundling related variables.
114 ((".*_IS_VENDORED.*")
117 (base32 "11zkj9bpqcadb0rc4ahvjp9047dp9hna8cn3b0vl3zpc9v2rwabw"))))
118 (build-system cmake-build-system)
120 '(#:configure-flags (list "-DBUILD_SHARED_LIBS=ON")))
121 (native-inputs (list pkg-config))
131 (home-page "https://igraph.org")
132 (synopsis "Network analysis and visualization")
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
138 (license license:gpl2+)))
140 (define-public python-igraph
141 (package/inherit igraph
142 (name "python-igraph")
146 ;; The PyPI archive lacks tests.
148 (url "https://github.com/igraph/python-igraph")
150 (file-name (git-file-name name version))
153 "0ravcww2jcr8fgi97gdxv00s5nkx59ljxy928nnniyd0231bqwlc"))))
154 (build-system python-build-system)
158 #~(modify-phases %standard-phases
159 (add-after 'unpack 'specify-libigraph-location
161 (let ((igraph #$(this-package-input "igraph")))
162 (substitute* "setup.py"
163 (("(LIBIGRAPH_FALLBACK_INCLUDE_DIRS = ).*" _ var)
165 var (format #f "[~s]~%" (string-append igraph
166 "/include/igraph"))))
167 (("(LIBIGRAPH_FALLBACK_LIBRARY_DIRS = ).*" _ var)
169 var (format #f "[~s]~%" (string-append igraph "/lib"))))))))
171 (lambda* (#:key tests? #:allow-other-keys)
173 (invoke "pytest" "-v")))))))
177 (list python-texttable))
179 (list python-pytest))
180 (home-page "https://igraph.org/python/")
181 (synopsis "Python bindings for the igraph network analysis library")))
183 (define-public r-rbiofabric
184 (let ((commit "666c2ae8b0a537c006592d067fac6285f71890ac")
187 (name "r-rbiofabric")
188 (version (string-append "0.3-" revision "." (string-take commit 7)))
192 (url "https://github.com/wjrl/RBioFabric")
194 (file-name (string-append name "-" version "-checkout"))
197 "1yahqrcrqpbcywv73y9rlmyz8apdnp08afialibrr93ch0p06f8z"))))
198 (build-system r-build-system)
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
207 (license license:expat))))
209 (define-public python-plotly
211 (name "python-plotly")
216 (url "https://github.com/plotly/plotly.py")
217 (commit (string-append "v" version))))
218 (file-name (git-file-name name version))
221 "02wlgy7gf3v5ckiq9ab3prm53cckxkavlghqgkk9xw2sfmmrn61q"))))
222 (build-system python-build-system)
225 (modify-phases %standard-phases
226 (add-after 'unpack 'chdir
228 (chdir "packages/python/plotly")
231 (lambda* (#:key tests? #:allow-other-keys)
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")))))))
239 (list python-ipywidgets python-pytest python-xarray))
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)))
256 (define-public python-plotly-2.4.1
257 (package (inherit python-plotly)
262 (uri (pypi-uri "plotly" version))
265 "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
268 (list python-decorator
275 '(#:tests? #f)))) ; The tests are not distributed in the release
277 (define-public python-louvain
279 (name "python-louvain")
284 (uri (pypi-uri "python-louvain" version))
286 (base32 "1sqp97fwh4asx0jr72x8hil8z8fcg2xq92jklmh2m599pvgnx19a"))))
287 (build-system python-build-system)
289 (list python-networkx python-numpy))
290 (home-page "https://github.com/taynaud/python-louvain")
291 (synopsis "Louvain algorithm for community detection")
293 "This package provides a pure Python implementation of the Louvain
294 algorithm for community detection in large networks.")
295 (license license:bsd-3)))
297 (define-public python-louvain-0.6
299 (name "python-louvain")
301 ;; The tarball on Pypi does not include the tests.
305 (url "https://github.com/vtraag/louvain-igraph")
307 (file-name (git-file-name name version))
310 "0w31537sifkf65sck1iaip5i6d8g64pa3wdwad83d6p9jwkck57k"))))
311 (build-system python-build-system)
313 (list python-ddt python-igraph))
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")
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.
325 This package has been superseded by the @code{leidenalg} package and should
326 not be used for new projects.")
327 (license license:gpl3+)))
336 (url "https://github.com/facebookresearch/faiss")
337 (commit (string-append "v" version))))
338 (file-name (git-file-name name version))
341 "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
342 (modules '((guix build utils)))
345 (substitute* "utils.cpp"
346 (("#include <immintrin.h>")
347 "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
349 (build-system cmake-build-system)
352 (list "-DBUILD_WITH_GPU=OFF" ; thanks, but no thanks, CUDA.
353 "-DBUILD_TUTORIAL=OFF") ; we don't need those
355 (modify-phases %standard-phases
356 (add-after 'unpack 'prepare-build
358 (let ((features (list ,@(let ((system (or (%current-target-system)
361 ((string-prefix? "x86_64" system)
362 '("-mavx" "-msse2" "-mpopcnt"))
363 ((string-prefix? "i686" system)
364 '("-msse2" "-mpopcnt"))
367 (substitute* "CMakeLists.txt"
369 (("-mpopcnt") "") ; only some architectures
372 (string-join features)
374 ;; Build also the shared library
375 (("ARCHIVE DESTINATION lib")
376 "LIBRARY DESTINATION lib")
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)
386 ;; See https://github.com/facebookresearch/faiss/issues/520
387 (substitute* "IndexScalarQuantizer.cpp"
388 (("#define USE_AVX") ""))
390 ;; Make header files available for compiling tests.
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$"))
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")
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)))
419 (define-public python-faiss
420 (package (inherit faiss)
421 (name "python-faiss")
422 (build-system python-build-system)
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"
432 (let ((python-version ,(version-major+minor (package-version python))))
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
442 (list ,@(let ((system (or (%current-target-system)
445 ((string-prefix? "x86_64" system)
446 '("-mavx" "-msse2" "-mpopcnt"))
447 ((string-prefix? "i686" system)
448 '("-msse2" "-mpopcnt"))
451 (substitute* "Makefile"
452 (("../libfaiss.a") ""))
453 (invoke "make" "cpu"))))))
456 ("openblas" ,openblas)
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
465 (define-public python-leidenalg
467 (name "python-leidenalg")
472 (uri (pypi-uri "leidenalg" version))
475 "15fwld9hdw357rd026mzcwpah5liy4f33vc9x9kwy37g71b2rjf1"))))
476 (build-system python-build-system)
477 (arguments '(#:tests? #f)) ; tests are not included
483 (list python-igraph))
484 (home-page "https://github.com/vtraag/leidenalg")
485 (synopsis "Community detection in large networks")
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+)))
496 (define-public edge-addition-planarity-suite
498 (name "edge-addition-planarity-suite")
504 (url (string-append "https://github.com/graph-algorithms/"
506 (commit (string-append "Version_" version))))
507 (file-name (git-file-name name version))
510 "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8"))))
511 (build-system gnu-build-system)
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)
520 "https://github.com/graph-algorithms/edge-addition-planarity-suite")))
525 ;; There is a version 0.8, but the tarball is broken with symlinks
530 (uri (string-append "mirror://sourceforge/rankwidth/"
531 "rw-" version ".tar.gz"))
534 "1rv2v42x2506x7f10349m1wpmmfxrv9l032bkminni2gbip9cjg0"))))
535 (build-system gnu-build-system)
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
544 (license license:gpl2+)))
546 (define-public mscgen
553 (uri (string-append "http://www.mcternan.me.uk/mscgen/software/mscgen-src-"
557 "08yw3maxhn5fl1lff81gmcrpa4j9aas4mmby1g9w5qcr0np82d1w"))))
558 (build-system gnu-build-system)
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+)))
575 (define-public python-graph-tool
577 (name "python-graph-tool")
582 "https://downloads.skewed.de/graph-tool/graph-tool-"
586 "0v58in4rwk9fhjarjw6xfxpx5zz2z13sy3yvd14b5kr0884yw6sz"))))
587 (build-system gnu-build-system)
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)))
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)))))
599 (list ncurses pkg-config))
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+)))