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