1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2018 Joshua Sierles, Nextjournal <joshua@nextjournal.com>
4 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
8 ;;; This file is part of GNU Guix.
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.
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.
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/>.
23 (define-module (gnu packages graph)
24 #:use-module (guix download)
25 #:use-module (guix git-download)
26 #:use-module (guix packages)
27 #:use-module (guix utils)
28 #:use-module (guix build-system cmake)
29 #:use-module (guix build-system gnu)
30 #:use-module (guix build-system python)
31 #:use-module (guix build-system r)
32 #:use-module ((guix licenses) #:prefix license:)
33 #:use-module (gnu packages)
34 #:use-module (gnu packages gcc)
35 #:use-module (gnu packages autotools)
36 #:use-module (gnu packages bioconductor)
37 #:use-module (gnu packages bioinformatics)
38 #:use-module (gnu packages check)
39 #:use-module (gnu packages compression)
40 #:use-module (gnu packages cran)
41 #:use-module (gnu packages graphviz)
42 #:use-module (gnu packages maths)
43 #:use-module (gnu packages multiprecision)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages python-science)
47 #:use-module (gnu packages python-web)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages statistics)
50 #:use-module (gnu packages swig)
51 #:use-module (gnu packages time)
52 #:use-module (gnu packages xml))
61 (uri (string-append "http://igraph.org/nightly/get/c/igraph-"
65 "1pxh8sdlirgvbvsw8v65h6prn7hlm45bfsl1yfcgd6rn4w706y6r"))))
66 (build-system gnu-build-system)
69 (list "--with-external-glpk"
70 "--with-external-blas"
71 "--with-external-lapack")))
77 ("openblas" ,openblas)
79 (home-page "http://igraph.org")
80 (synopsis "Network analysis and visualization")
82 "This package provides a library for the analysis of networks and graphs.
83 It can handle large graphs very well and provides functions for generating
84 random and regular graphs, graph visualization, centrality methods and much
86 (license license:gpl2+)))
88 (define-public python-igraph
89 (package (inherit igraph)
90 (name "python-igraph")
91 (version "0.7.1.post6")
95 (uri (pypi-uri "python-igraph" version))
98 "0xp61zz710qlzhmzbfr65d5flvsi8zf2xy78s6rsszh719wl5sm5"))))
99 (build-system python-build-system)
102 `(("igraph" ,igraph)))
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")))
108 (define-public r-igraph
115 (uri (cran-uri "igraph" version))
118 "0scrbqb26pam8akblb4g9rkz888s0xffw3gcly78s4ijj67barxd"))))
119 (build-system r-build-system)
121 `(("gfortran" ,gfortran)))
128 `(("r-magrittr" ,r-magrittr)
129 ("r-matrix" ,r-matrix)
130 ("r-pkgconfig" ,r-pkgconfig)))
131 (home-page "http://igraph.org")
132 (synopsis "Network analysis and visualization")
134 "This package provides routines for simple graphs and network analysis.
135 It can handle large graphs very well and provides functions for generating
136 random and regular graphs, graph visualization, centrality methods and much
138 (license license:gpl2+)))
140 (define-public r-diffusionmap
142 (name "r-diffusionmap")
147 (uri (cran-uri "diffusionMap" version))
150 "1rvk7069brlm1s9kqj4c31mwwr3mw4hmhay95cjjjfmw5xclff2j"))))
151 (properties `((upstream-name . "diffusionMap")))
152 (build-system r-build-system)
154 `(("r-igraph" ,r-igraph)
155 ("r-matrix" ,r-matrix)
156 ("r-scatterplot3d" ,r-scatterplot3d)))
157 (home-page "https://www.r-project.org")
158 (synopsis "Diffusion map")
159 (description "This package implements the diffusion map method of data
160 parametrization, including creation and visualization of diffusion maps,
161 clustering with diffusion K-means and regression using the adaptive regression
163 (license license:gpl2)))
165 (define-public r-rgraphviz
172 (uri (bioconductor-uri "Rgraphviz" version))
175 "0nivz8fshaqig6ynjqbya2gmxsy4hm7jnd8fhb853z5g0ydp7g0c"))))
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)))
183 `(("r-graph" ,r-graph)))
185 `(("pkg-config" ,pkg-config)))
186 (home-page "http://bioconductor.org/packages/Rgraphviz")
187 (synopsis "Plotting capabilities for R graph objects")
189 "This package interfaces R with the graphviz library for plotting R graph
190 objects from the @code{graph} package.")
191 (license license:epl1.0)))
193 (define-public r-rbiofabric
194 (let ((commit "666c2ae8b0a537c006592d067fac6285f71890ac")
197 (name "r-rbiofabric")
198 (version (string-append "0.3-" revision "." (string-take commit 7)))
202 (url "https://github.com/wjrl/RBioFabric.git")
204 (file-name (string-append name "-" version "-checkout"))
207 "1yahqrcrqpbcywv73y9rlmyz8apdnp08afialibrr93ch0p06f8z"))))
208 (build-system r-build-system)
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
215 represented by horizontal lines, and edges are represented by vertical
217 (license license:expat))))
219 (define-public python-plotly
221 (name "python-plotly")
226 (uri (pypi-uri "plotly" version))
229 "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
230 (build-system python-build-system)
232 '(#:tests? #f)) ; The tests are not distributed in the release
234 `(("python-decorator" ,python-decorator)
235 ("python-nbformat" ,python-nbformat)
236 ("python-pandas" ,python-pandas)
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,
243 publication-quality graphs online. Examples of how to make line plots, scatter
244 plots, area charts, bar charts, error bars, box plots, histograms, heatmaps,
245 subplots, multiple-axes, polar charts, and bubble charts. ")
246 (license license:expat)))
248 (define-public python2-plotly
249 (package-with-python2 python-plotly))
251 (define-public python-louvain
253 (name "python-louvain")
255 ;; The tarball on Pypi does not include the tests.
259 (url "https://github.com/vtraag/louvain-igraph.git")
261 (file-name (git-file-name name version))
264 "0w31537sifkf65sck1iaip5i6d8g64pa3wdwad83d6p9jwkck57k"))))
265 (build-system python-build-system)
267 `(("python-ddt" ,python-ddt)
268 ("python-igraph" ,python-igraph)))
270 `(("igraph" ,igraph)))
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")
277 "This package provides an implementation of the Louvain algorithm for use
278 with igraph. Louvain is a general algorithm for methods of community
279 detection in large networks.
281 This package has been superseded by the @code{leidenalg} package and should
282 not be used for new projects.")
283 (license license:gpl3+)))
292 (url "https://github.com/facebookresearch/faiss.git")
293 (commit (string-append "v" version))))
294 (file-name (git-file-name name version))
297 "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
298 (modules '((guix build utils)))
301 (substitute* "utils.cpp"
302 (("#include <immintrin.h>")
303 "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
305 (build-system cmake-build-system)
308 (list "-DBUILD_WITH_GPU=OFF" ; thanks, but no thanks, CUDA.
309 "-DBUILD_TUTORIAL=OFF") ; we don't need those
311 (modify-phases %standard-phases
312 (add-after 'unpack 'prepare-build
314 (let ((features (list ,@(let ((system (or (%current-target-system)
317 ((string-prefix? "x86_64" system)
318 '("-mavx" "-msse2" "-mpopcnt"))
319 ((string-prefix? "i686" system)
320 '("-msse2" "-mpopcnt"))
323 (substitute* "CMakeLists.txt"
325 (("-mpopcnt") "") ; only some architectures
328 (string-join features)
330 ;; Build also the shared library
331 (("ARCHIVE DESTINATION lib")
332 "LIBRARY DESTINATION lib")
335 add_library(objlib OBJECT ${faiss_cpu_headers} ${faiss_cpu_cpp})
336 set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
337 add_library(${faiss_lib}_static STATIC $<TARGET_OBJECTS:objlib>)
338 add_library(${faiss_lib} SHARED $<TARGET_OBJECTS:objlib>)
339 install(TARGETS ${faiss_lib}_static ARCHIVE DESTINATION lib)
342 ;; See https://github.com/facebookresearch/faiss/issues/520
343 (substitute* "IndexScalarQuantizer.cpp"
344 (("#define USE_AVX") ""))
346 ;; Make header files available for compiling tests.
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$"))
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")
364 `(("openblas" ,openblas)))
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
370 clustering of dense vectors. It contains algorithms that search in sets of
371 vectors of any size, up to ones that possibly do not fit in RAM. It also
372 contains supporting code for evaluation and parameter tuning.")
373 (license license:bsd-3)))
375 (define-public python-faiss
376 (package (inherit faiss)
377 (name "python-faiss")
378 (build-system python-build-system)
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"
388 (let ((python-version ,(version-major+minor (package-version python))))
390 PYTHONCFLAGS =-I~a/include/python~am/ -I~a/lib/python~a/site-packages/numpy/core/include
391 LIBS = -lpython~am -lfaiss
392 SHAREDFLAGS = -shared -fopenmp
393 CXXFLAGS = -fpermissive -fopenmp -fPIC
394 CPUFLAGS = ~{~a ~}~%"
395 (assoc-ref inputs "python*") python-version
396 (assoc-ref inputs "python-numpy") python-version
398 (list ,@(let ((system (or (%current-target-system)
401 ((string-prefix? "x86_64" system)
402 '("-mavx" "-msse2" "-mpopcnt"))
403 ((string-prefix? "i686" system)
404 '("-msse2" "-mpopcnt"))
407 (substitute* "Makefile"
408 (("../libfaiss.a") ""))
409 (invoke "make" "cpu"))))))
412 ("openblas" ,openblas)
416 `(("python-matplotlib" ,python-matplotlib)
417 ("python-numpy" ,python-numpy)))
418 (description "Faiss is a library for efficient similarity search and
419 clustering of dense vectors. This package provides Python bindings to the
422 (define-public python-leidenalg
424 (name "python-leidenalg")
429 (uri (pypi-uri "leidenalg" version))
432 "15fwld9hdw357rd026mzcwpah5liy4f33vc9x9kwy37g71b2rjf1"))))
433 (build-system python-build-system)
434 (arguments '(#:tests? #f)) ; tests are not included
436 `(("pkg-config" ,pkg-config)))
438 `(("igraph" ,igraph)))
440 `(("python-igraph" ,python-igraph)))
441 (home-page "https://github.com/vtraag/leidenalg")
442 (synopsis "Community detection in large networks")
444 "Leiden is a general algorithm for methods of community detection in
445 large networks. This package implements the Leiden algorithm in C++ and
446 exposes it to Python. Besides the relative flexibility of the implementation,
447 it also scales well, and can be run on graphs of millions of nodes (as long as
448 they can fit in memory). The core function is @code{find_partition} which
449 finds the optimal partition using the Leiden algorithm, which is an extension
450 of the Louvain algorithm, for a number of different methods.")
451 (license license:gpl3+)))
453 (define-public edge-addition-planarity-suite
455 (name "edge-addition-planarity-suite")
461 (url (string-append "https://github.com/graph-algorithms/"
463 (commit (string-append "Version_" version))))
464 (file-name (git-file-name name version))
467 "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8"))))
468 (build-system gnu-build-system)
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
475 linear time edge addition algorithm for embedding planar graphs and
476 isolating planarity obstructions.")
477 (license license:bsd-3)
479 "https://github.com/graph-algorithms/edge-addition-planarity-suite")))
484 ;; There is a version 0.8, but the tarball is broken with symlinks
489 (uri (string-append "mirror://sourceforge/rankwidth/"
490 "rw-" version ".tar.gz"))
493 "1rv2v42x2506x7f10349m1wpmmfxrv9l032bkminni2gbip9cjg0"))))
494 (build-system gnu-build-system)
496 `(("pkg-config" ,pkg-config)))
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
503 (license license:gpl2+)))