1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2018 Joshua Sierles, Nextjournal <joshua@nextjournal.com>
4 ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
7 ;;; Copyright © 2020 Alexander Krotov <krotov@iitp.ru>
9 ;;; This file is part of GNU Guix.
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.
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.
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/>.
24 (define-module (gnu packages graph)
25 #:use-module (guix download)
26 #:use-module (guix git-download)
27 #:use-module (guix packages)
28 #:use-module (guix utils)
29 #:use-module (guix build-system cmake)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system python)
32 #:use-module (guix build-system r)
33 #:use-module ((guix licenses) #:prefix license:)
34 #:use-module (gnu packages)
35 #:use-module (gnu packages gcc)
36 #:use-module (gnu packages autotools)
37 #:use-module (gnu packages bioconductor)
38 #:use-module (gnu packages bioinformatics)
39 #:use-module (gnu packages check)
40 #:use-module (gnu packages compression)
41 #:use-module (gnu packages cran)
42 #:use-module (gnu packages gd)
43 #:use-module (gnu packages graphviz)
44 #:use-module (gnu packages maths)
45 #:use-module (gnu packages multiprecision)
46 #:use-module (gnu packages pkg-config)
47 #:use-module (gnu packages python)
48 #:use-module (gnu packages python-science)
49 #:use-module (gnu packages python-web)
50 #:use-module (gnu packages python-xyz)
51 #:use-module (gnu packages statistics)
52 #:use-module (gnu packages swig)
53 #:use-module (gnu packages time)
54 #:use-module (gnu packages xml))
63 (uri (string-append "https://github.com/igraph/igraph/releases/"
64 "download/" version "/igraph-" version ".tar.gz"))
66 (base32 "0wbvrac3ip3lqmbkckhnxa2swlbc86l1h8mazdlb618kx3winvi6"))))
67 (build-system gnu-build-system)
70 (list "--with-external-glpk"
71 "--with-external-blas"
72 "--with-external-lapack")))
78 ("openblas" ,openblas)
80 (home-page "http://igraph.org")
81 (synopsis "Network analysis and visualization")
83 "This package provides a library for the analysis of networks and graphs.
84 It can handle large graphs very well and provides functions for generating
85 random and regular graphs, graph visualization, centrality methods and much
87 (license license:gpl2+)))
89 (define-public python-igraph
90 (package (inherit igraph)
91 (name "python-igraph")
96 (uri (pypi-uri "python-igraph" version))
99 "13mbrlmnbgbzw6y8ws7wj0a3ly3in8j4l1ngi6yxvgvxxi4bprj7"))))
100 (build-system python-build-system)
103 (list "--use-pkg-config")
105 (modify-phases %standard-phases
108 (invoke "python" "./setup.py" "build" "--use-pkg-config")))
110 (add-after 'install 'check
111 (lambda* (#:key inputs outputs #:allow-other-keys)
112 (add-installed-pythonpath inputs outputs)
113 (invoke "pytest" "-v"))))))
115 `(("igraph" ,igraph)))
117 `(("python-texttable" ,python-texttable)))
119 `(("pkg-config" ,pkg-config)
120 ("python-pytest" ,python-pytest)))
121 (home-page "https://pypi.org/project/python-igraph/")
122 (synopsis "Python bindings for the igraph network analysis library")))
124 (define-public r-igraph
131 (uri (cran-uri "igraph" version))
134 "126z1ygbmi3g7hk97snf22rnx680dyi30idssm5zacba5rdngp8c"))))
135 (build-system r-build-system)
137 `(("gfortran" ,gfortran)))
144 `(("r-magrittr" ,r-magrittr)
145 ("r-matrix" ,r-matrix)
146 ("r-pkgconfig" ,r-pkgconfig)))
147 (home-page "http://igraph.org")
148 (synopsis "Network analysis and visualization")
150 "This package provides routines for simple graphs and network analysis.
151 It can handle large graphs very well and provides functions for generating
152 random and regular graphs, graph visualization, centrality methods and much
154 (license license:gpl2+)))
156 (define-public r-diffusionmap
158 (name "r-diffusionmap")
163 (uri (cran-uri "diffusionMap" version))
166 "1rvk7069brlm1s9kqj4c31mwwr3mw4hmhay95cjjjfmw5xclff2j"))))
167 (properties `((upstream-name . "diffusionMap")))
168 (build-system r-build-system)
170 `(("r-igraph" ,r-igraph)
171 ("r-matrix" ,r-matrix)
172 ("r-scatterplot3d" ,r-scatterplot3d)))
173 (home-page "https://www.r-project.org")
174 (synopsis "Diffusion map")
175 (description "This package implements the diffusion map method of data
176 parametrization, including creation and visualization of diffusion maps,
177 clustering with diffusion K-means and regression using the adaptive regression
179 (license license:gpl2)))
181 (define-public r-rgraphviz
188 (uri (bioconductor-uri "Rgraphviz" version))
191 "00lrkbgbb4payybckcmazsv8skysgdlglyqbl7yjb37vv3gnfc6c"))))
192 (properties `((upstream-name . "Rgraphviz")))
193 (build-system r-build-system)
194 ;; FIXME: Rgraphviz bundles the sources of an older variant of
195 ;; graphviz. It does not build with the latest version of graphviz, so
196 ;; we do not add graphviz to the inputs.
197 (inputs `(("zlib" ,zlib)))
199 `(("r-graph" ,r-graph)))
201 `(("pkg-config" ,pkg-config)))
202 (home-page "https://bioconductor.org/packages/Rgraphviz")
203 (synopsis "Plotting capabilities for R graph objects")
205 "This package interfaces R with the graphviz library for plotting R graph
206 objects from the @code{graph} package.")
207 (license license:epl1.0)))
209 (define-public r-rbiofabric
210 (let ((commit "666c2ae8b0a537c006592d067fac6285f71890ac")
213 (name "r-rbiofabric")
214 (version (string-append "0.3-" revision "." (string-take commit 7)))
218 (url "https://github.com/wjrl/RBioFabric.git")
220 (file-name (string-append name "-" version "-checkout"))
223 "1yahqrcrqpbcywv73y9rlmyz8apdnp08afialibrr93ch0p06f8z"))))
224 (build-system r-build-system)
226 `(("r-igraph" ,r-igraph)))
227 (home-page "http://www.biofabric.org/")
228 (synopsis "BioFabric network visualization")
229 (description "This package provides an implementation of the function
230 @code{bioFabric} for creating scalable network digrams where nodes are
231 represented by horizontal lines, and edges are represented by vertical
233 (license license:expat))))
235 (define-public python-plotly
237 (name "python-plotly")
242 (uri (pypi-uri "plotly" version))
245 "0s9gk2fl53x8wwncs3fwii1vzfngr0sskv15v3mpshqmrqfrk27m"))))
246 (build-system python-build-system)
248 '(#:tests? #f)) ; The tests are not distributed in the release
250 `(("python-decorator" ,python-decorator)
251 ("python-nbformat" ,python-nbformat)
252 ("python-pandas" ,python-pandas)
253 ("python-pytz" ,python-pytz)
254 ("python-requests" ,python-requests)
255 ("python-six" ,python-six)))
256 (home-page "https://plot.ly/python/")
257 (synopsis "Interactive plotting library for Python")
258 (description "Plotly's Python graphing library makes interactive,
259 publication-quality graphs online. Examples of how to make line plots, scatter
260 plots, area charts, bar charts, error bars, box plots, histograms, heatmaps,
261 subplots, multiple-axes, polar charts, and bubble charts. ")
262 (license license:expat)))
264 (define-public python2-plotly
265 (package-with-python2 python-plotly))
267 (define-public python-louvain
269 (name "python-louvain")
271 ;; The tarball on Pypi does not include the tests.
275 (url "https://github.com/vtraag/louvain-igraph.git")
277 (file-name (git-file-name name version))
280 "0w31537sifkf65sck1iaip5i6d8g64pa3wdwad83d6p9jwkck57k"))))
281 (build-system python-build-system)
283 `(("python-ddt" ,python-ddt)
284 ("python-igraph" ,python-igraph)))
286 `(("igraph" ,igraph)))
288 `(("pkg-config" ,pkg-config)
289 ("python-pytest" ,python-pytest)))
290 (home-page "https://github.com/vtraag/louvain-igraph")
291 (synopsis "Algorithm for methods of community detection in large networks")
293 "This package provides an implementation of the Louvain algorithm for use
294 with igraph. Louvain is a general algorithm for methods of community
295 detection in large networks.
297 This package has been superseded by the @code{leidenalg} package and should
298 not be used for new projects.")
299 (license license:gpl3+)))
308 (url "https://github.com/facebookresearch/faiss.git")
309 (commit (string-append "v" version))))
310 (file-name (git-file-name name version))
313 "0pk15jfa775cy2pqmzq62nhd6zfjxmpvz5h731197c28aq3zw39w"))
314 (modules '((guix build utils)))
317 (substitute* "utils.cpp"
318 (("#include <immintrin.h>")
319 "#ifdef __SSE__\n#include <immintrin.h>\n#endif"))
321 (build-system cmake-build-system)
324 (list "-DBUILD_WITH_GPU=OFF" ; thanks, but no thanks, CUDA.
325 "-DBUILD_TUTORIAL=OFF") ; we don't need those
327 (modify-phases %standard-phases
328 (add-after 'unpack 'prepare-build
330 (let ((features (list ,@(let ((system (or (%current-target-system)
333 ((string-prefix? "x86_64" system)
334 '("-mavx" "-msse2" "-mpopcnt"))
335 ((string-prefix? "i686" system)
336 '("-msse2" "-mpopcnt"))
339 (substitute* "CMakeLists.txt"
341 (("-mpopcnt") "") ; only some architectures
344 (string-join features)
346 ;; Build also the shared library
347 (("ARCHIVE DESTINATION lib")
348 "LIBRARY DESTINATION lib")
351 add_library(objlib OBJECT ${faiss_cpu_headers} ${faiss_cpu_cpp})
352 set_property(TARGET objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
353 add_library(${faiss_lib}_static STATIC $<TARGET_OBJECTS:objlib>)
354 add_library(${faiss_lib} SHARED $<TARGET_OBJECTS:objlib>)
355 install(TARGETS ${faiss_lib}_static ARCHIVE DESTINATION lib)
358 ;; See https://github.com/facebookresearch/faiss/issues/520
359 (substitute* "IndexScalarQuantizer.cpp"
360 (("#define USE_AVX") ""))
362 ;; Make header files available for compiling tests.
364 (for-each (lambda (file)
365 (mkdir-p (string-append "faiss/" (dirname file)))
366 (copy-file file (string-append "faiss/" file)))
367 (find-files "." "\\.h$"))
371 (invoke "make" "-C" "tests"
372 (format #f "-j~a" (parallel-job-count)))))
373 (add-after 'install 'remove-tests
374 (lambda* (#:key outputs #:allow-other-keys)
375 (delete-file-recursively
376 (string-append (assoc-ref outputs "out")
380 `(("openblas" ,openblas)))
382 `(("googletest" ,googletest)))
383 (home-page "https://github.com/facebookresearch/faiss")
384 (synopsis "Efficient similarity search and clustering of dense vectors")
385 (description "Faiss is a library for efficient similarity search and
386 clustering of dense vectors. It contains algorithms that search in sets of
387 vectors of any size, up to ones that possibly do not fit in RAM. It also
388 contains supporting code for evaluation and parameter tuning.")
389 (license license:bsd-3)))
391 (define-public python-faiss
392 (package (inherit faiss)
393 (name "python-faiss")
394 (build-system python-build-system)
397 (modify-phases %standard-phases
398 (add-after 'unpack 'chdir
399 (lambda _ (chdir "python") #t))
400 (add-after 'chdir 'build-swig
401 (lambda* (#:key inputs #:allow-other-keys)
402 (with-output-to-file "../makefile.inc"
404 (let ((python-version ,(version-major+minor (package-version python))))
406 PYTHONCFLAGS =-I~a/include/python~am/ -I~a/lib/python~a/site-packages/numpy/core/include
407 LIBS = -lpython~am -lfaiss
408 SHAREDFLAGS = -shared -fopenmp
409 CXXFLAGS = -fpermissive -fopenmp -fPIC
410 CPUFLAGS = ~{~a ~}~%"
411 (assoc-ref inputs "python*") python-version
412 (assoc-ref inputs "python-numpy") python-version
414 (list ,@(let ((system (or (%current-target-system)
417 ((string-prefix? "x86_64" system)
418 '("-mavx" "-msse2" "-mpopcnt"))
419 ((string-prefix? "i686" system)
420 '("-msse2" "-mpopcnt"))
423 (substitute* "Makefile"
424 (("../libfaiss.a") ""))
425 (invoke "make" "cpu"))))))
428 ("openblas" ,openblas)
432 `(("python-matplotlib" ,python-matplotlib)
433 ("python-numpy" ,python-numpy)))
434 (description "Faiss is a library for efficient similarity search and
435 clustering of dense vectors. This package provides Python bindings to the
438 (define-public python-leidenalg
440 (name "python-leidenalg")
445 (uri (pypi-uri "leidenalg" version))
448 "15fwld9hdw357rd026mzcwpah5liy4f33vc9x9kwy37g71b2rjf1"))))
449 (build-system python-build-system)
450 (arguments '(#:tests? #f)) ; tests are not included
452 `(("pkg-config" ,pkg-config)))
454 `(("igraph" ,igraph)))
456 `(("python-igraph" ,python-igraph)))
457 (home-page "https://github.com/vtraag/leidenalg")
458 (synopsis "Community detection in large networks")
460 "Leiden is a general algorithm for methods of community detection in
461 large networks. This package implements the Leiden algorithm in C++ and
462 exposes it to Python. Besides the relative flexibility of the implementation,
463 it also scales well, and can be run on graphs of millions of nodes (as long as
464 they can fit in memory). The core function is @code{find_partition} which
465 finds the optimal partition using the Leiden algorithm, which is an extension
466 of the Louvain algorithm, for a number of different methods.")
467 (license license:gpl3+)))
469 (define-public edge-addition-planarity-suite
471 (name "edge-addition-planarity-suite")
477 (url (string-append "https://github.com/graph-algorithms/"
479 (commit (string-append "Version_" version))))
480 (file-name (git-file-name name version))
483 "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8"))))
484 (build-system gnu-build-system)
486 `(("autoconf" ,autoconf)
487 ("automake" ,automake)
488 ("libtool" ,libtool)))
489 (synopsis "Embedding of planar graphs")
490 (description "The package provides a reference implementation of the
491 linear time edge addition algorithm for embedding planar graphs and
492 isolating planarity obstructions.")
493 (license license:bsd-3)
495 "https://github.com/graph-algorithms/edge-addition-planarity-suite")))
500 ;; There is a version 0.8, but the tarball is broken with symlinks
505 (uri (string-append "mirror://sourceforge/rankwidth/"
506 "rw-" version ".tar.gz"))
509 "1rv2v42x2506x7f10349m1wpmmfxrv9l032bkminni2gbip9cjg0"))))
510 (build-system gnu-build-system)
512 `(("pkg-config" ,pkg-config)))
514 `(("igraph" ,igraph)))
515 (home-page "https://sourceforge.net/projects/rankwidth/")
516 (synopsis "Rank-width and rank-decomposition of graphs")
517 (description "rw computes rank-width and rank-decompositions
519 (license license:gpl2+)))
521 (define-public mscgen
528 (uri (string-append "http://www.mcternan.me.uk/mscgen/software/mscgen-src-"
532 "08yw3maxhn5fl1lff81gmcrpa4j9aas4mmby1g9w5qcr0np82d1w"))))
533 (build-system gnu-build-system)
535 `(("pkg-config" ,pkg-config)))
538 (home-page "http://www.mcternan.me.uk/mscgen/")
539 (synopsis "Message Sequence Chart Generator")
540 (description "Mscgen is a small program that parses Message Sequence Chart
541 descriptions and produces PNG, SVG, EPS or server side image maps (ismaps) as
542 the output. Message Sequence Charts (MSCs) are a way of representing entities
543 and interactions over some time period and are often used in combination with
544 SDL. MSCs are popular in Telecoms to specify how protocols operate although
545 MSCs need not be complicated to create or use. Mscgen aims to provide a simple
546 text language that is clear to create, edit and understand, which can also be
547 transformed into common image formats for display or printing.")
548 (license license:gpl2+)))