gnu: calibre: Wrap QTWEBENGINEPROCESS_PATH.
[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 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 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
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.
16 ;;;
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.
21 ;;;
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/>.
24
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))
56
57 (define-public igraph
58 (package
59 (name "igraph")
60 (version "0.8.2")
61 (source
62 (origin
63 (method url-fetch)
64 (uri (string-append "https://github.com/igraph/igraph/releases/"
65 "download/" version "/igraph-" version ".tar.gz"))
66 (sha256
67 (base32 "158flvl80qh1l1ikfa04p1dzh8kapsvm6q80x3ih5gwcgcg4g2ki"))))
68 (build-system gnu-build-system)
69 (arguments
70 `(#:configure-flags
71 (list "--with-external-glpk"
72 "--with-external-blas"
73 "--with-external-lapack")))
74 (inputs
75 `(("gmp" ,gmp)
76 ("glpk" ,glpk)
77 ("libxml2" ,libxml2)
78 ("lapack" ,lapack)
79 ("openblas" ,openblas)
80 ("zlib" ,zlib)))
81 (home-page "https://igraph.org")
82 (synopsis "Network analysis and visualization")
83 (description
84 "This package provides a library for the analysis of networks and graphs.
85 It can handle large graphs very well and provides functions for generating
86 random and regular graphs, graph visualization, centrality methods and much
87 more.")
88 (license license:gpl2+)))
89
90 (define-public python-igraph
91 (package (inherit igraph)
92 (name "python-igraph")
93 (version "0.8.2")
94 (source
95 (origin
96 (method url-fetch)
97 (uri (pypi-uri "python-igraph" version))
98 (sha256
99 (base32 "0wkxrs28qdvnrz7d4jzcf2bh6v2yqzx3wyfziihfgsi2gn6n60a6"))))
100 (build-system python-build-system)
101 (arguments
102 '(#:configure-flags
103 (list "--use-pkg-config")
104 #:phases
105 (modify-phases %standard-phases
106 (replace 'build
107 (lambda _
108 (invoke "python" "./setup.py" "build" "--use-pkg-config")))
109 (delete 'check)
110 (add-after 'install 'check
111 (lambda* (#:key inputs outputs #:allow-other-keys)
112 (add-installed-pythonpath inputs outputs)
113 (invoke "pytest" "-v"))))))
114 (inputs
115 `(("igraph" ,igraph)))
116 (propagated-inputs
117 `(("python-texttable" ,python-texttable)))
118 (native-inputs
119 `(("pkg-config" ,pkg-config)
120 ("python-pytest" ,python-pytest)))
121 (home-page "https://pypi.org/project/python-igraph/")
122 (synopsis "Python bindings for the igraph network analysis library")))
123
124 (define-public r-igraph
125 (package
126 (name "r-igraph")
127 (version "1.2.5")
128 (source
129 (origin
130 (method url-fetch)
131 (uri (cran-uri "igraph" version))
132 (sha256
133 (base32
134 "126z1ygbmi3g7hk97snf22rnx680dyi30idssm5zacba5rdngp8c"))))
135 (build-system r-build-system)
136 (native-inputs
137 `(("gfortran" ,gfortran)))
138 (inputs
139 `(("gmp" ,gmp)
140 ("glpk" ,glpk)
141 ("libxml2" ,libxml2)
142 ("zlib" ,zlib)))
143 (propagated-inputs
144 `(("r-magrittr" ,r-magrittr)
145 ("r-matrix" ,r-matrix)
146 ("r-pkgconfig" ,r-pkgconfig)))
147 (home-page "https://igraph.org")
148 (synopsis "Network analysis and visualization")
149 (description
150 "This package provides routines for simple graphs and network analysis.
151 It can handle large graphs very well and provides functions for generating
152 random and regular graphs, graph visualization, centrality methods and much
153 more.")
154 (license license:gpl2+)))
155
156 (define-public r-diffusionmap
157 (package
158 (name "r-diffusionmap")
159 (version "1.2.0")
160 (source
161 (origin
162 (method url-fetch)
163 (uri (cran-uri "diffusionMap" version))
164 (sha256
165 (base32
166 "1rvk7069brlm1s9kqj4c31mwwr3mw4hmhay95cjjjfmw5xclff2j"))))
167 (properties `((upstream-name . "diffusionMap")))
168 (build-system r-build-system)
169 (propagated-inputs
170 `(("r-igraph" ,r-igraph)
171 ("r-matrix" ,r-matrix)
172 ("r-scatterplot3d" ,r-scatterplot3d)))
173 (home-page "https://www.r-project.org")
174 (synopsis "Diffusion map")
175 (description "This package implements the diffusion map method of data
176 parametrization, including creation and visualization of diffusion maps,
177 clustering with diffusion K-means and regression using the adaptive regression
178 model.")
179 (license license:gpl2)))
180
181 (define-public r-rgraphviz
182 (package
183 (name "r-rgraphviz")
184 (version "2.32.0")
185 (source
186 (origin
187 (method url-fetch)
188 (uri (bioconductor-uri "Rgraphviz" version))
189 (sha256
190 (base32
191 "1calpvzgcz6v7s4x6bf35kj83sga95zjp7x87p5d3qnbv7q2wz5y"))))
192 (properties `((upstream-name . "Rgraphviz")))
193 (build-system r-build-system)
194 ;; FIXME: Rgraphviz bundles the sources of an older variant of
195 ;; graphviz. It does not build with the latest version of graphviz, so
196 ;; we do not add graphviz to the inputs.
197 (inputs `(("zlib" ,zlib)))
198 (propagated-inputs
199 `(("r-graph" ,r-graph)))
200 (native-inputs
201 `(("pkg-config" ,pkg-config)))
202 (home-page "https://bioconductor.org/packages/Rgraphviz")
203 (synopsis "Plotting capabilities for R graph objects")
204 (description
205 "This package interfaces R with the graphviz library for plotting R graph
206 objects from the @code{graph} package.")
207 (license license:epl1.0)))
208
209 (define-public r-rbiofabric
210 (let ((commit "666c2ae8b0a537c006592d067fac6285f71890ac")
211 (revision "1"))
212 (package
213 (name "r-rbiofabric")
214 (version (string-append "0.3-" revision "." (string-take commit 7)))
215 (source (origin
216 (method git-fetch)
217 (uri (git-reference
218 (url "https://github.com/wjrl/RBioFabric")
219 (commit commit)))
220 (file-name (string-append name "-" version "-checkout"))
221 (sha256
222 (base32
223 "1yahqrcrqpbcywv73y9rlmyz8apdnp08afialibrr93ch0p06f8z"))))
224 (build-system r-build-system)
225 (propagated-inputs
226 `(("r-igraph" ,r-igraph)))
227 (home-page "http://www.biofabric.org/")
228 (synopsis "BioFabric network visualization")
229 (description "This package provides an implementation of the function
230 @code{bioFabric} for creating scalable network digrams where nodes are
231 represented by horizontal lines, and edges are represented by vertical
232 lines.")
233 (license license:expat))))
234
235 (define-public python-plotly
236 (package
237 (name "python-plotly")
238 (version "4.8.1")
239 (source (origin
240 (method git-fetch)
241 (uri (git-reference
242 (url "https://github.com/plotly/plotly.py")
243 (commit (string-append "v" version))))
244 (file-name (git-file-name name version))
245 (sha256
246 (base32
247 "08ab677gr85m10zhixr6dnmlfws8q6sra7nhyb8nf3r8dx1ffqhz"))))
248 (build-system python-build-system)
249 (arguments
250 `(#:phases
251 (modify-phases %standard-phases
252 (add-after 'unpack 'chdir
253 (lambda _
254 (chdir "packages/python/plotly")
255 #t))
256 (replace 'check
257 (lambda _
258 (invoke "pytest" "-x" "plotly/tests/test_core")
259 (invoke "pytest" "-x" "plotly/tests/test_io")
260 ;; FIXME: Add optional dependencies and enable their tests.
261 ;; (invoke "pytest" "-x" "plotly/tests/test_optional")
262 (invoke "pytest" "_plotly_utils/tests")))
263 (add-before 'reset-gzip-timestamps 'make-files-writable
264 (lambda* (#:key outputs #:allow-other-keys)
265 (let ((out (assoc-ref outputs "out")))
266 (for-each (lambda (file) (chmod file #o644))
267 (find-files out "\\.gz"))
268 #t))))))
269 (native-inputs
270 `(("python-pytest" ,python-pytest)))
271 (propagated-inputs
272 `(("python-decorator" ,python-decorator)
273 ("python-ipywidgets" ,python-ipywidgets)
274 ("python-pandas" ,python-pandas)
275 ("python-requests" ,python-requests)
276 ("python-retrying" ,python-retrying)
277 ("python-six" ,python-six)
278 ("python-statsmodels" ,python-statsmodels)
279 ("python-xarray" ,python-xarray)))
280 (home-page "https://plotly.com/python/")
281 (synopsis "Interactive plotting library for Python")
282 (description "Plotly's Python graphing library makes interactive,
283 publication-quality graphs online. Examples of how to make line plots, scatter
284 plots, area charts, bar charts, error bars, box plots, histograms, heatmaps,
285 subplots, multiple-axes, polar charts, and bubble charts. ")
286 (license license:expat)))
287
288 (define-public python-plotly-2.4.1
289 (package (inherit python-plotly)
290 (version "2.4.1")
291 (source
292 (origin
293 (method url-fetch)
294 (uri (pypi-uri "plotly" version))
295 (sha256
296 (base32
297 "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
298 (native-inputs '())
299 (propagated-inputs
300 `(("python-decorator" ,python-decorator)
301 ("python-nbformat" ,python-nbformat)
302 ("python-pandas" ,python-pandas)
303 ("python-pytz" ,python-pytz)
304 ("python-requests" ,python-requests)
305 ("python-six" ,python-six)))
306 (arguments
307 '(#:tests? #f)))) ; The tests are not distributed in the release
308
309 (define-public python2-plotly
310 (package-with-python2 python-plotly-2.4.1))
311
312 (define-public python-louvain
313 (package
314 (name "python-louvain")
315 (version "0.6.1")
316 ;; The tarball on Pypi does not include the tests.
317 (source (origin
318 (method git-fetch)
319 (uri (git-reference
320 (url "https://github.com/vtraag/louvain-igraph")
321 (commit version)))
322 (file-name (git-file-name name version))
323 (sha256
324 (base32
325 "0w31537sifkf65sck1iaip5i6d8g64pa3wdwad83d6p9jwkck57k"))))
326 (build-system python-build-system)
327 (propagated-inputs
328 `(("python-ddt" ,python-ddt)
329 ("python-igraph" ,python-igraph)))
330 (inputs
331 `(("igraph" ,igraph)))
332 (native-inputs
333 `(("pkg-config" ,pkg-config)
334 ("python-pytest" ,python-pytest)))
335 (home-page "https://github.com/vtraag/louvain-igraph")
336 (synopsis "Algorithm for methods of community detection in large networks")
337 (description
338 "This package provides an implementation of the Louvain algorithm for use
339 with igraph. Louvain is a general algorithm for methods of community
340 detection in large networks.
341
342 This package has been superseded by the @code{leidenalg} package and should
343 not be used for new projects.")
344 (license license:gpl3+)))
345
346 (define-public faiss
347 (package
348 (name "faiss")
349 (version "1.5.0")
350 (source (origin
351 (method git-fetch)
352 (uri (git-reference
353 (url "https://github.com/facebookresearch/faiss")
354 (commit (string-append "v" version))))
355 (file-name (git-file-name name version))
356 (sha256
357 (base32
358 "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
359 (modules '((guix build utils)))
360 (snippet
361 '(begin
362 (substitute* "utils.cpp"
363 (("#include <immintrin.h>")
364 "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
365 #t))))
366 (build-system cmake-build-system)
367 (arguments
368 `(#:configure-flags
369 (list "-DBUILD_WITH_GPU=OFF" ; thanks, but no thanks, CUDA.
370 "-DBUILD_TUTORIAL=OFF") ; we don't need those
371 #:phases
372 (modify-phases %standard-phases
373 (add-after 'unpack 'prepare-build
374 (lambda _
375 (let ((features (list ,@(let ((system (or (%current-target-system)
376 (%current-system))))
377 (cond
378 ((string-prefix? "x86_64" system)
379 '("-mavx" "-msse2" "-mpopcnt"))
380 ((string-prefix? "i686" system)
381 '("-msse2" "-mpopcnt"))
382 (else
383 '()))))))
384 (substitute* "CMakeLists.txt"
385 (("-m64") "")
386 (("-mpopcnt") "") ; only some architectures
387 (("-msse4")
388 (string-append
389 (string-join features)
390 " -I" (getcwd)))
391 ;; Build also the shared library
392 (("ARCHIVE DESTINATION lib")
393 "LIBRARY DESTINATION lib")
394 (("add_library.*" m)
395 "\
396 add_library(objlib OBJECT ${faiss_cpu_headers} ${faiss_cpu_cpp})
397 set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
398 add_library(${faiss_lib}_static STATIC $<TARGET_OBJECTS:objlib>)
399 add_library(${faiss_lib} SHARED $<TARGET_OBJECTS:objlib>)
400 install(TARGETS ${faiss_lib}_static ARCHIVE DESTINATION lib)
401 \n")))
402
403 ;; See https://github.com/facebookresearch/faiss/issues/520
404 (substitute* "IndexScalarQuantizer.cpp"
405 (("#define USE_AVX") ""))
406
407 ;; Make header files available for compiling tests.
408 (mkdir-p "faiss")
409 (for-each (lambda (file)
410 (mkdir-p (string-append "faiss/" (dirname file)))
411 (copy-file file (string-append "faiss/" file)))
412 (find-files "." "\\.h$"))
413 #t))
414 (replace 'check
415 (lambda _
416 (invoke "make" "-C" "tests"
417 (format #f "-j~a" (parallel-job-count)))))
418 (add-after 'install 'remove-tests
419 (lambda* (#:key outputs #:allow-other-keys)
420 (delete-file-recursively
421 (string-append (assoc-ref outputs "out")
422 "/test"))
423 #t)))))
424 (inputs
425 `(("openblas" ,openblas)))
426 (native-inputs
427 `(("googletest" ,googletest)))
428 (home-page "https://github.com/facebookresearch/faiss")
429 (synopsis "Efficient similarity search and clustering of dense vectors")
430 (description "Faiss is a library for efficient similarity search and
431 clustering of dense vectors. It contains algorithms that search in sets of
432 vectors of any size, up to ones that possibly do not fit in RAM. It also
433 contains supporting code for evaluation and parameter tuning.")
434 (license license:bsd-3)))
435
436 (define-public python-faiss
437 (package (inherit faiss)
438 (name "python-faiss")
439 (build-system python-build-system)
440 (arguments
441 `(#:phases
442 (modify-phases %standard-phases
443 (add-after 'unpack 'chdir
444 (lambda _ (chdir "python") #t))
445 (add-after 'chdir 'build-swig
446 (lambda* (#:key inputs #:allow-other-keys)
447 (with-output-to-file "../makefile.inc"
448 (lambda ()
449 (let ((python-version ,(version-major+minor (package-version python))))
450 (format #t "\
451 PYTHONCFLAGS =-I~a/include/python~am/ -I~a/lib/python~a/site-packages/numpy/core/include
452 LIBS = -lpython~am -lfaiss
453 SHAREDFLAGS = -shared -fopenmp
454 CXXFLAGS = -fpermissive -fopenmp -fPIC
455 CPUFLAGS = ~{~a ~}~%"
456 (assoc-ref inputs "python*") python-version
457 (assoc-ref inputs "python-numpy") python-version
458 python-version
459 (list ,@(let ((system (or (%current-target-system)
460 (%current-system))))
461 (cond
462 ((string-prefix? "x86_64" system)
463 '("-mavx" "-msse2" "-mpopcnt"))
464 ((string-prefix? "i686" system)
465 '("-msse2" "-mpopcnt"))
466 (else
467 '()))))))))
468 (substitute* "Makefile"
469 (("../libfaiss.a") ""))
470 (invoke "make" "cpu"))))))
471 (inputs
472 `(("faiss" ,faiss)
473 ("openblas" ,openblas)
474 ("python*" ,python)
475 ("swig" ,swig)))
476 (propagated-inputs
477 `(("python-matplotlib" ,python-matplotlib)
478 ("python-numpy" ,python-numpy)))
479 (description "Faiss is a library for efficient similarity search and
480 clustering of dense vectors. This package provides Python bindings to the
481 Faiss library.")))
482
483 (define-public python-leidenalg
484 (package
485 (name "python-leidenalg")
486 (version "0.7.0")
487 (source
488 (origin
489 (method url-fetch)
490 (uri (pypi-uri "leidenalg" version))
491 (sha256
492 (base32
493 "15fwld9hdw357rd026mzcwpah5liy4f33vc9x9kwy37g71b2rjf1"))))
494 (build-system python-build-system)
495 (arguments '(#:tests? #f)) ; tests are not included
496 (native-inputs
497 `(("pkg-config" ,pkg-config)))
498 (inputs
499 `(("igraph" ,igraph)))
500 (propagated-inputs
501 `(("python-igraph" ,python-igraph)))
502 (home-page "https://github.com/vtraag/leidenalg")
503 (synopsis "Community detection in large networks")
504 (description
505 "Leiden is a general algorithm for methods of community detection in
506 large networks. This package implements the Leiden algorithm in C++ and
507 exposes it to Python. Besides the relative flexibility of the implementation,
508 it also scales well, and can be run on graphs of millions of nodes (as long as
509 they can fit in memory). The core function is @code{find_partition} which
510 finds the optimal partition using the Leiden algorithm, which is an extension
511 of the Louvain algorithm, for a number of different methods.")
512 (license license:gpl3+)))
513
514 (define-public edge-addition-planarity-suite
515 (package
516 (name "edge-addition-planarity-suite")
517 (version "3.0.0.5")
518 (source
519 (origin
520 (method git-fetch)
521 (uri (git-reference
522 (url (string-append "https://github.com/graph-algorithms/"
523 name))
524 (commit (string-append "Version_" version))))
525 (file-name (git-file-name name version))
526 (sha256
527 (base32
528 "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8"))))
529 (build-system gnu-build-system)
530 (native-inputs
531 `(("autoconf" ,autoconf)
532 ("automake" ,automake)
533 ("libtool" ,libtool)))
534 (synopsis "Embedding of planar graphs")
535 (description "The package provides a reference implementation of the
536 linear time edge addition algorithm for embedding planar graphs and
537 isolating planarity obstructions.")
538 (license license:bsd-3)
539 (home-page
540 "https://github.com/graph-algorithms/edge-addition-planarity-suite")))
541
542 (define-public rw
543 (package
544 (name "rw")
545 ;; There is a version 0.8, but the tarball is broken with symlinks
546 ;; to /usr/share.
547 (version "0.7")
548 (source (origin
549 (method url-fetch)
550 (uri (string-append "mirror://sourceforge/rankwidth/"
551 "rw-" version ".tar.gz"))
552 (sha256
553 (base32
554 "1rv2v42x2506x7f10349m1wpmmfxrv9l032bkminni2gbip9cjg0"))))
555 (build-system gnu-build-system)
556 (native-inputs
557 `(("pkg-config" ,pkg-config)))
558 (inputs
559 `(("igraph" ,igraph)))
560 (home-page "https://sourceforge.net/projects/rankwidth/")
561 (synopsis "Rank-width and rank-decomposition of graphs")
562 (description "rw computes rank-width and rank-decompositions
563 of graphs.")
564 (license license:gpl2+)))
565
566 (define-public mscgen
567 (package
568 (name "mscgen")
569 (version "0.20")
570 (source
571 (origin
572 (method url-fetch)
573 (uri (string-append "http://www.mcternan.me.uk/mscgen/software/mscgen-src-"
574 version ".tar.gz"))
575 (sha256
576 (base32
577 "08yw3maxhn5fl1lff81gmcrpa4j9aas4mmby1g9w5qcr0np82d1w"))))
578 (build-system gnu-build-system)
579 (native-inputs
580 `(("pkg-config" ,pkg-config)))
581 (inputs
582 `(("gd" ,gd)))
583 (home-page "http://www.mcternan.me.uk/mscgen/")
584 (synopsis "Message Sequence Chart Generator")
585 (description "Mscgen is a small program that parses Message Sequence Chart
586 descriptions and produces PNG, SVG, EPS or server side image maps (ismaps) as
587 the output. Message Sequence Charts (MSCs) are a way of representing entities
588 and interactions over some time period and are often used in combination with
589 SDL. MSCs are popular in Telecoms to specify how protocols operate although
590 MSCs need not be complicated to create or use. Mscgen aims to provide a simple
591 text language that is clear to create, edit and understand, which can also be
592 transformed into common image formats for display or printing.")
593 (license license:gpl2+)))