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