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