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>
7 ;;; This file is part of GNU Guix.
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 (define-module (gnu packages graph)
23 #:use-module (guix download)
24 #:use-module (guix git-download)
25 #:use-module (guix packages)
26 #:use-module (guix utils)
27 #:use-module (guix build-system cmake)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system python)
30 #:use-module (guix build-system r)
31 #:use-module ((guix licenses) #:prefix license:)
32 #:use-module (gnu packages)
33 #:use-module (gnu packages gcc)
34 #:use-module (gnu packages bioconductor)
35 #:use-module (gnu packages bioinformatics)
36 #:use-module (gnu packages check)
37 #:use-module (gnu packages compression)
38 #:use-module (gnu packages cran)
39 #:use-module (gnu packages graphviz)
40 #:use-module (gnu packages maths)
41 #:use-module (gnu packages multiprecision)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages python-web)
45 #:use-module (gnu packages python-xyz)
46 #:use-module (gnu packages statistics)
47 #:use-module (gnu packages swig)
48 #:use-module (gnu packages time)
49 #:use-module (gnu packages xml))
58 (uri (string-append "http://igraph.org/nightly/get/c/igraph-"
62 "1pxh8sdlirgvbvsw8v65h6prn7hlm45bfsl1yfcgd6rn4w706y6r"))))
63 (build-system gnu-build-system)
66 (list "--with-external-glpk"
67 "--with-external-blas"
68 "--with-external-lapack")))
74 ("openblas" ,openblas)
76 (home-page "http://igraph.org")
77 (synopsis "Network analysis and visualization")
79 "This package provides a library for the analysis of networks and graphs.
80 It can handle large graphs very well and provides functions for generating
81 random and regular graphs, graph visualization, centrality methods and much
83 (license license:gpl2+)))
85 (define-public python-igraph
86 (package (inherit igraph)
87 (name "python-igraph")
88 (version "0.7.1.post6")
92 (uri (pypi-uri "python-igraph" version))
95 "0xp61zz710qlzhmzbfr65d5flvsi8zf2xy78s6rsszh719wl5sm5"))))
96 (build-system python-build-system)
99 `(("igraph" ,igraph)))
101 `(("pkg-config" ,pkg-config)))
102 (home-page "http://pypi.python.org/pypi/python-igraph")
103 (synopsis "Python bindings for the igraph network analysis library")))
105 (define-public r-igraph
112 (uri (cran-uri "igraph" version))
115 "1074y8mvprrqlkb4vwa2qc9l03r8d7p5vaaqacj4ljjs7dvcq6l9"))))
116 (build-system r-build-system)
118 `(("gfortran" ,gfortran)))
125 `(("r-magrittr" ,r-magrittr)
126 ("r-matrix" ,r-matrix)
127 ("r-pkgconfig" ,r-pkgconfig)))
128 (home-page "http://igraph.org")
129 (synopsis "Network analysis and visualization")
131 "This package provides routines for simple graphs and network analysis.
132 It can handle large graphs very well and provides functions for generating
133 random and regular graphs, graph visualization, centrality methods and much
135 (license license:gpl2+)))
137 (define-public r-diffusionmap
139 (name "r-diffusionmap")
144 (uri (cran-uri "diffusionMap" version))
147 "11l4kbciawvli5nlsi4qaf8afmgk5xgqiqpdyhvaqri5mx0zhk5j"))))
148 (properties `((upstream-name . "diffusionMap")))
149 (build-system r-build-system)
151 `(("r-igraph" ,r-igraph)
152 ("r-matrix" ,r-matrix)
153 ("r-scatterplot3d" ,r-scatterplot3d)))
154 (home-page "https://www.r-project.org")
155 (synopsis "Diffusion map")
156 (description "This package implements the diffusion map method of data
157 parametrization, including creation and visualization of diffusion maps,
158 clustering with diffusion K-means and regression using the adaptive regression
160 (license license:gpl2)))
162 (define-public r-rgraphviz
169 (uri (bioconductor-uri "Rgraphviz" version))
172 "0nivz8fshaqig6ynjqbya2gmxsy4hm7jnd8fhb853z5g0ydp7g0c"))))
173 (properties `((upstream-name . "Rgraphviz")))
174 (build-system r-build-system)
175 ;; FIXME: Rgraphviz bundles the sources of an older variant of
176 ;; graphviz. It does not build with the latest version of graphviz, so
177 ;; we do not add graphviz to the inputs.
178 (inputs `(("zlib" ,zlib)))
180 `(("r-graph" ,r-graph)))
182 `(("pkg-config" ,pkg-config)))
183 (home-page "http://bioconductor.org/packages/Rgraphviz")
184 (synopsis "Plotting capabilities for R graph objects")
186 "This package interfaces R with the graphviz library for plotting R graph
187 objects from the @code{graph} package.")
188 (license license:epl1.0)))
190 (define-public r-rbiofabric
191 (let ((commit "666c2ae8b0a537c006592d067fac6285f71890ac")
194 (name "r-rbiofabric")
195 (version (string-append "0.3-" revision "." (string-take commit 7)))
199 (url "https://github.com/wjrl/RBioFabric.git")
201 (file-name (string-append name "-" version "-checkout"))
204 "1yahqrcrqpbcywv73y9rlmyz8apdnp08afialibrr93ch0p06f8z"))))
205 (build-system r-build-system)
207 `(("r-igraph" ,r-igraph)))
208 (home-page "http://www.biofabric.org/")
209 (synopsis "BioFabric network visualization")
210 (description "This package provides an implementation of the function
211 @code{bioFabric} for creating scalable network digrams where nodes are
212 represented by horizontal lines, and edges are represented by vertical
214 (license license:expat))))
216 (define-public python-plotly
218 (name "python-plotly")
223 (uri (pypi-uri "plotly" version))
226 "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
227 (build-system python-build-system)
229 '(#:tests? #f)) ; The tests are not distributed in the release
231 `(("python-decorator" ,python-decorator)
232 ("python-nbformat" ,python-nbformat)
233 ("python-pandas" ,python-pandas)
234 ("python-pytz" ,python-pytz)
235 ("python-requests" ,python-requests)
236 ("python-six" ,python-six)))
237 (home-page "https://plot.ly/python/")
238 (synopsis "Interactive plotting library for Python")
239 (description "Plotly's Python graphing library makes interactive,
240 publication-quality graphs online. Examples of how to make line plots, scatter
241 plots, area charts, bar charts, error bars, box plots, histograms, heatmaps,
242 subplots, multiple-axes, polar charts, and bubble charts. ")
243 (license license:expat)))
245 (define-public python2-plotly
246 (package-with-python2 python-plotly))
248 (define-public python-louvain
250 (name "python-louvain")
252 ;; The tarball on Pypi does not include the tests.
256 (url "https://github.com/vtraag/louvain-igraph.git")
258 (file-name (git-file-name name version))
261 "0w31537sifkf65sck1iaip5i6d8g64pa3wdwad83d6p9jwkck57k"))))
262 (build-system python-build-system)
264 `(("python-ddt" ,python-ddt)
265 ("python-igraph" ,python-igraph)))
267 `(("igraph" ,igraph)))
269 `(("pkg-config" ,pkg-config)
270 ("python-pytest" ,python-pytest)))
271 (home-page "https://github.com/vtraag/louvain-igraph")
272 (synopsis "Algorithm for methods of community detection in large networks")
274 "This package provides an implementation of the Louvain algorithm for use
275 with igraph. Louvain is a general algorithm for methods of community
276 detection in large networks.
278 This package has been superseded by the @code{leidenalg} package and should
279 not be used for new projects.")
280 (license license:gpl3+)))
289 (url "https://github.com/facebookresearch/faiss.git")
290 (commit (string-append "v" version))))
291 (file-name (git-file-name name version))
294 "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
295 (modules '((guix build utils)))
298 (substitute* "utils.cpp"
299 (("#include <immintrin.h>")
300 "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
302 (build-system cmake-build-system)
305 (list "-DBUILD_WITH_GPU=OFF" ; thanks, but no thanks, CUDA.
306 "-DBUILD_TUTORIAL=OFF") ; we don't need those
308 (modify-phases %standard-phases
309 (add-after 'unpack 'prepare-build
311 (let ((features (list ,@(let ((system (or (%current-target-system)
314 ((string-prefix? "x86_64" system)
315 '("-mavx" "-msse2" "-mpopcnt"))
316 ((string-prefix? "i686" system)
317 '("-msse2" "-mpopcnt"))
320 (substitute* "CMakeLists.txt"
322 (("-mpopcnt") "") ; only some architectures
325 (string-join features)
327 ;; Build also the shared library
328 (("ARCHIVE DESTINATION lib")
329 "LIBRARY DESTINATION lib")
332 add_library(objlib OBJECT ${faiss_cpu_headers} ${faiss_cpu_cpp})
333 set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
334 add_library(${faiss_lib}_static STATIC $<TARGET_OBJECTS:objlib>)
335 add_library(${faiss_lib} SHARED $<TARGET_OBJECTS:objlib>)
336 install(TARGETS ${faiss_lib}_static ARCHIVE DESTINATION lib)
339 ;; See https://github.com/facebookresearch/faiss/issues/520
340 (substitute* "IndexScalarQuantizer.cpp"
341 (("#define USE_AVX") ""))
343 ;; Make header files available for compiling tests.
345 (for-each (lambda (file)
346 (mkdir-p (string-append "faiss/" (dirname file)))
347 (copy-file file (string-append "faiss/" file)))
348 (find-files "." "\\.h$"))
352 (invoke "make" "-C" "tests"
353 (format #f "-j~a" (parallel-job-count)))))
354 (add-after 'install 'remove-tests
355 (lambda* (#:key outputs #:allow-other-keys)
356 (delete-file-recursively
357 (string-append (assoc-ref outputs "out")
361 `(("openblas" ,openblas)))
363 `(("googletest" ,googletest)))
364 (home-page "https://github.com/facebookresearch/faiss")
365 (synopsis "Efficient similarity search and clustering of dense vectors")
366 (description "Faiss is a library for efficient similarity search and
367 clustering of dense vectors. It contains algorithms that search in sets of
368 vectors of any size, up to ones that possibly do not fit in RAM. It also
369 contains supporting code for evaluation and parameter tuning.")
370 (license license:bsd-3)))
372 (define-public python-faiss
373 (package (inherit faiss)
374 (name "python-faiss")
375 (build-system python-build-system)
378 (modify-phases %standard-phases
379 (add-after 'unpack 'chdir
380 (lambda _ (chdir "python") #t))
381 (add-after 'chdir 'build-swig
382 (lambda* (#:key inputs #:allow-other-keys)
383 (with-output-to-file "../makefile.inc"
385 (let ((python-version ,(version-major+minor (package-version python))))
387 PYTHONCFLAGS =-I~a/include/python~am/ -I~a/lib/python~a/site-packages/numpy/core/include
388 LIBS = -lpython~am -lfaiss
389 SHAREDFLAGS = -shared -fopenmp
390 CXXFLAGS = -fpermissive -std=c++11 -fopenmp -fPIC
391 CPUFLAGS = ~{~a ~}~%"
392 (assoc-ref inputs "python*") python-version
393 (assoc-ref inputs "python-numpy") python-version
395 (list ,@(let ((system (or (%current-target-system)
398 ((string-prefix? "x86_64" system)
399 '("-mavx" "-msse2" "-mpopcnt"))
400 ((string-prefix? "i686" system)
401 '("-msse2" "-mpopcnt"))
404 (substitute* "Makefile"
405 (("../libfaiss.a") ""))
406 (invoke "make" "cpu"))))))
409 ("openblas" ,openblas)
413 `(("python-matplotlib" ,python-matplotlib)
414 ("python-numpy" ,python-numpy)))
415 (description "Faiss is a library for efficient similarity search and
416 clustering of dense vectors. This package provides Python bindings to the
419 (define-public python-leidenalg
421 (name "python-leidenalg")
426 (uri (pypi-uri "leidenalg" version))
429 "15fwld9hdw357rd026mzcwpah5liy4f33vc9x9kwy37g71b2rjf1"))))
430 (build-system python-build-system)
431 (arguments '(#:tests? #f)) ; tests are not included
433 `(("pkg-config" ,pkg-config)))
435 `(("igraph" ,igraph)))
437 `(("python-igraph" ,python-igraph)))
438 (home-page "https://github.com/vtraag/leidenalg")
439 (synopsis "Community detection in large networks")
441 "Leiden is a general algorithm for methods of community detection in
442 large networks. This package implements the Leiden algorithm in C++ and
443 exposes it to Python. Besides the relative flexibility of the implementation,
444 it also scales well, and can be run on graphs of millions of nodes (as long as
445 they can fit in memory). The core function is @code{find_partition} which
446 finds the optimal partition using the Leiden algorithm, which is an extension
447 of the Louvain algorithm, for a number of different methods.")
448 (license license:gpl3+)))