gnu: python-plotly: Allow test phase to be skipped.
[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 ;;;
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.4")
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 "127q6q40kbmvd62yhbz6dlfk370qiq98s1iscyagpgbpjwb4xvyf"))))
68 (build-system gnu-build-system)
69 (arguments
70 `(#:configure-flags
71 (list "--disable-static"
72 "--with-external-glpk"
73 "--with-external-blas"
74 "--with-external-lapack")))
75 (inputs
76 `(("gmp" ,gmp)
77 ("glpk" ,glpk)
78 ("libxml2" ,libxml2)
79 ("lapack" ,lapack)
80 ("openblas" ,openblas)
81 ("zlib" ,zlib)))
82 (home-page "https://igraph.org")
83 (synopsis "Network analysis and visualization")
84 (description
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
88 more.")
89 (license license:gpl2+)))
90
91 (define-public python-igraph
92 (package (inherit igraph)
93 (name "python-igraph")
94 (version "0.8.2")
95 (source
96 (origin
97 (method url-fetch)
98 (uri (pypi-uri "python-igraph" version))
99 (sha256
100 (base32 "0wkxrs28qdvnrz7d4jzcf2bh6v2yqzx3wyfziihfgsi2gn6n60a6"))))
101 (build-system python-build-system)
102 (arguments
103 '(#:configure-flags
104 (list "--use-pkg-config")
105 #:phases
106 (modify-phases %standard-phases
107 (replace 'build
108 (lambda _
109 (invoke "python" "./setup.py" "build" "--use-pkg-config")))
110 (delete 'check)
111 (add-after 'install 'check
112 (lambda* (#:key inputs outputs #:allow-other-keys)
113 (add-installed-pythonpath inputs outputs)
114 (invoke "pytest" "-v"))))))
115 (inputs
116 `(("igraph" ,igraph)))
117 (propagated-inputs
118 `(("python-texttable" ,python-texttable)))
119 (native-inputs
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")))
124
125 (define-public r-rbiofabric
126 (let ((commit "666c2ae8b0a537c006592d067fac6285f71890ac")
127 (revision "1"))
128 (package
129 (name "r-rbiofabric")
130 (version (string-append "0.3-" revision "." (string-take commit 7)))
131 (source (origin
132 (method git-fetch)
133 (uri (git-reference
134 (url "https://github.com/wjrl/RBioFabric")
135 (commit commit)))
136 (file-name (string-append name "-" version "-checkout"))
137 (sha256
138 (base32
139 "1yahqrcrqpbcywv73y9rlmyz8apdnp08afialibrr93ch0p06f8z"))))
140 (build-system r-build-system)
141 (propagated-inputs
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
148 lines.")
149 (license license:expat))))
150
151 (define-public python-plotly
152 (package
153 (name "python-plotly")
154 (version "4.14.3")
155 (source (origin
156 (method git-fetch)
157 (uri (git-reference
158 (url "https://github.com/plotly/plotly.py")
159 (commit (string-append "v" version))))
160 (file-name (git-file-name name version))
161 (sha256
162 (base32
163 "02wlgy7gf3v5ckiq9ab3prm53cckxkavlghqgkk9xw2sfmmrn61q"))))
164 (build-system python-build-system)
165 (arguments
166 `(#:phases
167 (modify-phases %standard-phases
168 (add-after 'unpack 'chdir
169 (lambda _
170 (chdir "packages/python/plotly")
171 #t))
172 (replace 'check
173 (lambda* (#:key tests? #:allow-other-keys)
174 (when tests?
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"))
180 #t))
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"))
186 #t))))))
187 (native-inputs
188 `(("python-ipywidgets" ,python-ipywidgets)
189 ("python-pytest" ,python-pytest)
190 ("python-xarray" ,python-xarray)))
191 (propagated-inputs
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)))
206
207 (define-public python-plotly-2.4.1
208 (package (inherit python-plotly)
209 (version "2.4.1")
210 (source
211 (origin
212 (method url-fetch)
213 (uri (pypi-uri "plotly" version))
214 (sha256
215 (base32
216 "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
217 (native-inputs '())
218 (propagated-inputs
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)))
225 (arguments
226 '(#:tests? #f)))) ; The tests are not distributed in the release
227
228 (define-public python2-plotly
229 (package-with-python2 python-plotly-2.4.1))
230
231 (define-public python-louvain
232 (package
233 (name "python-louvain")
234 (version "0.6.1")
235 ;; The tarball on Pypi does not include the tests.
236 (source (origin
237 (method git-fetch)
238 (uri (git-reference
239 (url "https://github.com/vtraag/louvain-igraph")
240 (commit version)))
241 (file-name (git-file-name name version))
242 (sha256
243 (base32
244 "0w31537sifkf65sck1iaip5i6d8g64pa3wdwad83d6p9jwkck57k"))))
245 (build-system python-build-system)
246 (propagated-inputs
247 `(("python-ddt" ,python-ddt)
248 ("python-igraph" ,python-igraph)))
249 (inputs
250 `(("igraph" ,igraph)))
251 (native-inputs
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")
256 (description
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.
260
261 This package has been superseded by the @code{leidenalg} package and should
262 not be used for new projects.")
263 (license license:gpl3+)))
264
265 (define-public faiss
266 (package
267 (name "faiss")
268 (version "1.5.0")
269 (source (origin
270 (method git-fetch)
271 (uri (git-reference
272 (url "https://github.com/facebookresearch/faiss")
273 (commit (string-append "v" version))))
274 (file-name (git-file-name name version))
275 (sha256
276 (base32
277 "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
278 (modules '((guix build utils)))
279 (snippet
280 '(begin
281 (substitute* "utils.cpp"
282 (("#include <immintrin.h>")
283 "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
284 #t))))
285 (build-system cmake-build-system)
286 (arguments
287 `(#:configure-flags
288 (list "-DBUILD_WITH_GPU=OFF" ; thanks, but no thanks, CUDA.
289 "-DBUILD_TUTORIAL=OFF") ; we don't need those
290 #:phases
291 (modify-phases %standard-phases
292 (add-after 'unpack 'prepare-build
293 (lambda _
294 (let ((features (list ,@(let ((system (or (%current-target-system)
295 (%current-system))))
296 (cond
297 ((string-prefix? "x86_64" system)
298 '("-mavx" "-msse2" "-mpopcnt"))
299 ((string-prefix? "i686" system)
300 '("-msse2" "-mpopcnt"))
301 (else
302 '()))))))
303 (substitute* "CMakeLists.txt"
304 (("-m64") "")
305 (("-mpopcnt") "") ; only some architectures
306 (("-msse4")
307 (string-append
308 (string-join features)
309 " -I" (getcwd)))
310 ;; Build also the shared library
311 (("ARCHIVE DESTINATION lib")
312 "LIBRARY DESTINATION lib")
313 (("add_library.*" m)
314 "\
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)
320 \n")))
321
322 ;; See https://github.com/facebookresearch/faiss/issues/520
323 (substitute* "IndexScalarQuantizer.cpp"
324 (("#define USE_AVX") ""))
325
326 ;; Make header files available for compiling tests.
327 (mkdir-p "faiss")
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$"))
332 #t))
333 (replace 'check
334 (lambda _
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")
341 "/test"))
342 #t)))))
343 (inputs
344 `(("openblas" ,openblas)))
345 (native-inputs
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)))
354
355 (define-public python-faiss
356 (package (inherit faiss)
357 (name "python-faiss")
358 (build-system python-build-system)
359 (arguments
360 `(#:phases
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"
367 (lambda ()
368 (let ((python-version ,(version-major+minor (package-version python))))
369 (format #t "\
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
377 python-version
378 (list ,@(let ((system (or (%current-target-system)
379 (%current-system))))
380 (cond
381 ((string-prefix? "x86_64" system)
382 '("-mavx" "-msse2" "-mpopcnt"))
383 ((string-prefix? "i686" system)
384 '("-msse2" "-mpopcnt"))
385 (else
386 '()))))))))
387 (substitute* "Makefile"
388 (("../libfaiss.a") ""))
389 (invoke "make" "cpu"))))))
390 (inputs
391 `(("faiss" ,faiss)
392 ("openblas" ,openblas)
393 ("python*" ,python)
394 ("swig" ,swig)))
395 (propagated-inputs
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
400 Faiss library.")))
401
402 (define-public python-leidenalg
403 (package
404 (name "python-leidenalg")
405 (version "0.7.0")
406 (source
407 (origin
408 (method url-fetch)
409 (uri (pypi-uri "leidenalg" version))
410 (sha256
411 (base32
412 "15fwld9hdw357rd026mzcwpah5liy4f33vc9x9kwy37g71b2rjf1"))))
413 (build-system python-build-system)
414 (arguments '(#:tests? #f)) ; tests are not included
415 (native-inputs
416 `(("pkg-config" ,pkg-config)))
417 (inputs
418 `(("igraph" ,igraph)))
419 (propagated-inputs
420 `(("python-igraph" ,python-igraph)))
421 (home-page "https://github.com/vtraag/leidenalg")
422 (synopsis "Community detection in large networks")
423 (description
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+)))
432
433 (define-public edge-addition-planarity-suite
434 (package
435 (name "edge-addition-planarity-suite")
436 (version "3.0.0.5")
437 (source
438 (origin
439 (method git-fetch)
440 (uri (git-reference
441 (url (string-append "https://github.com/graph-algorithms/"
442 name))
443 (commit (string-append "Version_" version))))
444 (file-name (git-file-name name version))
445 (sha256
446 (base32
447 "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8"))))
448 (build-system gnu-build-system)
449 (native-inputs
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)
458 (home-page
459 "https://github.com/graph-algorithms/edge-addition-planarity-suite")))
460
461 (define-public rw
462 (package
463 (name "rw")
464 ;; There is a version 0.8, but the tarball is broken with symlinks
465 ;; to /usr/share.
466 (version "0.7")
467 (source (origin
468 (method url-fetch)
469 (uri (string-append "mirror://sourceforge/rankwidth/"
470 "rw-" version ".tar.gz"))
471 (sha256
472 (base32
473 "1rv2v42x2506x7f10349m1wpmmfxrv9l032bkminni2gbip9cjg0"))))
474 (build-system gnu-build-system)
475 (native-inputs
476 `(("pkg-config" ,pkg-config)))
477 (inputs
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
482 of graphs.")
483 (license license:gpl2+)))
484
485 (define-public mscgen
486 (package
487 (name "mscgen")
488 (version "0.20")
489 (source
490 (origin
491 (method url-fetch)
492 (uri (string-append "http://www.mcternan.me.uk/mscgen/software/mscgen-src-"
493 version ".tar.gz"))
494 (sha256
495 (base32
496 "08yw3maxhn5fl1lff81gmcrpa4j9aas4mmby1g9w5qcr0np82d1w"))))
497 (build-system gnu-build-system)
498 (native-inputs
499 `(("pkg-config" ,pkg-config)))
500 (inputs
501 `(("gd" ,gd)))
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+)))