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>
10 ;;; This file is part of GNU Guix.
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
25 (define-module (gnu packages graph)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix packages)
29 #:use-module (guix utils)
30 #:use-module (guix build-system cmake)
31 #:use-module (guix build-system gnu)
32 #:use-module (guix build-system python)
33 #:use-module (guix build-system r)
34 #:use-module ((guix licenses) #:prefix license:)
35 #:use-module (gnu packages)
36 #:use-module (gnu packages gcc)
37 #:use-module (gnu packages autotools)
38 #:use-module (gnu packages bioconductor)
39 #:use-module (gnu packages bioinformatics)
40 #:use-module (gnu packages check)
41 #:use-module (gnu packages compression)
42 #:use-module (gnu packages cran)
43 #:use-module (gnu packages gd)
44 #:use-module (gnu packages graphviz)
45 #:use-module (gnu packages maths)
46 #:use-module (gnu packages multiprecision)
47 #:use-module (gnu packages pkg-config)
48 #:use-module (gnu packages python)
49 #:use-module (gnu packages python-science)
50 #:use-module (gnu packages python-web)
51 #:use-module (gnu packages python-xyz)
52 #:use-module (gnu packages statistics)
53 #:use-module (gnu packages swig)
54 #:use-module (gnu packages time)
55 #:use-module (gnu packages xml))
64 (uri (string-append "https://github.com/igraph/igraph/releases/"
65 "download/" version "/igraph-" version ".tar.gz"))
67 (base32 "127q6q40kbmvd62yhbz6dlfk370qiq98s1iscyagpgbpjwb4xvyf"))))
68 (build-system gnu-build-system)
71 (list "--disable-static"
72 "--with-external-glpk"
73 "--with-external-blas"
74 "--with-external-lapack")))
80 ("openblas" ,openblas)
82 (home-page "https://igraph.org")
83 (synopsis "Network analysis and visualization")
85 "This package provides a library for the analysis of networks and graphs.
86 It can handle large graphs very well and provides functions for generating
87 random and regular graphs, graph visualization, centrality methods and much
89 (license license:gpl2+)))
91 (define-public python-igraph
92 (package (inherit igraph)
93 (name "python-igraph")
98 (uri (pypi-uri "python-igraph" version))
100 (base32 "0wkxrs28qdvnrz7d4jzcf2bh6v2yqzx3wyfziihfgsi2gn6n60a6"))))
101 (build-system python-build-system)
104 (list "--use-pkg-config")
106 (modify-phases %standard-phases
109 (invoke "python" "./setup.py" "build" "--use-pkg-config")))
111 (add-after 'install 'check
112 (lambda* (#:key inputs outputs #:allow-other-keys)
113 (add-installed-pythonpath inputs outputs)
114 (invoke "pytest" "-v"))))))
116 `(("igraph" ,igraph)))
118 `(("python-texttable" ,python-texttable)))
120 `(("pkg-config" ,pkg-config)
121 ("python-pytest" ,python-pytest)))
122 (home-page "https://pypi.org/project/python-igraph/")
123 (synopsis "Python bindings for the igraph network analysis library")))
125 (define-public r-rbiofabric
126 (let ((commit "666c2ae8b0a537c006592d067fac6285f71890ac")
129 (name "r-rbiofabric")
130 (version (string-append "0.3-" revision "." (string-take commit 7)))
134 (url "https://github.com/wjrl/RBioFabric")
136 (file-name (string-append name "-" version "-checkout"))
139 "1yahqrcrqpbcywv73y9rlmyz8apdnp08afialibrr93ch0p06f8z"))))
140 (build-system r-build-system)
142 `(("r-igraph" ,r-igraph)))
143 (home-page "http://www.biofabric.org/")
144 (synopsis "BioFabric network visualization")
145 (description "This package provides an implementation of the function
146 @code{bioFabric} for creating scalable network digrams where nodes are
147 represented by horizontal lines, and edges are represented by vertical
149 (license license:expat))))
151 (define-public python-plotly
153 (name "python-plotly")
158 (url "https://github.com/plotly/plotly.py")
159 (commit (string-append "v" version))))
160 (file-name (git-file-name name version))
163 "02wlgy7gf3v5ckiq9ab3prm53cckxkavlghqgkk9xw2sfmmrn61q"))))
164 (build-system python-build-system)
167 (modify-phases %standard-phases
168 (add-after 'unpack 'chdir
170 (chdir "packages/python/plotly")
173 (lambda* (#:key tests? #:allow-other-keys)
175 (invoke "pytest" "-x" "plotly/tests/test_core")
176 (invoke "pytest" "-x" "plotly/tests/test_io")
177 ;; FIXME: Add optional dependencies and enable their tests.
178 ;; (invoke "pytest" "-x" "plotly/tests/test_optional")
179 (invoke "pytest" "_plotly_utils/tests"))
181 (add-before 'reset-gzip-timestamps 'make-files-writable
182 (lambda* (#:key outputs #:allow-other-keys)
183 (let ((out (assoc-ref outputs "out")))
184 (for-each (lambda (file) (chmod file #o644))
185 (find-files out "\\.gz"))
188 `(("python-ipywidgets" ,python-ipywidgets)
189 ("python-pytest" ,python-pytest)
190 ("python-xarray" ,python-xarray)))
192 `(("python-ipython" ,python-ipython)
193 ("python-pandas" ,python-pandas)
194 ("python-pillow" ,python-pillow)
195 ("python-requests" ,python-requests)
196 ("python-retrying" ,python-retrying)
197 ("python-six" ,python-six)
198 ("python-statsmodels" ,python-statsmodels)))
199 (home-page "https://plotly.com/python/")
200 (synopsis "Interactive plotting library for Python")
201 (description "Plotly's Python graphing library makes interactive,
202 publication-quality graphs online. Examples of how to make line plots, scatter
203 plots, area charts, bar charts, error bars, box plots, histograms, heatmaps,
204 subplots, multiple-axes, polar charts, and bubble charts. ")
205 (license license:expat)))
207 (define-public python-plotly-2.4.1
208 (package (inherit python-plotly)
213 (uri (pypi-uri "plotly" version))
216 "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
219 `(("python-decorator" ,python-decorator)
220 ("python-nbformat" ,python-nbformat)
221 ("python-pandas" ,python-pandas)
222 ("python-pytz" ,python-pytz)
223 ("python-requests" ,python-requests)
224 ("python-six" ,python-six)))
226 '(#:tests? #f)))) ; The tests are not distributed in the release
228 (define-public python2-plotly
229 (package-with-python2 python-plotly-2.4.1))
231 (define-public python-louvain
233 (name "python-louvain")
235 ;; The tarball on Pypi does not include the tests.
239 (url "https://github.com/vtraag/louvain-igraph")
241 (file-name (git-file-name name version))
244 "0w31537sifkf65sck1iaip5i6d8g64pa3wdwad83d6p9jwkck57k"))))
245 (build-system python-build-system)
247 `(("python-ddt" ,python-ddt)
248 ("python-igraph" ,python-igraph)))
250 `(("igraph" ,igraph)))
252 `(("pkg-config" ,pkg-config)
253 ("python-pytest" ,python-pytest)))
254 (home-page "https://github.com/vtraag/louvain-igraph")
255 (synopsis "Algorithm for methods of community detection in large networks")
257 "This package provides an implementation of the Louvain algorithm for use
258 with igraph. Louvain is a general algorithm for methods of community
259 detection in large networks.
261 This package has been superseded by the @code{leidenalg} package and should
262 not be used for new projects.")
263 (license license:gpl3+)))
272 (url "https://github.com/facebookresearch/faiss")
273 (commit (string-append "v" version))))
274 (file-name (git-file-name name version))
277 "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
278 (modules '((guix build utils)))
281 (substitute* "utils.cpp"
282 (("#include <immintrin.h>")
283 "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
285 (build-system cmake-build-system)
288 (list "-DBUILD_WITH_GPU=OFF" ; thanks, but no thanks, CUDA.
289 "-DBUILD_TUTORIAL=OFF") ; we don't need those
291 (modify-phases %standard-phases
292 (add-after 'unpack 'prepare-build
294 (let ((features (list ,@(let ((system (or (%current-target-system)
297 ((string-prefix? "x86_64" system)
298 '("-mavx" "-msse2" "-mpopcnt"))
299 ((string-prefix? "i686" system)
300 '("-msse2" "-mpopcnt"))
303 (substitute* "CMakeLists.txt"
305 (("-mpopcnt") "") ; only some architectures
308 (string-join features)
310 ;; Build also the shared library
311 (("ARCHIVE DESTINATION lib")
312 "LIBRARY DESTINATION lib")
315 add_library(objlib OBJECT ${faiss_cpu_headers} ${faiss_cpu_cpp})
316 set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
317 add_library(${faiss_lib}_static STATIC $<TARGET_OBJECTS:objlib>)
318 add_library(${faiss_lib} SHARED $<TARGET_OBJECTS:objlib>)
319 install(TARGETS ${faiss_lib}_static ARCHIVE DESTINATION lib)
322 ;; See https://github.com/facebookresearch/faiss/issues/520
323 (substitute* "IndexScalarQuantizer.cpp"
324 (("#define USE_AVX") ""))
326 ;; Make header files available for compiling tests.
328 (for-each (lambda (file)
329 (mkdir-p (string-append "faiss/" (dirname file)))
330 (copy-file file (string-append "faiss/" file)))
331 (find-files "." "\\.h$"))
335 (invoke "make" "-C" "tests"
336 (format #f "-j~a" (parallel-job-count)))))
337 (add-after 'install 'remove-tests
338 (lambda* (#:key outputs #:allow-other-keys)
339 (delete-file-recursively
340 (string-append (assoc-ref outputs "out")
344 `(("openblas" ,openblas)))
346 `(("googletest" ,googletest)))
347 (home-page "https://github.com/facebookresearch/faiss")
348 (synopsis "Efficient similarity search and clustering of dense vectors")
349 (description "Faiss is a library for efficient similarity search and
350 clustering of dense vectors. It contains algorithms that search in sets of
351 vectors of any size, up to ones that possibly do not fit in RAM. It also
352 contains supporting code for evaluation and parameter tuning.")
353 (license license:bsd-3)))
355 (define-public python-faiss
356 (package (inherit faiss)
357 (name "python-faiss")
358 (build-system python-build-system)
361 (modify-phases %standard-phases
362 (add-after 'unpack 'chdir
363 (lambda _ (chdir "python") #t))
364 (add-after 'chdir 'build-swig
365 (lambda* (#:key inputs #:allow-other-keys)
366 (with-output-to-file "../makefile.inc"
368 (let ((python-version ,(version-major+minor (package-version python))))
370 PYTHONCFLAGS =-I~a/include/python~am/ -I~a/lib/python~a/site-packages/numpy/core/include
371 LIBS = -lpython~am -lfaiss
372 SHAREDFLAGS = -shared -fopenmp
373 CXXFLAGS = -fpermissive -fopenmp -fPIC
374 CPUFLAGS = ~{~a ~}~%"
375 (assoc-ref inputs "python*") python-version
376 (assoc-ref inputs "python-numpy") python-version
378 (list ,@(let ((system (or (%current-target-system)
381 ((string-prefix? "x86_64" system)
382 '("-mavx" "-msse2" "-mpopcnt"))
383 ((string-prefix? "i686" system)
384 '("-msse2" "-mpopcnt"))
387 (substitute* "Makefile"
388 (("../libfaiss.a") ""))
389 (invoke "make" "cpu"))))))
392 ("openblas" ,openblas)
396 `(("python-matplotlib" ,python-matplotlib)
397 ("python-numpy" ,python-numpy)))
398 (description "Faiss is a library for efficient similarity search and
399 clustering of dense vectors. This package provides Python bindings to the
402 (define-public python-leidenalg
404 (name "python-leidenalg")
409 (uri (pypi-uri "leidenalg" version))
412 "15fwld9hdw357rd026mzcwpah5liy4f33vc9x9kwy37g71b2rjf1"))))
413 (build-system python-build-system)
414 (arguments '(#:tests? #f)) ; tests are not included
416 `(("pkg-config" ,pkg-config)))
418 `(("igraph" ,igraph)))
420 `(("python-igraph" ,python-igraph)))
421 (home-page "https://github.com/vtraag/leidenalg")
422 (synopsis "Community detection in large networks")
424 "Leiden is a general algorithm for methods of community detection in
425 large networks. This package implements the Leiden algorithm in C++ and
426 exposes it to Python. Besides the relative flexibility of the implementation,
427 it also scales well, and can be run on graphs of millions of nodes (as long as
428 they can fit in memory). The core function is @code{find_partition} which
429 finds the optimal partition using the Leiden algorithm, which is an extension
430 of the Louvain algorithm, for a number of different methods.")
431 (license license:gpl3+)))
433 (define-public edge-addition-planarity-suite
435 (name "edge-addition-planarity-suite")
441 (url (string-append "https://github.com/graph-algorithms/"
443 (commit (string-append "Version_" version))))
444 (file-name (git-file-name name version))
447 "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8"))))
448 (build-system gnu-build-system)
450 `(("autoconf" ,autoconf)
451 ("automake" ,automake)
452 ("libtool" ,libtool)))
453 (synopsis "Embedding of planar graphs")
454 (description "The package provides a reference implementation of the
455 linear time edge addition algorithm for embedding planar graphs and
456 isolating planarity obstructions.")
457 (license license:bsd-3)
459 "https://github.com/graph-algorithms/edge-addition-planarity-suite")))
464 ;; There is a version 0.8, but the tarball is broken with symlinks
469 (uri (string-append "mirror://sourceforge/rankwidth/"
470 "rw-" version ".tar.gz"))
473 "1rv2v42x2506x7f10349m1wpmmfxrv9l032bkminni2gbip9cjg0"))))
474 (build-system gnu-build-system)
476 `(("pkg-config" ,pkg-config)))
478 `(("igraph" ,igraph)))
479 (home-page "https://sourceforge.net/projects/rankwidth/")
480 (synopsis "Rank-width and rank-decomposition of graphs")
481 (description "rw computes rank-width and rank-decompositions
483 (license license:gpl2+)))
485 (define-public mscgen
492 (uri (string-append "http://www.mcternan.me.uk/mscgen/software/mscgen-src-"
496 "08yw3maxhn5fl1lff81gmcrpa4j9aas4mmby1g9w5qcr0np82d1w"))))
497 (build-system gnu-build-system)
499 `(("pkg-config" ,pkg-config)))
502 (home-page "http://www.mcternan.me.uk/mscgen/")
503 (synopsis "Message Sequence Chart Generator")
504 (description "Mscgen is a small program that parses Message Sequence Chart
505 descriptions and produces PNG, SVG, EPS or server side image maps (ismaps) as
506 the output. Message Sequence Charts (MSCs) are a way of representing entities
507 and interactions over some time period and are often used in combination with
508 SDL. MSCs are popular in Telecoms to specify how protocols operate although
509 MSCs need not be complicated to create or use. Mscgen aims to provide a simple
510 text language that is clear to create, edit and understand, which can also be
511 transformed into common image formats for display or printing.")
512 (license license:gpl2+)))