gnu: sbcl-cl-cffi-gtk: Update to 20200417.
[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>
3776dc09 5;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
f455d99d 6;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
56973172 7;;; Copyright © 2020 Alexander Krotov <krotov@iitp.ru>
e57fffad
RW
8;;;
9;;; This file is part of GNU Guix.
10;;;
11;;; GNU Guix is free software; you can redistribute it and/or modify it
12;;; under the terms of the GNU General Public License as published by
13;;; the Free Software Foundation; either version 3 of the License, or (at
14;;; your option) any later version.
15;;;
16;;; GNU Guix is distributed in the hope that it will be useful, but
17;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;;; GNU General Public License for more details.
20;;;
21;;; You should have received a copy of the GNU General Public License
22;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24(define-module (gnu packages graph)
25 #:use-module (guix download)
4e35c429 26 #:use-module (guix git-download)
e57fffad 27 #:use-module (guix packages)
51a9971c 28 #:use-module (guix utils)
3e403187 29 #:use-module (guix build-system cmake)
e57fffad 30 #:use-module (guix build-system gnu)
31476df3 31 #:use-module (guix build-system python)
1738138c 32 #:use-module (guix build-system r)
e57fffad
RW
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (gnu packages)
1738138c 35 #:use-module (gnu packages gcc)
f455d99d 36 #:use-module (gnu packages autotools)
d53aeeaf 37 #:use-module (gnu packages bioconductor)
e206de67 38 #:use-module (gnu packages bioinformatics)
3e403187 39 #:use-module (gnu packages check)
e57fffad 40 #:use-module (gnu packages compression)
fff9b884 41 #:use-module (gnu packages cran)
56973172 42 #:use-module (gnu packages gd)
e206de67 43 #:use-module (gnu packages graphviz)
e57fffad
RW
44 #:use-module (gnu packages maths)
45 #:use-module (gnu packages multiprecision)
31476df3 46 #:use-module (gnu packages pkg-config)
5f3616d6 47 #:use-module (gnu packages python)
312ec128 48 #:use-module (gnu packages python-science)
5f3616d6 49 #:use-module (gnu packages python-web)
44d10b1f 50 #:use-module (gnu packages python-xyz)
1738138c 51 #:use-module (gnu packages statistics)
51a9971c 52 #:use-module (gnu packages swig)
5f3616d6 53 #:use-module (gnu packages time)
e57fffad
RW
54 #:use-module (gnu packages xml))
55
56(define-public igraph
57 (package
58 (name "igraph")
8c9dcdea 59 (version "0.8.1")
e57fffad
RW
60 (source
61 (origin
62 (method url-fetch)
06b13f51
RW
63 (uri (string-append "https://github.com/igraph/igraph/releases/"
64 "download/" version "/igraph-" version ".tar.gz"))
e57fffad 65 (sha256
8c9dcdea 66 (base32 "0wbvrac3ip3lqmbkckhnxa2swlbc86l1h8mazdlb618kx3winvi6"))))
e57fffad
RW
67 (build-system gnu-build-system)
68 (arguments
69 `(#:configure-flags
70 (list "--with-external-glpk"
71 "--with-external-blas"
72 "--with-external-lapack")))
73 (inputs
74 `(("gmp" ,gmp)
75 ("glpk" ,glpk)
76 ("libxml2" ,libxml2)
77 ("lapack" ,lapack)
78 ("openblas" ,openblas)
79 ("zlib" ,zlib)))
80 (home-page "http://igraph.org")
81 (synopsis "Network analysis and visualization")
82 (description
83 "This package provides a library for the analysis of networks and graphs.
84It can handle large graphs very well and provides functions for generating
85random and regular graphs, graph visualization, centrality methods and much
86more.")
87 (license license:gpl2+)))
31476df3
RW
88
89(define-public python-igraph
90 (package (inherit igraph)
91 (name "python-igraph")
7daae3c9 92 (version "0.8.0")
31476df3
RW
93 (source
94 (origin
95 (method url-fetch)
96 (uri (pypi-uri "python-igraph" version))
97 (sha256
98 (base32
7daae3c9 99 "13mbrlmnbgbzw6y8ws7wj0a3ly3in8j4l1ngi6yxvgvxxi4bprj7"))))
31476df3 100 (build-system python-build-system)
7daae3c9
RW
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"))))))
31476df3
RW
114 (inputs
115 `(("igraph" ,igraph)))
7daae3c9
RW
116 (propagated-inputs
117 `(("python-texttable" ,python-texttable)))
31476df3 118 (native-inputs
7daae3c9
RW
119 `(("pkg-config" ,pkg-config)
120 ("python-pytest" ,python-pytest)))
e85af137 121 (home-page "https://pypi.org/project/python-igraph/")
31476df3 122 (synopsis "Python bindings for the igraph network analysis library")))
1738138c
RW
123
124(define-public r-igraph
125 (package
126 (name "r-igraph")
d8dc2a7c 127 (version "1.2.5")
1738138c
RW
128 (source
129 (origin
130 (method url-fetch)
131 (uri (cran-uri "igraph" version))
132 (sha256
133 (base32
d8dc2a7c 134 "126z1ygbmi3g7hk97snf22rnx680dyi30idssm5zacba5rdngp8c"))))
1738138c
RW
135 (build-system r-build-system)
136 (native-inputs
137 `(("gfortran" ,gfortran)))
138 (inputs
139 `(("gmp" ,gmp)
8cf7b28f
RW
140 ("glpk" ,glpk)
141 ("libxml2" ,libxml2)
142 ("zlib" ,zlib)))
1738138c 143 (propagated-inputs
8cf7b28f 144 `(("r-magrittr" ,r-magrittr)
1738138c
RW
145 ("r-matrix" ,r-matrix)
146 ("r-pkgconfig" ,r-pkgconfig)))
147 (home-page "http://igraph.org")
148 (synopsis "Network analysis and visualization")
149 (description
150 "This package provides routines for simple graphs and network analysis.
151It can handle large graphs very well and provides functions for generating
152random and regular graphs, graph visualization, centrality methods and much
153more.")
154 (license license:gpl2+)))
e206de67 155
fff9b884
RW
156(define-public r-diffusionmap
157 (package
158 (name "r-diffusionmap")
17f3960f 159 (version "1.2.0")
fff9b884
RW
160 (source
161 (origin
162 (method url-fetch)
163 (uri (cran-uri "diffusionMap" version))
164 (sha256
165 (base32
17f3960f 166 "1rvk7069brlm1s9kqj4c31mwwr3mw4hmhay95cjjjfmw5xclff2j"))))
fff9b884
RW
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)))
d062957a 173 (home-page "https://www.r-project.org")
fff9b884
RW
174 (synopsis "Diffusion map")
175 (description "This package implements the diffusion map method of data
176parametrization, including creation and visualization of diffusion maps,
177clustering with diffusion K-means and regression using the adaptive regression
178model.")
179 (license license:gpl2)))
180
e206de67
RW
181(define-public r-rgraphviz
182 (package
183 (name "r-rgraphviz")
dbfce8ff 184 (version "2.30.0")
e206de67
RW
185 (source
186 (origin
187 (method url-fetch)
188 (uri (bioconductor-uri "Rgraphviz" version))
189 (sha256
190 (base32
dbfce8ff 191 "00lrkbgbb4payybckcmazsv8skysgdlglyqbl7yjb37vv3gnfc6c"))))
e206de67
RW
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)))
99db6db7 202 (home-page "https://bioconductor.org/packages/Rgraphviz")
e206de67
RW
203 (synopsis "Plotting capabilities for R graph objects")
204 (description
205 "This package interfaces R with the graphviz library for plotting R graph
206objects from the @code{graph} package.")
207 (license license:epl1.0)))
4e35c429
RW
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.git")
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
231represented by horizontal lines, and edges are represented by vertical
232lines.")
233 (license license:expat))))
5f3616d6
LF
234
235(define-public python-plotly
236 (package
237 (name "python-plotly")
ef803aa5 238 (version "2.4.1")
5f3616d6
LF
239 (source
240 (origin
241 (method url-fetch)
242 (uri (pypi-uri "plotly" version))
243 (sha256
244 (base32
ef803aa5 245 "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
5f3616d6
LF
246 (build-system python-build-system)
247 (arguments
248 '(#:tests? #f)) ; The tests are not distributed in the release
249 (propagated-inputs
250 `(("python-decorator" ,python-decorator)
251 ("python-nbformat" ,python-nbformat)
1a28b9ab 252 ("python-pandas" ,python-pandas)
5f3616d6
LF
253 ("python-pytz" ,python-pytz)
254 ("python-requests" ,python-requests)
255 ("python-six" ,python-six)))
256 (home-page "https://plot.ly/python/")
257 (synopsis "Interactive plotting library for Python")
258 (description "Plotly's Python graphing library makes interactive,
259publication-quality graphs online. Examples of how to make line plots, scatter
260plots, area charts, bar charts, error bars, box plots, histograms, heatmaps,
261subplots, multiple-axes, polar charts, and bubble charts. ")
262 (license license:expat)))
263
264(define-public python2-plotly
265 (package-with-python2 python-plotly))
3e403187 266
6ee48091
RW
267(define-public python-louvain
268 (package
269 (name "python-louvain")
270 (version "0.6.1")
271 ;; The tarball on Pypi does not include the tests.
272 (source (origin
273 (method git-fetch)
274 (uri (git-reference
275 (url "https://github.com/vtraag/louvain-igraph.git")
276 (commit version)))
277 (file-name (git-file-name name version))
278 (sha256
279 (base32
280 "0w31537sifkf65sck1iaip5i6d8g64pa3wdwad83d6p9jwkck57k"))))
281 (build-system python-build-system)
282 (propagated-inputs
283 `(("python-ddt" ,python-ddt)
284 ("python-igraph" ,python-igraph)))
285 (inputs
286 `(("igraph" ,igraph)))
287 (native-inputs
288 `(("pkg-config" ,pkg-config)
289 ("python-pytest" ,python-pytest)))
290 (home-page "https://github.com/vtraag/louvain-igraph")
291 (synopsis "Algorithm for methods of community detection in large networks")
292 (description
293 "This package provides an implementation of the Louvain algorithm for use
294with igraph. Louvain is a general algorithm for methods of community
295detection in large networks.
296
297This package has been superseded by the @code{leidenalg} package and should
298not be used for new projects.")
299 (license license:gpl3+)))
300
3e403187
RW
301(define-public faiss
302 (package
303 (name "faiss")
304 (version "1.5.0")
305 (source (origin
306 (method git-fetch)
307 (uri (git-reference
308 (url "https://github.com/facebookresearch/faiss.git")
309 (commit (string-append "v" version))))
310 (file-name (git-file-name name version))
311 (sha256
312 (base32
3776dc09
EF
313 "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
314 (modules '((guix build utils)))
315 (snippet
316 '(begin
317 (substitute* "utils.cpp"
318 (("#include <immintrin.h>")
319 "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
320 #t))))
3e403187
RW
321 (build-system cmake-build-system)
322 (arguments
323 `(#:configure-flags
324 (list "-DBUILD_WITH_GPU=OFF" ; thanks, but no thanks, CUDA.
325 "-DBUILD_TUTORIAL=OFF") ; we don't need those
326 #:phases
327 (modify-phases %standard-phases
328 (add-after 'unpack 'prepare-build
329 (lambda _
330 (let ((features (list ,@(let ((system (or (%current-target-system)
331 (%current-system))))
332 (cond
333 ((string-prefix? "x86_64" system)
3776dc09 334 '("-mavx" "-msse2" "-mpopcnt"))
3e403187 335 ((string-prefix? "i686" system)
3776dc09 336 '("-msse2" "-mpopcnt"))
3e403187
RW
337 (else
338 '()))))))
339 (substitute* "CMakeLists.txt"
3776dc09
EF
340 (("-m64") "")
341 (("-mpopcnt") "") ; only some architectures
3e403187
RW
342 (("-msse4")
343 (string-append
344 (string-join features)
345 " -I" (getcwd)))
346 ;; Build also the shared library
347 (("ARCHIVE DESTINATION lib")
348 "LIBRARY DESTINATION lib")
349 (("add_library.*" m)
350 "\
351add_library(objlib OBJECT ${faiss_cpu_headers} ${faiss_cpu_cpp})
352set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
353add_library(${faiss_lib}_static STATIC $<TARGET_OBJECTS:objlib>)
354add_library(${faiss_lib} SHARED $<TARGET_OBJECTS:objlib>)
355install(TARGETS ${faiss_lib}_static ARCHIVE DESTINATION lib)
356\n")))
357
358 ;; See https://github.com/facebookresearch/faiss/issues/520
359 (substitute* "IndexScalarQuantizer.cpp"
360 (("#define USE_AVX") ""))
361
362 ;; Make header files available for compiling tests.
363 (mkdir-p "faiss")
364 (for-each (lambda (file)
365 (mkdir-p (string-append "faiss/" (dirname file)))
366 (copy-file file (string-append "faiss/" file)))
367 (find-files "." "\\.h$"))
368 #t))
369 (replace 'check
370 (lambda _
371 (invoke "make" "-C" "tests"
372 (format #f "-j~a" (parallel-job-count)))))
373 (add-after 'install 'remove-tests
374 (lambda* (#:key outputs #:allow-other-keys)
375 (delete-file-recursively
376 (string-append (assoc-ref outputs "out")
377 "/test"))
378 #t)))))
379 (inputs
380 `(("openblas" ,openblas)))
381 (native-inputs
382 `(("googletest" ,googletest)))
383 (home-page "https://github.com/facebookresearch/faiss")
384 (synopsis "Efficient similarity search and clustering of dense vectors")
385 (description "Faiss is a library for efficient similarity search and
386clustering of dense vectors. It contains algorithms that search in sets of
387vectors of any size, up to ones that possibly do not fit in RAM. It also
388contains supporting code for evaluation and parameter tuning.")
389 (license license:bsd-3)))
51a9971c
RW
390
391(define-public python-faiss
392 (package (inherit faiss)
393 (name "python-faiss")
394 (build-system python-build-system)
395 (arguments
396 `(#:phases
397 (modify-phases %standard-phases
398 (add-after 'unpack 'chdir
399 (lambda _ (chdir "python") #t))
400 (add-after 'chdir 'build-swig
401 (lambda* (#:key inputs #:allow-other-keys)
402 (with-output-to-file "../makefile.inc"
403 (lambda ()
404 (let ((python-version ,(version-major+minor (package-version python))))
405 (format #t "\
406PYTHONCFLAGS =-I~a/include/python~am/ -I~a/lib/python~a/site-packages/numpy/core/include
407LIBS = -lpython~am -lfaiss
408SHAREDFLAGS = -shared -fopenmp
0fe041bd 409CXXFLAGS = -fpermissive -fopenmp -fPIC
51a9971c
RW
410CPUFLAGS = ~{~a ~}~%"
411 (assoc-ref inputs "python*") python-version
412 (assoc-ref inputs "python-numpy") python-version
413 python-version
8339ccac
EF
414 (list ,@(let ((system (or (%current-target-system)
415 (%current-system))))
416 (cond
417 ((string-prefix? "x86_64" system)
418 '("-mavx" "-msse2" "-mpopcnt"))
419 ((string-prefix? "i686" system)
420 '("-msse2" "-mpopcnt"))
421 (else
422 '()))))))))
51a9971c
RW
423 (substitute* "Makefile"
424 (("../libfaiss.a") ""))
425 (invoke "make" "cpu"))))))
426 (inputs
427 `(("faiss" ,faiss)
428 ("openblas" ,openblas)
429 ("python*" ,python)
430 ("swig" ,swig)))
431 (propagated-inputs
432 `(("python-matplotlib" ,python-matplotlib)
433 ("python-numpy" ,python-numpy)))
434 (description "Faiss is a library for efficient similarity search and
435clustering of dense vectors. This package provides Python bindings to the
436Faiss library.")))
e865e0b9
RW
437
438(define-public python-leidenalg
439 (package
440 (name "python-leidenalg")
441 (version "0.7.0")
442 (source
443 (origin
444 (method url-fetch)
445 (uri (pypi-uri "leidenalg" version))
446 (sha256
447 (base32
448 "15fwld9hdw357rd026mzcwpah5liy4f33vc9x9kwy37g71b2rjf1"))))
449 (build-system python-build-system)
450 (arguments '(#:tests? #f)) ; tests are not included
451 (native-inputs
452 `(("pkg-config" ,pkg-config)))
453 (inputs
454 `(("igraph" ,igraph)))
455 (propagated-inputs
456 `(("python-igraph" ,python-igraph)))
457 (home-page "https://github.com/vtraag/leidenalg")
458 (synopsis "Community detection in large networks")
459 (description
460 "Leiden is a general algorithm for methods of community detection in
461large networks. This package implements the Leiden algorithm in C++ and
462exposes it to Python. Besides the relative flexibility of the implementation,
463it also scales well, and can be run on graphs of millions of nodes (as long as
464they can fit in memory). The core function is @code{find_partition} which
465finds the optimal partition using the Leiden algorithm, which is an extension
466of the Louvain algorithm, for a number of different methods.")
467 (license license:gpl3+)))
f455d99d
AE
468
469(define-public edge-addition-planarity-suite
470 (package
471 (name "edge-addition-planarity-suite")
472 (version "3.0.0.5")
473 (source
474 (origin
475 (method git-fetch)
476 (uri (git-reference
477 (url (string-append "https://github.com/graph-algorithms/"
478 name))
479 (commit (string-append "Version_" version))))
480 (file-name (git-file-name name version))
481 (sha256
482 (base32
483 "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8"))))
484 (build-system gnu-build-system)
485 (native-inputs
486 `(("autoconf" ,autoconf)
487 ("automake" ,automake)
488 ("libtool" ,libtool)))
489 (synopsis "Embedding of planar graphs")
490 (description "The package provides a reference implementation of the
491linear time edge addition algorithm for embedding planar graphs and
492isolating planarity obstructions.")
493 (license license:bsd-3)
494 (home-page
495 "https://github.com/graph-algorithms/edge-addition-planarity-suite")))
bf473f0c
AE
496
497(define-public rw
498 (package
499 (name "rw")
500 ;; There is a version 0.8, but the tarball is broken with symlinks
501 ;; to /usr/share.
502 (version "0.7")
503 (source (origin
504 (method url-fetch)
505 (uri (string-append "mirror://sourceforge/rankwidth/"
506 "rw-" version ".tar.gz"))
507 (sha256
508 (base32
509 "1rv2v42x2506x7f10349m1wpmmfxrv9l032bkminni2gbip9cjg0"))))
510 (build-system gnu-build-system)
511 (native-inputs
512 `(("pkg-config" ,pkg-config)))
513 (inputs
514 `(("igraph" ,igraph)))
515 (home-page "https://sourceforge.net/projects/rankwidth/")
516 (synopsis "Rank-width and rank-decomposition of graphs")
517 (description "rw computes rank-width and rank-decompositions
518of graphs.")
519 (license license:gpl2+)))
56973172
AK
520
521(define-public mscgen
522 (package
523 (name "mscgen")
524 (version "0.20")
525 (source
526 (origin
527 (method url-fetch)
528 (uri (string-append "http://www.mcternan.me.uk/mscgen/software/mscgen-src-"
529 version ".tar.gz"))
530 (sha256
531 (base32
532 "08yw3maxhn5fl1lff81gmcrpa4j9aas4mmby1g9w5qcr0np82d1w"))))
533 (build-system gnu-build-system)
534 (inputs
535 `(("gd" ,gd)))
536 (home-page "http://www.mcternan.me.uk/mscgen/")
537 (synopsis "Message Sequence Chart Generator")
538 (description "Mscgen is a small program that parses Message Sequence Chart
539descriptions and produces PNG, SVG, EPS or server side image maps (ismaps) as
540the output. Message Sequence Charts (MSCs) are a way of representing entities
541and interactions over some time period and are often used in combination with
542SDL. MSCs are popular in Telecoms to specify how protocols operate although
543MSCs need not be complicated to create or use. Mscgen aims to provide a simple
544text language that is clear to create, edit and understand, which can also be
545transformed into common image formats for display or printing.")
546 (license license:gpl2+)))