networkit-rs 0.1.0

Rust bindings for Networkit
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
########################################################################################################
# Build configurations
# ====================
#
# full
# ----
# Description: Basic build with all components (TLX, C++, Cython). Has to be tested on every fully
#              supported platform. Close to user-experience, except that warnings are also treated
#              as errors during build and TLX is provided as externally build library (normal
#              installation builds both NetworKit and TLX in one step).
# Script:      scripts/full.sh
# Build-type:  Release
# Variants:    native = Build for native architecture
#
#
# core
# ----
# Description: Builds the C++ code into one shared library. Has also sanity checks and debugging.
#              Since this only modifies the C++ building-process, Cython + Python-tests are removed in
#              order to increase speed.
# Script:      scripts/core.sh
# Build-type:  Debug
# Variants:    release = Release-build (only used on Windows, since "full" is not supported)
#              native = Build for native architecture (only used on Windows, since "full" is not supported)
#              non-monolithic = Each C++ module is a library
#              C++20 = Check for (latest) C++20 conformance
#
#
# clang-tidy
# ----------
# Description: Uses clang-tidy for several static analysis checks. These involve bug prone programming
#              errors, possible modernizations and performance optiomizations.
# Script:      scripts/clang_tidy.sh
# Config:      .clang-tidy
# Build-type:  Debug
#
#
# coverage
# --------
# Description: Enables code-coverage, address- & leak-sanitizers and tests in order to create cpp-coveralls data.
# Script:      scripts/core_sanitizers_coverage.sh
# Build type:  Debug
#
#
# documentation:
# --------------
# Description: Builds documentation of both C++ and Python-code. The result is automatically deployed
#              when a pull request is merged.
# Script:      scripts/documentation.sh
# Build-type:  Debug
#
#
# Jobs:
# =====
# 0. Rationale:
# - Main platform is Linux, which is therefore used for most of the tests.
# - Basic user experience (full) should be tested on all supported platforms (Linux, macOS, Windows)
#   with the default compiler.
# - For further user-centric tests, "full (native)" should be tested with default compiler for
#   vectorization support.
# - At least one debug build, so either core or one of its variants, should be done on each platform
#   to check for problems like possible race conditions.
# - At least on one platform: code styling/static-analysis (clang-tidy, code-style), coverage,
#   documentation and all core-variants, minimum supported version of compilers / Python
# - Remark: Currently Windows does not support a full/native build, therefore core builds are used.
#
# 1. Linux:
# - Latest version (gcc/Python): full, full (native)
# - Latest version (clang/Python): core
# - Minimum version (gcc/Python, clang/Python): full
# - Additional: core (non-monolithic), core (C++20), clang-tidy, code-style, coverage,
#               documentation
#
# 2. macOS:
# - Latest version (apple-clang): full, full (native)
# - Latest version (gcc/Python, clang/Python): core
#
# 3. Windows
# - Latest version (msvc): core, core (release), core (native)
#
#
# Job naming
# ==========
# <OS> [opt.]<OS-VERSION> (<COMPILER>, [opt.]<PYTHON VERSION>): <BUILD CONFIGURATION>
########################################################################################################

name: build

on: [push, pull_request]

# Default parameters for all builds.
env:
  OMP_NUM_THREADS: 2
  CXX_STANDARD: 17
  MONOLITH: ON
  TLX_PATH: /home/runner/work/networkit/networkit/tlx
  TLX_PATH_WIN: /d/a/networkit/networkit/tlx
  NATIVE: OFF

jobs:
  macos-build-latest-version-apple-clang:
    name: "macOS ${{ matrix.os }} (apple-clang, CPython 3.10): ${{ matrix.build-configuration }}"
    runs-on: macos-${{ matrix.os }}
    env:
      CC: cc
      CXX: c++
    strategy:
      matrix:
        os: ['11']
        build-configuration: ['full', 'full (native)']
    steps:
      - name: Install prerequisites
        run: |
          brew install libomp
          brew install ninja
      - name: Setup Python 3.11
        uses: actions/setup-python@v3
        with:
          python-version: '3.11.0'
      - name: Checkout networkit
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Checkout tlx
        uses: actions/checkout@v2
        with:
          repository: tlx/tlx
          path: tlx
      - name: Prepare environment and run checks
        run:  ${{ github.workspace }}/.github/workflows/scripts/full.sh
        shell: bash
        env:
          TLX_PATH: /Users/runner/work/networkit/networkit/tlx
          NATIVE: ${{ matrix.os == 'full (native)' }}

  macos-build-latest-version-misc:
    name: "macOS ${{ matrix.os }} (${{ matrix.compiler }}): core"
    runs-on: macos-${{ matrix.os }}
    strategy:
      matrix:
        os: ['11']
        compiler: ['clang-15', 'gcc-11']
    steps:
      - name: Install prerequisites
        run: |
          brew install libomp
          brew install ninja
      - name: Install compiler llvm
        if: matrix.compiler == 'clang-15'
        run: |
          brew reinstall llvm@15
          brew link --overwrite llvm@15
      - name: Install compiler gcc
        if: matrix.compiler == 'gcc-11'
        run: |
          brew reinstall gcc@11
          brew link --overwrite gcc@11
      - name: Checkout networkit
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Prepare environment and run checks
        run:  ${{ github.workspace }}/.github/workflows/scripts/cpp_only.sh
        shell: bash
        env:
          CC: ${{ matrix.compiler == 'clang-15' && '/usr/local/opt/llvm@15/bin/clang' || 'gcc-11' }}
          CXX: ${{ matrix.compiler == 'clang-15' && '/usr/local/opt/llvm@15/bin/clang++' || 'g++-11' }}

  linux-build-latest:
    name: "Linux (gcc-11${{ startsWith(matrix.build-configuration, 'full') && ', CPython 3.11' || '' }}): ${{ matrix.build-configuration }}"
    runs-on: ubuntu-20.04
    env:
      CC: gcc-11
      CXX: g++-11
    strategy:
      matrix:
        build-configuration: ['full', 'full (native)', 'core (non-monolithic)', 'core (C++20)']
    steps:
      - name: Install prerequisites
        run:  |
          sudo add-apt-repository 'deb http://mirrors.kernel.org/ubuntu jammy main universe'
          sudo apt-get update
          sudo apt-get install gcc-11 g++-11 ninja-build
      - name: Setup Python 3.11.0
        uses: actions/setup-python@v3
        with:
          python-version: '3.11.0'
      - name: Checkout networkit
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Checkout tlx
        if: ${{ startsWith(matrix.build-configuration, 'full') }}
        uses: actions/checkout@v2
        with:
          repository: tlx/tlx
          path: tlx
      - name: Prepare environment and run checks
        run:  ${{ github.workspace }}/.github/workflows/scripts/$SCRIPT
        shell: bash
        env:
          NATIVE: ${{ matrix.build-configuration == 'full (native)' }}
          MONOLITH: ${{ matrix.build-configuration != 'core (non-monolithic)' }}
          SCRIPT: ${{ startsWith(matrix.build-configuration, 'core') && 'cpp_only.sh' || 'full.sh'}}
          CXX_STANDARD: ${{ matrix.build-configuration == 'core (C++20)' && '20' || env.CXX_STANDARD }}

  linux-build-misc:
    name: "Linux (${{ matrix.compiler }}): core"
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        compiler: ['clang-15']
    steps:
      - name: Install prerequisites
        run:  |
          curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
          echo "deb http://apt.llvm.org/focal llvm-toolchain-focal-15 main" | sudo tee /etc/apt/sources.list.d/llvm13.list
          sudo apt-get update
          sudo apt-get install clang-15 libomp-15-dev ninja-build
      - name: Checkout networkit
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Checkout tlx
        uses: actions/checkout@v2
        with:
          repository: tlx/tlx
          path: tlx
      - name: Prepare environment and run checks
        run:  ${{ github.workspace }}/.github/workflows/scripts/cpp_only.sh
        shell: bash
        env:
          CC: clang-15
          CXX: clang++-15

  linux-build-min-support:
    name: "Linux (${{ matrix.compiler }}, CPython 3.7): full"
    runs-on: ubuntu-18.04
    strategy:
      matrix:
        compiler: ['gcc-7', 'clang-5']
    steps:
      - name: Install prerequisites
        run:  |
          sudo apt-get update
          sudo apt-get install ninja-build
          sudo apt-get install libomp5 libomp-dev clang-5.0 clang++-5.0
          sudo apt-get install gcc-7 g++-7
      - name: Setup Python 3.7
        uses: actions/setup-python@v2
        with:
          python-version: '3.7'
      - name: Checkout networkit
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Checkout tlx
        uses: actions/checkout@v2
        with:
          repository: tlx/tlx
          path: tlx
      - name: Prepare environment and run checks
        run:  ${{ github.workspace }}/.github/workflows/scripts/full.sh
        shell: bash
        env:
          CC: ${{ matrix.compiler == 'gcc-7' && 'gcc-7' || 'clang-5.0' }}
          CXX: ${{ matrix.compiler == 'gcc-7' && 'g++-7' || 'clang++-5.0' }}

  linux-build-clang-tidy:
    name: "Linux (clang-15): clang-tidy"
    runs-on: ubuntu-20.04
    env:
      CC: clang
      CXX: clang++
    steps:
      - name: Install prerequisites
        run: |
          curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
          echo "deb http://apt.llvm.org/focal llvm-toolchain-focal-15 main" | sudo tee /etc/apt/sources.list.d/llvm13.list
          sudo apt-get update
          sudo apt-get install libomp-15-dev clang-15 clang-tidy-15 ninja-build
      - name: Checkout networkit
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Prepare environment and run checks
        run:  ${{ github.workspace }}/.github/workflows/scripts/clang_tidy.sh
        shell: bash

  linux-build-core-sanitizers-coverage:
    name: "Linux (gcc-10, CPython 3.11): coverage"
    runs-on: ubuntu-20.04
    env:
      CC: gcc-10
      CXX: g++-10
      COVERALLS_DUMP_FILE: coveralls.dump
      COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
      COVERALLS_SVC_NUM: ${{ github.run_number }}
      NETWORKIT_BUILD_TESTS: ON
    steps:
      - name: Install prerequisites
        run:  |
          sudo apt-get update
          sudo apt-get install ninja-build
      - name: Setup Python 3.11.0
        uses: actions/setup-python@v3
        with:
          python-version: '3.11.0'
      - name: Checkout
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Prepare environment and run checks
        run:  ${{ github.workspace }}/.github/workflows/scripts/core_sanitizers_coverage.sh
        shell: bash
        timeout-minutes: 120
      - name: Create C++ coverage
        run: |
          cd ${{ github.workspace }}
          . pyenv/bin/activate
          cd core_build
          gcovr -e '.*test/.*' -e '.*CMakeFiles.*' -e '.*/extlibs/.*' -e '.*/scripts/.*' -e '.*/pyenv/.*' -e '.*/include/tlx/.*' --coveralls -r .. > networkit_cpp.json
          gcovr -e '.*test/.*' -e '.*CMakeFiles.*' -e '.*/extlibs/.*' -e '.*/scripts/.*' -e '.*/pyenv/.*' -e '.*/include/tlx/.*' -r ..
      - name: Create Python coverage and merge files
        run: |
          cd ${{ github.workspace }}
          . pyenv/bin/activate
          coverage run -m unittest discover -v networkit/test
          coverage report
          coveralls --merge=core_build/networkit_cpp.json --output=$COVERALLS_DUMP_FILE
      - name: Upload coverage
        if: github.event_name == 'push' && github.ref == 'refs/heads/master'
        run: |
          cd ${{ github.workspace }}
          . pyenv/bin/activate
          python3 ${{ github.workspace }}/.github/workflows/scripts/upload_coverage.py

  windows-build-msvc:
    name: "Windows (msvc 14.31): ${{ matrix.build-configuration }}"
    runs-on: windows-2022
    strategy:
      matrix:
        build-configuration: ['core']
    steps:
      - name: Checkout networkit
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Setup devCmd (vstools)
        uses: ilammy/msvc-dev-cmd@v1
      - name: Prepare environment and run checks
        shell: bash
        run: |
          mkdir build && cd build
          cmake -GNinja -DNETWORKIT_STATIC=ON -DNETWORKIT_BUILD_TESTS=ON -DNETWORKIT_MONOLITH=ON -DNETWORKIT_CXX_STANDARD=${{ env.CXX_STANDARD }} -DNETWORKIT_WARNINGS=ON -DCMAKE_BUILD_TYPE=Debug -DNETWORKIT_SANITY_CHECKS=ON ..
          ninja
          ctest -V -C Debug

  windows-build-latest:
    name: "Windows (msvc 14.31, CPython 3.11): ${{ matrix.build-configuration }}"
    runs-on: windows-2022
    strategy:
      matrix:
        build-configuration: ['full', 'full (native)']
    steps:
      - name: Setup Python 3.11.0
        uses: actions/setup-python@v3
        with:
          python-version: '3.11.0'
      - name: Checkout networkit
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Checkout tlx
        uses: actions/checkout@v2
        with:
          repository: tlx/tlx
          path: tlx
      - name: Setup devCmd (vstools)
        uses: ilammy/msvc-dev-cmd@v1
      - name: Prepare environment and run checks
        shell: bash
        run: |
          cd tlx && mkdir build && cd build
          cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ env.TLX_PATH_WIN }} ..
          ninja && ninja install
          cd ../..
          python -m venv pyenv
          . ./pyenv/Scripts/activate
          pip install cython ipython jupyter ipywidgets==7.7.1 jupyterlab-widgets==1.1.1
          mkdir build && cd build
          cmake -GNinja -DNETWORKIT_BUILD_TESTS=ON -DNETWORKIT_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DNETWORKIT_CXX_STANDARD=${{ env.CXX_STANDARD }} -DNETWORKIT_WARNINGS=ON -DNETWORKIT_WARNINGS_AS_ERRORS=ON -DNETWORKIT_EXT_TLX=${{ env.TLX_PATH_WIN }} -DNETWORKIT_NATIVE=${{ env.NATIVE }} ..
          ninja
          ctest -V -C Release
          cd ..
          python setup.py build_ext --inplace --external-tlx=${{ env.TLX_PATH_WIN }}
          pip install -e .
          python -c 'import networkit'
          pip install -r requirements.txt
          python -m unittest discover -v networkit/test/
          pip install ipycytoscape plotly seaborn
          python notebooks/test_notebooks.py "notebooks"
        env:
          NATIVE: ${{ matrix.os == 'full (native)' }}

  documentation-build:
    name: "Linux (gcc-11, CPython 3.11): documentation"
    runs-on: ubuntu-20.04
    env:
      CC: gcc-11
      CXX: g++-11
    steps:
      - name: Install prerequisites
        run:  |
          sudo add-apt-repository 'deb http://mirrors.kernel.org/ubuntu jammy main universe'
          sudo apt-get update
          sudo apt-get install gcc-11 g++-11 ninja-build
          sudo apt-get install doxygen pandoc
      - name: Setup Python 3.11.0
        uses: actions/setup-python@v3
        with:
          python-version: '3.11.0'
      - name: Checkout networkit
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Prepare environment and run checks
        run:  ${{ github.workspace }}/.github/workflows/scripts/documentation.sh
        shell: bash
      - name: Deploy networkit.github.io
        if: github.event_name == 'push' && github.ref == 'refs/heads/master'
        uses: peaceiris/actions-gh-pages@v3
        with:
          personal_token: ${{ secrets.SECRET_DEPLOY_GITHUB_PAGES }}
          external_repository: networkit/dev-docs
          publish_branch:  master
          publish_dir: ./core_build/htmldocs
          force_orphan: true
          user_name: 'github-actions[bot]'
          user_email: 'github-actions[bot]@users.noreply.github.com'

  style-guide-compliance-build:
    name: "Linux (default): code-style"
    runs-on: ubuntu-20.04
    steps:
      - name: Install prerequisites
        run: |
          curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
          echo "deb http://apt.llvm.org/focal llvm-toolchain-focal-15 main" | sudo tee /etc/apt/sources.list.d/llvm11.list
          sudo apt-get update
          sudo apt-get install clang-format-15 python-yaml
      - name: Checkout networkit
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Prepare environment and run checks
        run:  |
          set -e
          ./check_code.sh -v