gnu: icecat: Update to 78.10.0-guix0-preview1 [security fixes].
[jackhill/guix/guix.git] / gnu / packages / graph.scm
CommitLineData
e57fffad 1;;; GNU Guix --- Functional package management for GNU
06b13f51 2;;; Copyright © 2017, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
5f3616d6 3;;; Copyright © 2018 Joshua Sierles, Nextjournal <joshua@nextjournal.com>
8c9dcdea 4;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
3e5d8113 5;;; Copyright © 2019, 2021 Efraim Flashner <efraim@flashner.co.il>
f455d99d 6;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
56973172 7;;; Copyright © 2020 Alexander Krotov <krotov@iitp.ru>
6e31d6f3 8;;; Copyright © 2020 Pierre Langlois <pierre.langlos@gmx.com>
e57fffad
RW
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)
4e35c429 27 #:use-module (guix git-download)
e57fffad 28 #:use-module (guix packages)
51a9971c 29 #:use-module (guix utils)
3e403187 30 #:use-module (guix build-system cmake)
e57fffad 31 #:use-module (guix build-system gnu)
31476df3 32 #:use-module (guix build-system python)
1738138c 33 #:use-module (guix build-system r)
e57fffad
RW
34 #:use-module ((guix licenses) #:prefix license:)
35 #:use-module (gnu packages)
1738138c 36 #:use-module (gnu packages gcc)
f455d99d 37 #:use-module (gnu packages autotools)
d53aeeaf 38 #:use-module (gnu packages bioconductor)
e206de67 39 #:use-module (gnu packages bioinformatics)
3e403187 40 #:use-module (gnu packages check)
e57fffad 41 #:use-module (gnu packages compression)
fff9b884 42 #:use-module (gnu packages cran)
56973172 43 #:use-module (gnu packages gd)
e206de67 44 #:use-module (gnu packages graphviz)
e57fffad
RW
45 #:use-module (gnu packages maths)
46 #:use-module (gnu packages multiprecision)
31476df3 47 #:use-module (gnu packages pkg-config)
5f3616d6 48 #:use-module (gnu packages python)
312ec128 49 #:use-module (gnu packages python-science)
5f3616d6 50 #:use-module (gnu packages python-web)
44d10b1f 51 #:use-module (gnu packages python-xyz)
1738138c 52 #:use-module (gnu packages statistics)
51a9971c 53 #:use-module (gnu packages swig)
5f3616d6 54 #:use-module (gnu packages time)
e57fffad
RW
55 #:use-module (gnu packages xml))
56
57(define-public igraph
58 (package
59 (name "igraph")
13e55e6e 60 (version "0.8.4")
e57fffad
RW
61 (source
62 (origin
63 (method url-fetch)
06b13f51
RW
64 (uri (string-append "https://github.com/igraph/igraph/releases/"
65 "download/" version "/igraph-" version ".tar.gz"))
e57fffad 66 (sha256
13e55e6e 67 (base32 "127q6q40kbmvd62yhbz6dlfk370qiq98s1iscyagpgbpjwb4xvyf"))))
e57fffad
RW
68 (build-system gnu-build-system)
69 (arguments
70 `(#:configure-flags
4491c624
TGR
71 (list "--disable-static"
72 "--with-external-glpk"
e57fffad
RW
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)))
00a34333 82 (home-page "https://igraph.org")
e57fffad
RW
83 (synopsis "Network analysis and visualization")
84 (description
85 "This package provides a library for the analysis of networks and graphs.
86It can handle large graphs very well and provides functions for generating
87random and regular graphs, graph visualization, centrality methods and much
88more.")
89 (license license:gpl2+)))
31476df3
RW
90
91(define-public python-igraph
92 (package (inherit igraph)
93 (name "python-igraph")
fe55ff38 94 (version "0.8.2")
31476df3
RW
95 (source
96 (origin
97 (method url-fetch)
98 (uri (pypi-uri "python-igraph" version))
99 (sha256
fe55ff38 100 (base32 "0wkxrs28qdvnrz7d4jzcf2bh6v2yqzx3wyfziihfgsi2gn6n60a6"))))
31476df3 101 (build-system python-build-system)
7daae3c9
RW
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"))))))
31476df3
RW
115 (inputs
116 `(("igraph" ,igraph)))
7daae3c9
RW
117 (propagated-inputs
118 `(("python-texttable" ,python-texttable)))
31476df3 119 (native-inputs
7daae3c9
RW
120 `(("pkg-config" ,pkg-config)
121 ("python-pytest" ,python-pytest)))
e85af137 122 (home-page "https://pypi.org/project/python-igraph/")
31476df3 123 (synopsis "Python bindings for the igraph network analysis library")))
1738138c 124
4e35c429
RW
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
b0e7b699 134 (url "https://github.com/wjrl/RBioFabric")
4e35c429
RW
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
147represented by horizontal lines, and edges are represented by vertical
148lines.")
149 (license license:expat))))
5f3616d6
LF
150
151(define-public python-plotly
152 (package
153 (name "python-plotly")
3e5d8113 154 (version "4.14.3")
6e31d6f3
PL
155 (source (origin
156 (method git-fetch)
157 (uri (git-reference
b0e7b699 158 (url "https://github.com/plotly/plotly.py")
6e31d6f3
PL
159 (commit (string-append "v" version))))
160 (file-name (git-file-name name version))
161 (sha256
162 (base32
3e5d8113 163 "02wlgy7gf3v5ckiq9ab3prm53cckxkavlghqgkk9xw2sfmmrn61q"))))
5f3616d6
LF
164 (build-system python-build-system)
165 (arguments
6e31d6f3
PL
166 `(#:phases
167 (modify-phases %standard-phases
168 (add-after 'unpack 'chdir
169 (lambda _
170 (chdir "packages/python/plotly")
171 #t))
172 (replace 'check
e9096ef1
EF
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))
6e31d6f3
PL
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
3e5d8113
EF
188 `(("python-ipywidgets" ,python-ipywidgets)
189 ("python-pytest" ,python-pytest)
190 ("python-xarray" ,python-xarray)))
5f3616d6 191 (propagated-inputs
3e5d8113 192 `(("python-ipython" ,python-ipython)
1a28b9ab 193 ("python-pandas" ,python-pandas)
3e5d8113 194 ("python-pillow" ,python-pillow)
5f3616d6 195 ("python-requests" ,python-requests)
6e31d6f3
PL
196 ("python-retrying" ,python-retrying)
197 ("python-six" ,python-six)
3e5d8113 198 ("python-statsmodels" ,python-statsmodels)))
6e31d6f3 199 (home-page "https://plotly.com/python/")
5f3616d6
LF
200 (synopsis "Interactive plotting library for Python")
201 (description "Plotly's Python graphing library makes interactive,
202publication-quality graphs online. Examples of how to make line plots, scatter
203plots, area charts, bar charts, error bars, box plots, histograms, heatmaps,
204subplots, multiple-axes, polar charts, and bubble charts. ")
205 (license license:expat)))
206
6e31d6f3
PL
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
5f3616d6 228(define-public python2-plotly
6e31d6f3 229 (package-with-python2 python-plotly-2.4.1))
3e403187 230
6ee48091
RW
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
b0e7b699 239 (url "https://github.com/vtraag/louvain-igraph")
6ee48091
RW
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
258with igraph. Louvain is a general algorithm for methods of community
259detection in large networks.
260
261This package has been superseded by the @code{leidenalg} package and should
262not be used for new projects.")
263 (license license:gpl3+)))
264
3e403187
RW
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
b0e7b699 272 (url "https://github.com/facebookresearch/faiss")
3e403187
RW
273 (commit (string-append "v" version))))
274 (file-name (git-file-name name version))
275 (sha256
276 (base32
3776dc09
EF
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))))
3e403187
RW
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)
3776dc09 298 '("-mavx" "-msse2" "-mpopcnt"))
3e403187 299 ((string-prefix? "i686" system)
3776dc09 300 '("-msse2" "-mpopcnt"))
3e403187
RW
301 (else
302 '()))))))
303 (substitute* "CMakeLists.txt"
3776dc09
EF
304 (("-m64") "")
305 (("-mpopcnt") "") ; only some architectures
3e403187
RW
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 "\
315add_library(objlib OBJECT ${faiss_cpu_headers} ${faiss_cpu_cpp})
316set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
317add_library(${faiss_lib}_static STATIC $<TARGET_OBJECTS:objlib>)
318add_library(${faiss_lib} SHARED $<TARGET_OBJECTS:objlib>)
319install(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
350clustering of dense vectors. It contains algorithms that search in sets of
351vectors of any size, up to ones that possibly do not fit in RAM. It also
352contains supporting code for evaluation and parameter tuning.")
353 (license license:bsd-3)))
51a9971c
RW
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 "\
370PYTHONCFLAGS =-I~a/include/python~am/ -I~a/lib/python~a/site-packages/numpy/core/include
371LIBS = -lpython~am -lfaiss
372SHAREDFLAGS = -shared -fopenmp
0fe041bd 373CXXFLAGS = -fpermissive -fopenmp -fPIC
51a9971c
RW
374CPUFLAGS = ~{~a ~}~%"
375 (assoc-ref inputs "python*") python-version
376 (assoc-ref inputs "python-numpy") python-version
377 python-version
8339ccac
EF
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 '()))))))))
51a9971c
RW
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
399clustering of dense vectors. This package provides Python bindings to the
400Faiss library.")))
e865e0b9
RW
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
425large networks. This package implements the Leiden algorithm in C++ and
426exposes it to Python. Besides the relative flexibility of the implementation,
427it also scales well, and can be run on graphs of millions of nodes (as long as
428they can fit in memory). The core function is @code{find_partition} which
429finds the optimal partition using the Leiden algorithm, which is an extension
430of the Louvain algorithm, for a number of different methods.")
431 (license license:gpl3+)))
f455d99d
AE
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
455linear time edge addition algorithm for embedding planar graphs and
456isolating planarity obstructions.")
457 (license license:bsd-3)
458 (home-page
459 "https://github.com/graph-algorithms/edge-addition-planarity-suite")))
bf473f0c
AE
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
482of graphs.")
483 (license license:gpl2+)))
56973172
AK
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)
cfa66669
MB
498 (native-inputs
499 `(("pkg-config" ,pkg-config)))
56973172
AK
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
505descriptions and produces PNG, SVG, EPS or server side image maps (ismaps) as
506the output. Message Sequence Charts (MSCs) are a way of representing entities
507and interactions over some time period and are often used in combination with
508SDL. MSCs are popular in Telecoms to specify how protocols operate although
509MSCs need not be complicated to create or use. Mscgen aims to provide a simple
510text language that is clear to create, edit and understand, which can also be
511transformed into common image formats for display or printing.")
512 (license license:gpl2+)))