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