ogdf-py 0.2.0__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/.github/workflows/build-publish.yml +17 -6
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/.github/workflows/ci.yml +54 -5
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/.gitignore +1 -1
- ogdf_py-0.5.1/CHANGELOG.md +215 -0
- ogdf_py-0.5.1/CMakeLists.txt +179 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/Makefile +1 -1
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/PKG-INFO +3 -3
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/README.md +2 -2
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/demos/README.md +11 -7
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/demos/algorithms_visual.py +283 -2
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/demos/layouts_gallery.py +5 -0
- ogdf_py-0.5.1/docs/choosing-a-layout.md +104 -0
- ogdf_py-0.5.1/docs/coverage.md +410 -0
- ogdf_py-0.5.1/docs/getting-started.md +523 -0
- ogdf_py-0.5.1/docs/index.md +65 -0
- ogdf_py-0.5.1/docs/metrics.md +178 -0
- ogdf_py-0.5.1/docs/recipes.md +180 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/mkdocs.yml +3 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/pyproject.toml +9 -1
- ogdf_py-0.5.1/scripts/bootstrap_ogdf.py +282 -0
- ogdf_py-0.5.1/scripts/ogdf-tag.txt +1 -0
- ogdf_py-0.5.1/src/ogdf/__init__.py +121 -0
- ogdf_py-0.5.1/src/ogdf/__main__.py +8 -0
- ogdf_py-0.5.1/src/ogdf/_about.py +110 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/src/ogdf/_core.cpp +7 -2
- ogdf_py-0.5.1/src/ogdf/_interop.py +379 -0
- ogdf_py-0.5.1/src/ogdf/_layout.py +204 -0
- ogdf_py-0.5.1/src/ogdf/_metrics.py +154 -0
- ogdf_py-0.5.1/src/ogdf/_random.py +126 -0
- ogdf_py-0.5.1/src/ogdf/_results.py +284 -0
- ogdf_py-0.5.1/src/ogdf/_transforms.py +192 -0
- ogdf_py-0.5.1/src/ogdf/_validate.py +154 -0
- ogdf_py-0.5.1/src/ogdf/bind_algorithms.cpp +861 -0
- ogdf_py-0.5.1/src/ogdf/bind_errors.cpp +38 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/src/ogdf/bind_graph.cpp +21 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/src/ogdf/bind_io.cpp +4 -2
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/src/ogdf/bind_layouts.cpp +153 -13
- ogdf_py-0.5.1/src/ogdf/bind_meta.cpp +85 -0
- ogdf_py-0.5.1/src/ogdf/bind_metrics.cpp +338 -0
- ogdf_py-0.5.1/src/ogdf/bind_transforms.cpp +261 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/src/ogdf/bindings.h +4 -0
- ogdf_py-0.5.1/src/ogdf/errors.h +187 -0
- ogdf_py-0.5.1/tests/conftest.py +20 -0
- ogdf_py-0.5.1/tests/test_about.py +53 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/tests/test_algorithms.py +188 -0
- ogdf_py-0.5.1/tests/test_docs.py +168 -0
- ogdf_py-0.5.1/tests/test_errors.py +238 -0
- ogdf_py-0.5.1/tests/test_interop.py +206 -0
- ogdf_py-0.5.1/tests/test_layout_facade.py +191 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/tests/test_layouts.py +58 -0
- ogdf_py-0.5.1/tests/test_metrics.py +302 -0
- ogdf_py-0.5.1/tests/test_recipes.py +149 -0
- ogdf_py-0.5.1/tests/test_reproducibility.py +70 -0
- ogdf_py-0.5.1/tests/test_results.py +235 -0
- ogdf_py-0.5.1/tests/test_transforms.py +314 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/uv.lock +31 -2
- ogdf_py-0.2.0/CHANGELOG.md +0 -77
- ogdf_py-0.2.0/CMakeLists.txt +0 -98
- ogdf_py-0.2.0/docs/coverage.md +0 -253
- ogdf_py-0.2.0/docs/getting-started.md +0 -111
- ogdf_py-0.2.0/docs/index.md +0 -46
- ogdf_py-0.2.0/scripts/bootstrap_ogdf.py +0 -126
- ogdf_py-0.2.0/src/ogdf/__init__.py +0 -22
- ogdf_py-0.2.0/src/ogdf/bind_algorithms.cpp +0 -439
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/LICENSE +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/demos/_common.py +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/demos/gallery.py +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/demos/generators_zoo.py +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/demos/io_roundtrip.py +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/demos/run_all.py +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/demos/styling_showcase.py +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/src/ogdf/bind_generators.cpp +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/src/ogdf/py.typed +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/tests/test_generators.py +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/tests/test_ogdf.py +0 -0
- {ogdf_py-0.2.0 → ogdf_py-0.5.1}/tests/test_styling.py +0 -0
|
@@ -22,9 +22,9 @@ concurrency:
|
|
|
22
22
|
cancel-in-progress: true
|
|
23
23
|
|
|
24
24
|
env:
|
|
25
|
-
# Build CPython 3.10-3.
|
|
25
|
+
# Build CPython 3.10-3.14; skip musllinux (OGDF is bootstrapped on
|
|
26
26
|
# manylinux/glibc) and PyPy.
|
|
27
|
-
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-*"
|
|
27
|
+
CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-* cp314-*"
|
|
28
28
|
CIBW_SKIP: "*-musllinux_* pp*"
|
|
29
29
|
# Clone + build OGDF once per platform before building any wheels. On Linux
|
|
30
30
|
# this runs inside the manylinux container (git present; install cmake).
|
|
@@ -32,9 +32,18 @@ env:
|
|
|
32
32
|
(command -v cmake >/dev/null 2>&1 || pipx install cmake) &&
|
|
33
33
|
python3 scripts/bootstrap_ogdf.py
|
|
34
34
|
CIBW_BEFORE_ALL_MACOS: python3 scripts/bootstrap_ogdf.py
|
|
35
|
+
# windows-latest ships git, CMake, and MSVC; the bootstrap builds OGDF with
|
|
36
|
+
# the MSVC toolchain.
|
|
37
|
+
CIBW_BEFORE_ALL_WINDOWS: python scripts/bootstrap_ogdf.py
|
|
35
38
|
# Exercise each wheel end-to-end (import + layouts + I/O).
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
# networkx is an optional runtime dependency; install it so the wheel test
|
|
40
|
+
# actually exercises the interop layer instead of skipping it.
|
|
41
|
+
CIBW_TEST_REQUIRES: pytest networkx
|
|
42
|
+
# Import, the installation report, and the full suite (layouts, algorithms,
|
|
43
|
+
# I/O, interop, recipes) against the built wheel rather than the source tree.
|
|
44
|
+
CIBW_TEST_COMMAND: >-
|
|
45
|
+
python -c "import ogdf; print(ogdf.about_text())" &&
|
|
46
|
+
pytest {project}/tests -v
|
|
38
47
|
|
|
39
48
|
jobs:
|
|
40
49
|
build-sdist:
|
|
@@ -75,6 +84,8 @@ jobs:
|
|
|
75
84
|
- os: macos-14
|
|
76
85
|
arch: arm64
|
|
77
86
|
macos_target: "11.0"
|
|
87
|
+
- os: windows-latest
|
|
88
|
+
arch: AMD64
|
|
78
89
|
env:
|
|
79
90
|
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macos_target }}
|
|
80
91
|
steps:
|
|
@@ -82,10 +93,10 @@ jobs:
|
|
|
82
93
|
|
|
83
94
|
# Cache the cloned+built OGDF per platform/arch so reruns skip the build.
|
|
84
95
|
- name: Cache OGDF
|
|
85
|
-
uses: actions/cache@
|
|
96
|
+
uses: actions/cache@v6
|
|
86
97
|
with:
|
|
87
98
|
path: thirdparty/ogdf
|
|
88
|
-
key: ogdf-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('scripts/bootstrap_ogdf.py') }}
|
|
99
|
+
key: ogdf-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('scripts/bootstrap_ogdf.py', 'scripts/ogdf-tag.txt') }}
|
|
89
100
|
|
|
90
101
|
- name: Build wheels
|
|
91
102
|
uses: pypa/cibuildwheel@v4.1.0
|
|
@@ -24,10 +24,10 @@ jobs:
|
|
|
24
24
|
# Cache the cloned+built OGDF so most runs skip the ~2 min build.
|
|
25
25
|
# Keyed on the bootstrap script (which pins the OGDF tag).
|
|
26
26
|
- name: Cache OGDF
|
|
27
|
-
uses: actions/cache@
|
|
27
|
+
uses: actions/cache@v6
|
|
28
28
|
with:
|
|
29
29
|
path: thirdparty/ogdf
|
|
30
|
-
key: ogdf-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/bootstrap_ogdf.py') }}
|
|
30
|
+
key: ogdf-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/bootstrap_ogdf.py', 'scripts/ogdf-tag.txt') }}
|
|
31
31
|
|
|
32
32
|
- name: Bootstrap OGDF
|
|
33
33
|
run: python3 scripts/bootstrap_ogdf.py
|
|
@@ -62,6 +62,52 @@ jobs:
|
|
|
62
62
|
fail_ci_if_error: false
|
|
63
63
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
64
64
|
|
|
65
|
+
offline-build:
|
|
66
|
+
name: Offline source build
|
|
67
|
+
runs-on: ubuntu-latest
|
|
68
|
+
steps:
|
|
69
|
+
- uses: actions/checkout@v7
|
|
70
|
+
|
|
71
|
+
# Without a vendored source, an offline bootstrap must fail fast and say
|
|
72
|
+
# how to supply one - rather than silently reaching for the network.
|
|
73
|
+
# The bootstrap is stdlib-only and must run on the system interpreter:
|
|
74
|
+
# `uv run` would build the project first, and CMakeLists bootstraps OGDF
|
|
75
|
+
# when it is missing, so the source would already be present here.
|
|
76
|
+
- name: Offline bootstrap refuses to clone
|
|
77
|
+
run: |
|
|
78
|
+
set +e
|
|
79
|
+
output=$(python3 scripts/bootstrap_ogdf.py --offline 2>&1)
|
|
80
|
+
status=$?
|
|
81
|
+
echo "$output"
|
|
82
|
+
test $status -ne 0 || { echo 'expected a non-zero exit'; exit 1; }
|
|
83
|
+
echo "$output" | grep -q 'network access is disabled'
|
|
84
|
+
|
|
85
|
+
# Vendor the source once, then build from it with the network path unused.
|
|
86
|
+
- name: Vendor the OGDF source
|
|
87
|
+
run: python3 scripts/bootstrap_ogdf.py --clone-only
|
|
88
|
+
|
|
89
|
+
- name: Install uv
|
|
90
|
+
uses: astral-sh/setup-uv@v8.3.0
|
|
91
|
+
with:
|
|
92
|
+
enable-cache: true
|
|
93
|
+
|
|
94
|
+
- name: Set up Python
|
|
95
|
+
run: uv python install 3.13
|
|
96
|
+
|
|
97
|
+
- name: Build from the vendored source with OGDF_OFFLINE set
|
|
98
|
+
env:
|
|
99
|
+
OGDF_OFFLINE: '1'
|
|
100
|
+
run: |
|
|
101
|
+
python3 scripts/bootstrap_ogdf.py
|
|
102
|
+
uv sync --dev
|
|
103
|
+
|
|
104
|
+
- name: Smoke-test the offline build
|
|
105
|
+
env:
|
|
106
|
+
OGDF_OFFLINE: '1'
|
|
107
|
+
run: |
|
|
108
|
+
uv run python -m ogdf
|
|
109
|
+
uv run pytest tests/ -q
|
|
110
|
+
|
|
65
111
|
windows:
|
|
66
112
|
name: Build & test (Windows)
|
|
67
113
|
runs-on: windows-latest
|
|
@@ -71,10 +117,10 @@ jobs:
|
|
|
71
117
|
# windows-latest ships git, CMake, and MSVC; the bootstrap builds OGDF
|
|
72
118
|
# with the MSVC toolchain into thirdparty/ogdf/build/Release.
|
|
73
119
|
- name: Cache OGDF
|
|
74
|
-
uses: actions/cache@
|
|
120
|
+
uses: actions/cache@v6
|
|
75
121
|
with:
|
|
76
122
|
path: thirdparty/ogdf
|
|
77
|
-
key: ogdf-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/bootstrap_ogdf.py') }}
|
|
123
|
+
key: ogdf-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/bootstrap_ogdf.py', 'scripts/ogdf-tag.txt') }}
|
|
78
124
|
|
|
79
125
|
- name: Bootstrap OGDF
|
|
80
126
|
run: python scripts/bootstrap_ogdf.py
|
|
@@ -88,7 +134,10 @@ jobs:
|
|
|
88
134
|
run: uv python install 3.13
|
|
89
135
|
|
|
90
136
|
- name: Install dependencies (builds the extension)
|
|
91
|
-
run: uv sync
|
|
137
|
+
run: uv sync --dev
|
|
92
138
|
|
|
93
139
|
- name: Run tests
|
|
94
140
|
run: uv run pytest tests/ -v
|
|
141
|
+
|
|
142
|
+
- name: Installation report
|
|
143
|
+
run: uv run python -m ogdf
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- The two `0.5.0` strings in `docs/getting-started.md` are now `0.5.1`, and `make release` rewrites them along with `pyproject.toml`. `test_provenance_example_keys_match` compares the documented `package_version` against the installed one, so a version bump that touches only `pyproject.toml` fails every wheel job at the cibuildwheel test step - after the wheels have already been built.
|
|
12
|
+
|
|
13
|
+
## [0.5.1]
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- The `drawing_metrics` example in `docs/metrics.md` now shows values measured from the snippet as written, and says they are machine-specific. The generators draw through `std::uniform_int_distribution`, whose algorithm the C++ standard leaves to the implementation, so the same seed builds a different graph under libc++ than under libstdc++ - the drawing is not the only thing that moves between platforms. `test_drawing_metrics_example_matches_reality` accordingly checks the key set, the graph size, and the arithmetic between the documented numbers rather than asserting values no other platform can reproduce.
|
|
18
|
+
|
|
19
|
+
- Tests now seed OGDF's engine before each one (`tests/conftest.py`). The engine is process-wide, so a test that generated a random graph without seeding got whatever position the engine was left in by the tests before it - passing under `pytest tests/` and drawing a different graph under `pytest tests/test_x.py` or `--lf`.
|
|
20
|
+
|
|
21
|
+
## [0.5.0]
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
**Results**
|
|
26
|
+
|
|
27
|
+
- Result objects, alongside the existing array-output functions rather than replacing them. `shortest_paths(graph, source, weight=None, *, directed=False, algorithm="auto")` returns a `ShortestPaths` with `distance()`, `path_to()`, `nodes_to()`, `predecessor_edge()`, `reachable()`, `unreachable_nodes()`, and `distances()`. `dijkstra` and `bellman_ford` were already building the shortest-path tree internally and discarding it; this keeps it. Unreachable nodes report `math.inf` and `None` instead of OGDF's raw sentinel, and `algorithm="auto"` picks Bellman-Ford when an `EdgeArrayInt` holds a negative length, Dijkstra otherwise. A reachable negative cycle raises `AlgorithmError` rather than returning meaningless distances.
|
|
28
|
+
|
|
29
|
+
- `min_st_cut` now returns an `STCut` named tuple, so the value and edges are reachable by name (`cut.value`, `cut.edges`) as well as by unpacking. The return shape is unchanged, so existing `value, edges = min_st_cut(...)` code keeps working.
|
|
30
|
+
|
|
31
|
+
- Low-level primitives behind the above: `dijkstra_tree`, `bellman_ford_tree`, and `st_cut`.
|
|
32
|
+
|
|
33
|
+
**Placing a drawing**
|
|
34
|
+
|
|
35
|
+
- Coordinate transforms for placing a finished drawing: `translate`, `center`, `normalize` (lower-left corner to the origin), `scale` (about the centre, the origin, the lower-left corner, or an explicit point), `fit_to_box`, and `pack_components`. Every one moves edge bend points as well as node coordinates, so a drawing produced by a routing layout is not torn apart - which is also why they are implemented natively, since bends are otherwise only reachable through `add_bend` / `clear_bends`.
|
|
36
|
+
|
|
37
|
+
- `scale` leaves node sizes alone by default, since scaling up is usually how overlapping nodes get separated; `scale_node_sizes=True` scales the whole picture. `fit_to_box` preserves aspect ratio, returns the factor it applied, and scales node sizes by default so the fit is exact; with `scale_node_sizes=False` the factor is solved for by bisection rather than estimated, so the fit stays exact while node boxes keep their size.
|
|
38
|
+
|
|
39
|
+
- `pack_components` arranges disconnected components side by side instead of piled at a common origin, binding OGDF's `TileToRowsCCPacker`. Returns the component count and leaves a connected graph untouched.
|
|
40
|
+
|
|
41
|
+
**Measuring a drawing**
|
|
42
|
+
|
|
43
|
+
- Drawing-quality metrics, so layouts can be compared on numbers instead of by eye: `count_crossings`, `edge_lengths`, `bounding_box`, `node_overlaps`, `min_angle` (angular resolution), and `stress`. All are computed over the drawn polylines, so edge bends are respected rather than treated as straight lines.
|
|
44
|
+
|
|
45
|
+
- `drawing_metrics(attributes)` aggregates them into one plain dict - crossings, the edge-length distribution and its scale-free coefficient of variation, width/height/area/aspect ratio, node overlap, angular resolution, and stress - ready to serialize alongside `provenance()`.
|
|
46
|
+
|
|
47
|
+
- `compare_layouts(graph, layouts, *, seed=None)` runs several layouts on one graph, each with a fresh `GraphAttributes`, and returns their metrics ranked by crossings then stress. A layout whose preconditions the graph fails is reported with an `error` key and sorted last instead of aborting the comparison; `seed` makes randomized layouts comparable like for like.
|
|
48
|
+
|
|
49
|
+
**Workflow**
|
|
50
|
+
|
|
51
|
+
- `layout(graph, algorithm=FMMMLayout, **options)` - one call from a graph to a placed drawing, composing precondition checks, seeding, the layout itself, optional component packing, and fit-to-box. The algorithm is a class by default, so it stays completable in an editor and checkable by mypy; a string is accepted for config-driven use, with `layout_names()` listing what resolves. Options are forwarded to the layout's setters through a mechanical `set_X` mapping derived from the bindings, so it cannot drift, and an unknown option raises `TypeError` naming what that layout does accept. Returns the `GraphAttributes`; metrics and provenance are deliberately left as separate calls, since the metrics are quadratic.
|
|
52
|
+
|
|
53
|
+
**Documentation and tests**
|
|
54
|
+
|
|
55
|
+
- Documentation: a Drawing Metrics page explaining what each metric means and how to read it, and the layout selection guide's comparison example now uses `compare_layouts` instead of a hand-rolled loop.
|
|
56
|
+
|
|
57
|
+
- Documented how the metrics read on real drawings: self-loops contribute length 0 (a straight-line drawing gives them no extent), `min_angle` is a worst case that a single pair of collinear edges sends to 0, and `stress` is a sum over node pairs so it grows with the graph and should only be compared between layouts of the same graph.
|
|
58
|
+
|
|
59
|
+
- `tests/test_docs.py` verifies the concrete output values printed in the documentation - the capability counts in the sample installation report, the `drawing_metrics` example, the recipe's build order, and the small inline `# result` comments - by re-deriving each and comparing.
|
|
60
|
+
|
|
61
|
+
- Documentation: a `layout()` section in the getting-started guide, a Placing the drawing section on the metrics page covering the transforms, and a `coverage.md` reorganised so the Python layer lists results, placement, measurement, and workflow as their own groups rather than filing completed work under "not yet provided".
|
|
62
|
+
|
|
63
|
+
### Changed
|
|
64
|
+
|
|
65
|
+
- `min_st_cut` deliberately does **not** report the node partition, and the documentation says why. OGDF's `MinSTCutMaxFlow` exposes `isInFrontCut` / `isInBackCut`, which look like the two sides of the cut but are the extreme minimum cuts nearest the source and nearest the sink. When the minimum cut is not unique those are different cuts, and neither is guaranteed to correspond to the edge list returned alongside them - on the complete digraph on 20 nodes the front cut is `{s}` while the returned edges are the sink's in-edges, so the two together describe no single cut. Callers who need the partition should derive it from the cut edges, which is consistent by construction; a test asserts that removing them really does separate source from sink.
|
|
66
|
+
|
|
67
|
+
- Algorithm docstrings now state provenance and conventions: whether the result is exact, heuristic, or approximate (`node_coloring` is a heuristic upper bound, `steiner_tree` a 2-approximation, `maximal_matching` maximal but not maximum), whether edge direction is honoured, how parallel edges are treated, and what an unreachable node's sentinel is.
|
|
68
|
+
|
|
69
|
+
- `bellman_ford` keeps integer edge lengths while `dijkstra` and `a_star_search` take doubles. This inconsistency is now documented rather than removed: OGDF's `ShortestPathModule` interface is defined over `int` and ships no floating-point Bellman-Ford, so closing the gap would mean reimplementing the algorithm instead of binding one - and the two are not interchangeable anyway, since Dijkstra rejects the negative weights Bellman-Ford exists for. `shortest_paths()` accepts either array type.
|
|
70
|
+
|
|
71
|
+
### Fixed
|
|
72
|
+
|
|
73
|
+
- Two documentation examples stated values that were never produced by running them: the `drawing_metrics` output in `docs/metrics.md` was written by hand rather than measured, and the topological order in the DAG recipe was a valid ordering but not the one the snippet prints. Both are now the real output, and `tests/test_docs.py` checks them.
|
|
74
|
+
|
|
75
|
+
- The capability counts in the sample `python -m ogdf` report had gone stale as more functions were bound (82/18/22 rather than the current 99/19/27).
|
|
76
|
+
|
|
77
|
+
## [0.4.0]
|
|
78
|
+
|
|
79
|
+
### Added
|
|
80
|
+
|
|
81
|
+
- `ogdf.about()` and `ogdf.about_text()` (also `python -m ogdf`): an installation diagnostic reporting the package version, the OGDF version and the pinned OGDF tag the linked static libraries were built from, OGDF's compiled-in configuration (system, LP solver, memory manager), the platform, the compiler, and a count and listing of the available capabilities. The pinned tag is baked in at build time, so the report describes the extension actually loaded.
|
|
82
|
+
|
|
83
|
+
- Offline and locked-down source builds. `scripts/bootstrap_ogdf.py` can now take the OGDF source from a local archive (`--archive`, `OGDF_ARCHIVE`) or an existing checkout (`--source-dir`, `OGDF_SOURCE_DIR`) instead of cloning, and `--offline` / `OGDF_OFFLINE=1` forbids network access outright. CMake accepts `-DOGDF_PREBUILT_DIR=/path/to/ogdf` (or the matching environment variable) to link against a separately built OGDF and skip the bootstrap entirely.
|
|
84
|
+
|
|
85
|
+
- Documented support matrix: which platform/architecture/CPython combinations have wheels, what a source build requires (tools, disk space, expected build time), and the three offline installation paths.
|
|
86
|
+
|
|
87
|
+
- CI coverage for the claims above: an `offline-build` job asserting that an offline bootstrap refuses to clone (and says how to vendor the source) and then builds and tests from a vendored checkout with `OGDF_OFFLINE=1`; and wheel tests that now import the wheel, print its installation report, and run the full suite - including the interop layer, by installing the optional `networkx` dependency.
|
|
88
|
+
|
|
89
|
+
- Exception taxonomy: `OGDFError` and, under it, `PreconditionError` (a `ValueError`), `InvalidGraphError`, `UnsupportedFormatError` (a `ValueError`), and `AlgorithmError` (a `RuntimeError`). The builtin mix-ins keep existing `except ValueError` / `except RuntimeError` code working.
|
|
90
|
+
|
|
91
|
+
- Consistent precondition enforcement. OGDF documents preconditions but compiles its assertions out of a release build, so violating one was undefined behaviour rather than a diagnosable error. Every wrapper with a documented precondition now checks it first: `SchnyderLayout`, `TreeLayout` (forest), `RadialTreeLayout` (tree), `TutteLayout` (triconnected planar), `DominanceLayout` / `VisibilityLayout` (DAG), `SpringEmbedderKK` (connected), `triangulate` (simple, connected, planar *embedded*), `topological_numbering` (DAG), `min_cut`, `maximum_matching_bipartite`, and `spqr_tree_summary`. The bindings additionally reject arrays belonging to a different graph than the one passed in, `None` node arguments, negative weights where the algorithm assumes non-negative ones (`dijkstra`, `a_star_search`, `max_flow`, `min_cut`, `min_st_cut`, `steiner_tree`), and a source equal to its sink.
|
|
92
|
+
|
|
93
|
+
- Validation helpers that report instead of raising: `requirements(name)`, `validate(name, graph)` (the unmet requirements, in check order), `is_valid_for(name, graph)`, `check(name, graph)`, `operations()`, and `graph_report(graph)` - a full structural description of a graph in one call. The requirement table mirrors the compiled-in checks, so the two cannot disagree.
|
|
94
|
+
|
|
95
|
+
- Predicates `is_simple`, `is_simple_undirected`, `has_self_loops`, and `represents_comb_embedding` (whether a planar embedding is currently in place).
|
|
96
|
+
|
|
97
|
+
- Python interoperability layer. `from_edges` / `to_edges` build a graph from - and report it back as - an ordinary edge list, returning a mapping from the caller's own keys to `Node` handles; extra tuple entries are ignored so a weighted `(u, v, w)` list works unchanged, and parallel edges and self-loops are preserved.
|
|
98
|
+
|
|
99
|
+
- `from_networkx` / `to_networkx` for all four NetworkX classes, with explicit handling of directedness, multiedges, node identity, and layout coordinates. `from_networkx(graph_attributes=True)` also returns a `GraphAttributes` whose `directed` flag matches the input and can copy a NetworkX node attribute into the node labels; `to_networkx` picks a lossless NetworkX class by default and copies `x`, `y`, `width`, `height`, and `label` back out, making a laid-out OGDF drawing directly plottable. NetworkX is an optional dependency, imported lazily.
|
|
100
|
+
|
|
101
|
+
- Array conversion helpers: `node_array_to_dict`, `edge_array_to_dict`, `node_array_to_list`, `edge_array_to_list`, `fill_node_array`, and `fill_edge_array` - keyed by `node.index` / `edge.index` by default, or by a caller-supplied mapping, with a documented node-identity policy.
|
|
102
|
+
|
|
103
|
+
- Result helpers `nodes_where` and `edges_where`, which turn the boolean-array output convention into ordinary Python lists of nodes or edges (a spanning tree, a matching, a cut).
|
|
104
|
+
|
|
105
|
+
- `GraphAttributes.graph` (the graph being described), `GraphAttributes.has(flags)` (whether an attribute group is enabled before reading it), and a readable/writable `GraphAttributes.directed`.
|
|
106
|
+
|
|
107
|
+
- Reproducibility. `set_seed`, `get_seed`, `new_seed`, and the `seeded(n)` context manager wrap OGDF's process-wide random engine, making every stochastic generator, layout, and heuristic reproducible from a recorded seed. `provenance(**settings)` returns JSON-serializable metadata - seed, package version, OGDF version and pinned tag, platform, and the algorithm settings passed in - to store alongside a result. Documented what is and is not guaranteed: same seed and same build reproduce a result exactly; across platforms, compilers, or OGDF versions they do not.
|
|
108
|
+
|
|
109
|
+
- Heuristic algorithms now report their achieved objective value: `SugiyamaLayout.number_of_crossings()` and `.number_of_levels()`, and `PlanarizationLayout.number_of_crossings()`, so runs and seeds can be compared numerically.
|
|
110
|
+
|
|
111
|
+
- Reproducibility tests asserting that a seed reproduces both the generated graph and its coordinates, and that different seeds diverge.
|
|
112
|
+
|
|
113
|
+
- Documentation: a layout selection guide (`docs/choosing-a-layout.md`) organising all nineteen layouts by graph structure, constraint, scale, and intended output, with guidance on directedness, disconnected graphs, multigraphs, determinism, and how to compare candidates numerically; and four end-to-end recipes (`docs/recipes.md`) - NetworkX to SVG, DAG to layered SVG, planar graph to TikZ, and a weighted graph to an annotated drawing. Every recipe is executed by `tests/test_recipes.py` so it cannot silently rot.
|
|
114
|
+
|
|
115
|
+
- Low-level `seed_random_engine` and `draw_random_seed` bindings, wrapped by `set_seed` / `new_seed`.
|
|
116
|
+
|
|
117
|
+
- Tests for invalid, empty, disconnected, cyclic, non-planar, non-bipartite, negative-weight, cross-graph-array, and duplicate-endpoint inputs.
|
|
118
|
+
|
|
119
|
+
### Changed
|
|
120
|
+
|
|
121
|
+
- `docs/coverage.md` now records the Python layer that is not a binding of anything - diagnostics, the exception taxonomy, interoperability, and reproducibility - alongside the OGDF inventory, and its priority roadmap names result ergonomics as the next item: `dijkstra` and `bellman_ford` already compute predecessor arrays internally and discard them, `max_flow` reports no source-side partition, and `bellman_ford`'s integer edge lengths are still inconsistent with the `double` weights used by `dijkstra` and `a_star_search`.
|
|
122
|
+
|
|
123
|
+
- `__version__` is single-sourced from the installed distribution metadata (falling back to the version CMake compiled into the extension) instead of being duplicated in `src/ogdf/__init__.py`. Both derive from `pyproject.toml`, and `tests/test_about.py` asserts they agree, so a stale extension now fails the suite.
|
|
124
|
+
|
|
125
|
+
- Build failures now identify the failing stage. The bootstrap distinguishes a missing tool, a failed source fetch, a failed CMake configuration (typically no C++17 compiler), and a failed compilation; CMake names which of the OGDF and COIN static libraries is missing and tailors the remedy to whether a prebuilt tree or offline mode was requested.
|
|
126
|
+
|
|
127
|
+
- The pinned OGDF tag now lives in a single place, `scripts/ogdf-tag.txt`, read by both the bootstrap script and CMake, so the tag reported by `ogdf.about()` cannot drift from the libraries that were linked.
|
|
128
|
+
|
|
129
|
+
## [0.3.0]
|
|
130
|
+
|
|
131
|
+
### Added
|
|
132
|
+
|
|
133
|
+
- Planar layouts: `FPPLayout`, `PlanarStraightLayout`, `PlanarDrawLayout`, and `MixedModelLayout` - straight-line and mixed-model planar grid drawings, completing the planar-drawing family alongside `SchnyderLayout`. Each validates that the input is a simple planar graph with at least 3 nodes.
|
|
134
|
+
|
|
135
|
+
- Shortest paths: `a_star_search`, point-to-point A* with an optional admissible heuristic; returns the path length and edges, or `None` if the target is unreachable.
|
|
136
|
+
|
|
137
|
+
- Crossing minimization: `crossing_number` (heuristic minimum crossings via the subgraph planarizer) and `insert_edges` (routes a chosen set of edges through the otherwise-planar rest of the graph and returns, per edge, the original edges it crosses).
|
|
138
|
+
|
|
139
|
+
- Flow / cut and connectivity: `min_st_cut` (directed or undirected s-t minimum cut, returning the value and the cut edges) and `node_connectivity` / `edge_connectivity` (global and local/Menger k-connectivity).
|
|
140
|
+
|
|
141
|
+
- Documentation: expanded the coverage checklist with a priority roadmap.
|
|
142
|
+
|
|
143
|
+
## [0.2.0]
|
|
144
|
+
|
|
145
|
+
### Added
|
|
146
|
+
|
|
147
|
+
- Layouts: `RadialTreeLayout`, `LinearLayout` (arc diagram), `TutteLayout` (convex planar), `DominanceLayout` / `VisibilityLayout` (upward, for DAGs), `MultilevelLayout` / `ModularMultilevelMixer` (large graphs), and `BalloonLayout`.
|
|
148
|
+
|
|
149
|
+
- Algorithms: cut vertices (`cut_vertices`) and bridges (`bridges`), Bellman-Ford shortest paths (`bellman_ford`), minimum-cost flow (`min_cost_flow`), general maximum-weight matching (`maximum_weight_matching`, Blossom V), minimum Steiner tree (`steiner_tree`, Mehlhorn), maximal planar subgraph (`maximal_planar_subgraph`), and triconnectivity via `separation_pair` and `spqr_tree_summary`.
|
|
150
|
+
|
|
151
|
+
- Cross-platform Python bootstrap (`scripts/bootstrap_ogdf.py`) replacing the bash script; generalized CMake linking (MSVC-aware); Windows build+test CI job.
|
|
152
|
+
|
|
153
|
+
- MkDocs documentation site (`docs/`) with a coverage checklist and a Gallery page rendering the demo drawings; `make docs`, `make docs-serve`, `make docs-deploy`.
|
|
154
|
+
|
|
155
|
+
- Demos: gallery entries for the new layouts, and algorithm visualizations for cut vertices/bridges, maximum-weight matching, Bellman-Ford distances, minimum-cost flow, the minimum Steiner tree, and the maximal planar subgraph.
|
|
156
|
+
|
|
157
|
+
- Generators: circulant, complete-k-partite, globe, regular-lattice; graph products (cartesian, tensor, strong, lexicographical); operations (union, complement, suspension); and random models (preferential attachment, Chung-Lu, Watts-Strogatz, Waxman, geometric-cube, hierarchy, series-parallel DAG, triconnected, planar-biconnected, planar-triconnected).
|
|
158
|
+
|
|
159
|
+
- Predicates and small algorithms: `is_two_edge_connected`, `is_regular`, `is_arborescence`, `triangulate`, `make_bimodal`, and `bfs_distances` (unweighted single-source distances).
|
|
160
|
+
|
|
161
|
+
- Windows support: the release workflow now builds Windows (AMD64) wheels alongside Linux and macOS, and the wheel matrix covers CPython 3.10-3.14.
|
|
162
|
+
|
|
163
|
+
### Fixed
|
|
164
|
+
|
|
165
|
+
- Removed the persistent CMake `build-dir` from `pyproject.toml`. Sharing it between editable installs and wheel builds could leave stale objects, so a `uv build --wheel` sometimes omitted recently-added functions. Each build now uses a fresh directory (OGDF is prebuilt, so this stays fast).
|
|
166
|
+
|
|
167
|
+
- MSVC build: replaced the non-standard `M_PI` (undefined on MSVC) with an explicit constant so the extension compiles on Windows.
|
|
168
|
+
|
|
169
|
+
## [0.1.1]
|
|
170
|
+
|
|
171
|
+
### Added
|
|
172
|
+
|
|
173
|
+
- OGDF bindings (curated subset): `Graph`/`Node`/`Edge` with iteration; `NodeArray`/`EdgeArray` in int/double/bool; `GraphAttributes` with coordinates, size, labels, and styling (colors, shapes, fill patterns, stroke, edge arrows, bends).
|
|
174
|
+
|
|
175
|
+
- Layout algorithms: `SugiyamaLayout`, `FMMMLayout`, `GEMLayout`, `SpringEmbedderKK`, `StressMinimization`, `PivotMDS`, `PlanarizationLayout` (with optional orthogonal routing), `SchnyderLayout`, `TreeLayout`, `CircularLayout`.
|
|
176
|
+
|
|
177
|
+
- Core graph algorithms: connectivity/structure predicates, connected / strong / biconnected components, topological numbering, Dijkstra shortest paths, minimum spanning tree, maximum flow, global minimum cut, matching, node coloring, and planar embedding.
|
|
178
|
+
|
|
179
|
+
- Graph generators: complete, complete-bipartite, wheel, cube, grid, Petersen, regular tree, plus random graphs, trees, digraphs, and regular / biconnected / planar variants.
|
|
180
|
+
|
|
181
|
+
- File I/O: interchange formats GML, GraphML, DOT, GEXF, GDF, TLP (with extension-based `read`/`write`) and drawing output as SVG and TikZ.
|
|
182
|
+
|
|
183
|
+
- `demos/` folder with illustrative scripts (layout gallery, styling showcase, algorithm visualizations, generator zoo, I/O round-trips) writing to `build/demo-output`; `make demos` also builds a self-contained HTML gallery (`index.html`) of every drawing.
|
|
184
|
+
|
|
185
|
+
- Bindings split into modular translation units (`bind_graph`, `bind_layouts`, `bind_algorithms`, `bind_io`, `bind_generators`).
|
|
186
|
+
|
|
187
|
+
- Auto-generated `_core.pyi` type stub for typed usage and IDE completion.
|
|
188
|
+
|
|
189
|
+
- `cibuildwheel` release workflow building CPython 3.10-3.13 wheels for Linux (x86_64, aarch64) and macOS (x86_64, arm64) on native runners, bootstrapping OGDF once per platform; trusted-publishing jobs for TestPyPI/PyPI on tags.
|
|
190
|
+
|
|
191
|
+
- CMake auto-bootstraps OGDF if missing, so `pip install` from an sdist works without a manual step (Unix only).
|
|
192
|
+
|
|
193
|
+
### Changed
|
|
194
|
+
|
|
195
|
+
- Reproducible OGDF dependency: `scripts/bootstrap_ogdf.py` (cross-platform: Linux, macOS, Windows) shallow-clones OGDF at a pinned tag (`foxglove-202510`) and builds its static libraries from source; the extension links them. `make build`/`make sync` auto-bootstrap if needed. Replaces reliance on a manually placed OGDF checkout.
|
|
196
|
+
|
|
197
|
+
- Persist the CMake build directory so only the bindings recompile on edits.
|
|
198
|
+
|
|
199
|
+
### Fixed
|
|
200
|
+
|
|
201
|
+
- `make build` targeted the wrong package name (`ogdf` vs `ogdf-py`), making it a silent no-op; it now rebuilds correctly.
|
|
202
|
+
|
|
203
|
+
- The generic `write` now raises `ValueError` for attribute-incapable formats (e.g. LEDA, Chaco) instead of crashing the interpreter.
|
|
204
|
+
|
|
205
|
+
## [0.1.0]
|
|
206
|
+
|
|
207
|
+
### Added
|
|
208
|
+
|
|
209
|
+
- Initial project structure
|
|
210
|
+
|
|
211
|
+
- Core module with example functions
|
|
212
|
+
|
|
213
|
+
- Test suite with pytest
|
|
214
|
+
|
|
215
|
+
- Build system using scikit-build-core
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.15...3.31)
|
|
2
|
+
project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
5
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
6
|
+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
7
|
+
|
|
8
|
+
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
|
|
9
|
+
find_package(nanobind CONFIG REQUIRED)
|
|
10
|
+
find_package(Threads REQUIRED)
|
|
11
|
+
|
|
12
|
+
# --- OGDF (prebuilt static libraries) ---------------------------------------
|
|
13
|
+
# OGDF is cloned at a pinned tag and built from source by
|
|
14
|
+
# scripts/bootstrap_ogdf.py, which produces the OGDF/COIN static libraries and
|
|
15
|
+
# the generated config header. We link those static libs into the extension.
|
|
16
|
+
#
|
|
17
|
+
# For offline / locked-down / reproducible builds, point OGDF_PREBUILT_DIR at an
|
|
18
|
+
# OGDF tree that has already been built (it must contain include/ and a build/
|
|
19
|
+
# with the static libraries), either as -DOGDF_PREBUILT_DIR=... or via the
|
|
20
|
+
# environment. Setting OGDF_OFFLINE=1 disables the automatic git clone so a
|
|
21
|
+
# missing dependency fails fast with an explanation instead of hitting the
|
|
22
|
+
# network.
|
|
23
|
+
if(NOT OGDF_PREBUILT_DIR AND DEFINED ENV{OGDF_PREBUILT_DIR})
|
|
24
|
+
set(OGDF_PREBUILT_DIR "$ENV{OGDF_PREBUILT_DIR}")
|
|
25
|
+
endif()
|
|
26
|
+
|
|
27
|
+
if(OGDF_PREBUILT_DIR)
|
|
28
|
+
set(OGDF_ROOT "${OGDF_PREBUILT_DIR}")
|
|
29
|
+
if(NOT EXISTS "${OGDF_ROOT}/include/ogdf")
|
|
30
|
+
message(FATAL_ERROR
|
|
31
|
+
"OGDF_PREBUILT_DIR=${OGDF_ROOT} does not look like an OGDF tree "
|
|
32
|
+
"(no include/ogdf). Point it at the root of a built OGDF checkout.")
|
|
33
|
+
endif()
|
|
34
|
+
message(STATUS "Using prebuilt OGDF from ${OGDF_ROOT}")
|
|
35
|
+
else()
|
|
36
|
+
set(OGDF_ROOT "${CMAKE_SOURCE_DIR}/thirdparty/ogdf")
|
|
37
|
+
endif()
|
|
38
|
+
set(OGDF_BUILD "${OGDF_ROOT}/build")
|
|
39
|
+
|
|
40
|
+
# The pinned OGDF tag, kept in one place (scripts/ogdf-tag.txt) so the bootstrap
|
|
41
|
+
# script and the compiled-in value reported by ogdf.about() cannot drift apart.
|
|
42
|
+
set(OGDF_PINNED_TAG "unknown")
|
|
43
|
+
if(EXISTS "${CMAKE_SOURCE_DIR}/scripts/ogdf-tag.txt")
|
|
44
|
+
file(READ "${CMAKE_SOURCE_DIR}/scripts/ogdf-tag.txt" OGDF_PINNED_TAG)
|
|
45
|
+
string(STRIP "${OGDF_PINNED_TAG}" OGDF_PINNED_TAG)
|
|
46
|
+
endif()
|
|
47
|
+
|
|
48
|
+
# Locate the prebuilt OGDF/COIN static libraries produced by
|
|
49
|
+
# scripts/bootstrap_ogdf.py. Search both the single-config location and the
|
|
50
|
+
# multi-config Release/ subdirectory (used by MSVC and Xcode), and match both
|
|
51
|
+
# the Unix (libOGDF.a) and MSVC (OGDF.lib) naming.
|
|
52
|
+
set(_ogdf_lib_dirs "${OGDF_BUILD}" "${OGDF_BUILD}/Release")
|
|
53
|
+
find_library(OGDF_LIBRARY NAMES OGDF libOGDF PATHS ${_ogdf_lib_dirs}
|
|
54
|
+
NO_DEFAULT_PATH)
|
|
55
|
+
|
|
56
|
+
# If OGDF has not been built yet, bootstrap it automatically (fetch the pinned
|
|
57
|
+
# tag + build from source), then search again. This lets `pip install` from an
|
|
58
|
+
# sdist work without a separate manual step. Uses the interpreter CMake found.
|
|
59
|
+
# Skipped when a prebuilt tree was supplied explicitly.
|
|
60
|
+
set(_ogdf_offline OFF)
|
|
61
|
+
if(DEFINED ENV{OGDF_OFFLINE} AND NOT "$ENV{OGDF_OFFLINE}" STREQUAL "0")
|
|
62
|
+
set(_ogdf_offline ON)
|
|
63
|
+
endif()
|
|
64
|
+
|
|
65
|
+
if(NOT OGDF_LIBRARY AND NOT OGDF_PREBUILT_DIR
|
|
66
|
+
AND EXISTS "${CMAKE_SOURCE_DIR}/scripts/bootstrap_ogdf.py")
|
|
67
|
+
message(STATUS "OGDF not built; running scripts/bootstrap_ogdf.py ...")
|
|
68
|
+
execute_process(
|
|
69
|
+
COMMAND "${Python_EXECUTABLE}"
|
|
70
|
+
"${CMAKE_SOURCE_DIR}/scripts/bootstrap_ogdf.py"
|
|
71
|
+
RESULT_VARIABLE _ogdf_bootstrap_result)
|
|
72
|
+
if(NOT _ogdf_bootstrap_result EQUAL 0)
|
|
73
|
+
message(FATAL_ERROR
|
|
74
|
+
"OGDF bootstrap failed (exit ${_ogdf_bootstrap_result}).\n"
|
|
75
|
+
"The bootstrap output above names the failing stage (source fetch, "
|
|
76
|
+
"CMake configuration, or compilation). Building OGDF from source "
|
|
77
|
+
"needs git, CMake >= 3.15, a C++17 compiler, network access, and "
|
|
78
|
+
"roughly 2 GB of free disk space.\n"
|
|
79
|
+
"For an offline build, vendor the source and set OGDF_ARCHIVE or "
|
|
80
|
+
"OGDF_SOURCE_DIR, or build OGDF separately and configure this "
|
|
81
|
+
"project with -DOGDF_PREBUILT_DIR=/path/to/ogdf.")
|
|
82
|
+
endif()
|
|
83
|
+
unset(OGDF_LIBRARY CACHE)
|
|
84
|
+
find_library(OGDF_LIBRARY NAMES OGDF libOGDF PATHS ${_ogdf_lib_dirs}
|
|
85
|
+
NO_DEFAULT_PATH)
|
|
86
|
+
endif()
|
|
87
|
+
|
|
88
|
+
find_library(COIN_LIBRARY NAMES COIN libCOIN PATHS ${_ogdf_lib_dirs}
|
|
89
|
+
NO_DEFAULT_PATH)
|
|
90
|
+
|
|
91
|
+
# Name the specific missing piece: OGDF and COIN are built by the same command,
|
|
92
|
+
# so having one but not the other means a partial or mismatched build tree.
|
|
93
|
+
if(NOT OGDF_LIBRARY OR NOT COIN_LIBRARY)
|
|
94
|
+
set(_ogdf_missing "")
|
|
95
|
+
if(NOT OGDF_LIBRARY)
|
|
96
|
+
list(APPEND _ogdf_missing "OGDF")
|
|
97
|
+
endif()
|
|
98
|
+
if(NOT COIN_LIBRARY)
|
|
99
|
+
list(APPEND _ogdf_missing "COIN")
|
|
100
|
+
endif()
|
|
101
|
+
string(REPLACE ";" " and " _ogdf_missing "${_ogdf_missing}")
|
|
102
|
+
if(OGDF_PREBUILT_DIR)
|
|
103
|
+
message(FATAL_ERROR
|
|
104
|
+
"Prebuilt ${_ogdf_missing} static librar(y/ies) not found under "
|
|
105
|
+
"${OGDF_BUILD}.\n"
|
|
106
|
+
"OGDF_PREBUILT_DIR must point at an OGDF tree that has already been "
|
|
107
|
+
"built with OGDF_LIBRARY_TARGETS_ONLY=ON and "
|
|
108
|
+
"CMAKE_POSITION_INDEPENDENT_CODE=ON.")
|
|
109
|
+
elseif(_ogdf_offline)
|
|
110
|
+
message(FATAL_ERROR
|
|
111
|
+
"Prebuilt ${_ogdf_missing} static librar(y/ies) not found under "
|
|
112
|
+
"${OGDF_BUILD}, and OGDF_OFFLINE is set so no source was fetched.\n"
|
|
113
|
+
"Vendor the OGDF source and run:\n"
|
|
114
|
+
" python scripts/bootstrap_ogdf.py --archive /path/to/ogdf-src.tar.gz\n"
|
|
115
|
+
"or configure with -DOGDF_PREBUILT_DIR=/path/to/prebuilt/ogdf.")
|
|
116
|
+
else()
|
|
117
|
+
message(FATAL_ERROR
|
|
118
|
+
"Prebuilt ${_ogdf_missing} static librar(y/ies) not found under "
|
|
119
|
+
"${OGDF_BUILD}.\n"
|
|
120
|
+
"Run the bootstrap first:\n"
|
|
121
|
+
" python scripts/bootstrap_ogdf.py\n"
|
|
122
|
+
"(or `make bootstrap`), which fetches OGDF at the pinned tag "
|
|
123
|
+
"(${OGDF_PINNED_TAG}) and builds it.")
|
|
124
|
+
endif()
|
|
125
|
+
endif()
|
|
126
|
+
|
|
127
|
+
# Public headers plus the build-time generated config header
|
|
128
|
+
# (config_autogen.h lives under build/include/ogdf-release).
|
|
129
|
+
set(OGDF_INCLUDE_DIRS
|
|
130
|
+
"${OGDF_ROOT}/include"
|
|
131
|
+
"${OGDF_BUILD}/include/ogdf-release")
|
|
132
|
+
|
|
133
|
+
set(OGDF_LIBRARIES ${OGDF_LIBRARY} ${COIN_LIBRARY} Threads::Threads)
|
|
134
|
+
|
|
135
|
+
nanobind_add_module(_core
|
|
136
|
+
src/ogdf/_core.cpp
|
|
137
|
+
src/ogdf/bind_errors.cpp
|
|
138
|
+
src/ogdf/bind_graph.cpp
|
|
139
|
+
src/ogdf/bind_layouts.cpp
|
|
140
|
+
src/ogdf/bind_algorithms.cpp
|
|
141
|
+
src/ogdf/bind_io.cpp
|
|
142
|
+
src/ogdf/bind_generators.cpp
|
|
143
|
+
src/ogdf/bind_transforms.cpp
|
|
144
|
+
src/ogdf/bind_metrics.cpp
|
|
145
|
+
src/ogdf/bind_meta.cpp)
|
|
146
|
+
|
|
147
|
+
target_include_directories(_core PRIVATE ${OGDF_INCLUDE_DIRS})
|
|
148
|
+
|
|
149
|
+
# Build provenance reported by ogdf.about(): the package version and the
|
|
150
|
+
# pinned OGDF tag the linked static libraries were built from.
|
|
151
|
+
target_compile_definitions(_core PRIVATE
|
|
152
|
+
OGDFPY_VERSION="${PROJECT_VERSION}"
|
|
153
|
+
OGDFPY_OGDF_TAG="${OGDF_PINNED_TAG}")
|
|
154
|
+
target_link_libraries(_core PRIVATE ${OGDF_LIBRARIES})
|
|
155
|
+
|
|
156
|
+
if(MSVC)
|
|
157
|
+
target_compile_options(_core PRIVATE /W4)
|
|
158
|
+
else()
|
|
159
|
+
target_compile_options(_core PRIVATE -Wall -Wextra)
|
|
160
|
+
endif()
|
|
161
|
+
|
|
162
|
+
install(TARGETS _core DESTINATION ogdf)
|
|
163
|
+
|
|
164
|
+
# Generate a type stub (_core.pyi) so the compiled module is typed for mypy and
|
|
165
|
+
# IDEs. nanobind imports the built module and introspects it at build time.
|
|
166
|
+
nanobind_add_stub(
|
|
167
|
+
_core_stub
|
|
168
|
+
MODULE _core
|
|
169
|
+
OUTPUT _core.pyi
|
|
170
|
+
PYTHON_PATH $<TARGET_FILE_DIR:_core>
|
|
171
|
+
DEPENDS _core
|
|
172
|
+
)
|
|
173
|
+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/_core.pyi DESTINATION ogdf)
|
|
174
|
+
|
|
175
|
+
# Ship py.typed alongside the compiled module + stub. In an editable install the
|
|
176
|
+
# pure-Python files (including src/ogdf/py.typed) stay in the source tree, so
|
|
177
|
+
# without this the site-packages ogdf/ dir has _core.pyi but no py.typed marker,
|
|
178
|
+
# and mypy refuses to use the stub.
|
|
179
|
+
install(FILES ${CMAKE_SOURCE_DIR}/src/ogdf/py.typed DESTINATION ogdf)
|
|
@@ -117,7 +117,7 @@ docs-deploy: demos
|
|
|
117
117
|
# Create a release (bump version, tag, push)
|
|
118
118
|
release:
|
|
119
119
|
@echo "Current version: $$(grep '^version' pyproject.toml | head -1)"
|
|
120
|
-
@read -p "New version: " version; sed "s/^version = .*/version = \"$$version\"/" pyproject.toml > pyproject.toml.tmp && mv pyproject.toml.tmp pyproject.toml; git add pyproject.toml; git commit -m "Bump version to $$version"; git tag -a "v$$version" -m "Release $$version"; echo "Tagged v$$version. Run 'git push && git push --tags' to publish."
|
|
120
|
+
@read -p "New version: " version; sed "s/^version = .*/version = \"$$version\"/" pyproject.toml > pyproject.toml.tmp && mv pyproject.toml.tmp pyproject.toml; sed -E "s/(package version *: ).*/\1$$version/; s/('package_version': ')[^']*'/\1$$version'/" docs/getting-started.md > docs/getting-started.md.tmp && mv docs/getting-started.md.tmp docs/getting-started.md; git add pyproject.toml docs/getting-started.md; git commit -m "Bump version to $$version"; git tag -a "v$$version" -m "Release $$version"; echo "Tagged v$$version. Run 'git push && git push --tags' to publish."
|
|
121
121
|
|
|
122
122
|
# Clean build artifacts
|
|
123
123
|
clean:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ogdf-py
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: Python bindings for the Open Graph Drawing Framework (OGDF), built with nanobind.
|
|
5
5
|
Keywords: nanobind,python,extension
|
|
6
6
|
Author-Email: Shakeeb Alireza <shakfu@users.noreply.github.com>
|
|
@@ -70,9 +70,9 @@ n = ogdf.connected_components(g, component) # -> number of components
|
|
|
70
70
|
|
|
71
71
|
- **Attributes:** `GraphAttributes` with coordinates, size, labels, and full styling (colors, shapes, fill patterns, stroke, edge arrows, and bends).
|
|
72
72
|
|
|
73
|
-
- **Layouts:** `SugiyamaLayout` (layered), `FMMMLayout` / `GEMLayout` / `SpringEmbedderKK` / `MultilevelLayout` (force-directed), `StressMinimization` / `PivotMDS` (stress/MDS), `PlanarizationLayout` (with optional orthogonal routing), `SchnyderLayout` (planar straight-line), `TreeLayout` / `RadialTreeLayout` / `BalloonLayout`, `CircularLayout`, `LinearLayout` (arc diagram), `TutteLayout` (convex planar), and `DominanceLayout` / `VisibilityLayout` (upward, for DAGs).
|
|
73
|
+
- **Layouts:** `SugiyamaLayout` (layered), `FMMMLayout` / `GEMLayout` / `SpringEmbedderKK` / `MultilevelLayout` (force-directed), `StressMinimization` / `PivotMDS` (stress/MDS), `PlanarizationLayout` (with optional orthogonal routing), `SchnyderLayout` / `FPPLayout` / `PlanarStraightLayout` / `PlanarDrawLayout` / `MixedModelLayout` (planar straight-line and mixed-model), `TreeLayout` / `RadialTreeLayout` / `BalloonLayout`, `CircularLayout`, `LinearLayout` (arc diagram), `TutteLayout` (convex planar), and `DominanceLayout` / `VisibilityLayout` (upward, for DAGs).
|
|
74
74
|
|
|
75
|
-
- **Algorithms:** connectivity and structure tests (`is_connected`, `is_biconnected`, `is_bipartite`, `is_acyclic`, `is_planar`, ...), components, cut vertices and bridges, separation pairs and SPQR-tree summary, topological numbering, shortest paths (`dijkstra`, `bellman_ford`), minimum spanning tree, maximum flow, minimum-cost flow, global minimum cut, matching (bipartite and maximum-weight), node coloring, minimum Steiner tree, maximal planar subgraph, and
|
|
75
|
+
- **Algorithms:** connectivity and structure tests (`is_connected`, `is_biconnected`, `is_bipartite`, `is_acyclic`, `is_planar`, ...), node/edge k-connectivity (`node_connectivity`, `edge_connectivity`), components, cut vertices and bridges, separation pairs and SPQR-tree summary, topological numbering, shortest paths (`dijkstra`, `bellman_ford`, `a_star_search`), minimum spanning tree, maximum flow, minimum-cost flow, global minimum cut and s-t minimum cut (`min_st_cut`), matching (bipartite and maximum-weight), node coloring, minimum Steiner tree, planar embedding, maximal planar subgraph, crossing minimization (`crossing_number`), and edge-insertion routing (`insert_edges`).
|
|
76
76
|
|
|
77
77
|
- **Generators:** classic graphs (complete, bipartite, wheel, cube, grid, Petersen, circulant, k-partite, globe, lattice), graph products (cartesian, tensor, strong, lexicographical), operations (union, complement, suspension), and random models (Erdos-Renyi, regular, planar, triconnected, Watts-Strogatz, preferential attachment, Chung-Lu, Waxman, geometric, series-parallel DAG, hierarchy).
|
|
78
78
|
|
|
@@ -51,9 +51,9 @@ n = ogdf.connected_components(g, component) # -> number of components
|
|
|
51
51
|
|
|
52
52
|
- **Attributes:** `GraphAttributes` with coordinates, size, labels, and full styling (colors, shapes, fill patterns, stroke, edge arrows, and bends).
|
|
53
53
|
|
|
54
|
-
- **Layouts:** `SugiyamaLayout` (layered), `FMMMLayout` / `GEMLayout` / `SpringEmbedderKK` / `MultilevelLayout` (force-directed), `StressMinimization` / `PivotMDS` (stress/MDS), `PlanarizationLayout` (with optional orthogonal routing), `SchnyderLayout` (planar straight-line), `TreeLayout` / `RadialTreeLayout` / `BalloonLayout`, `CircularLayout`, `LinearLayout` (arc diagram), `TutteLayout` (convex planar), and `DominanceLayout` / `VisibilityLayout` (upward, for DAGs).
|
|
54
|
+
- **Layouts:** `SugiyamaLayout` (layered), `FMMMLayout` / `GEMLayout` / `SpringEmbedderKK` / `MultilevelLayout` (force-directed), `StressMinimization` / `PivotMDS` (stress/MDS), `PlanarizationLayout` (with optional orthogonal routing), `SchnyderLayout` / `FPPLayout` / `PlanarStraightLayout` / `PlanarDrawLayout` / `MixedModelLayout` (planar straight-line and mixed-model), `TreeLayout` / `RadialTreeLayout` / `BalloonLayout`, `CircularLayout`, `LinearLayout` (arc diagram), `TutteLayout` (convex planar), and `DominanceLayout` / `VisibilityLayout` (upward, for DAGs).
|
|
55
55
|
|
|
56
|
-
- **Algorithms:** connectivity and structure tests (`is_connected`, `is_biconnected`, `is_bipartite`, `is_acyclic`, `is_planar`, ...), components, cut vertices and bridges, separation pairs and SPQR-tree summary, topological numbering, shortest paths (`dijkstra`, `bellman_ford`), minimum spanning tree, maximum flow, minimum-cost flow, global minimum cut, matching (bipartite and maximum-weight), node coloring, minimum Steiner tree, maximal planar subgraph, and
|
|
56
|
+
- **Algorithms:** connectivity and structure tests (`is_connected`, `is_biconnected`, `is_bipartite`, `is_acyclic`, `is_planar`, ...), node/edge k-connectivity (`node_connectivity`, `edge_connectivity`), components, cut vertices and bridges, separation pairs and SPQR-tree summary, topological numbering, shortest paths (`dijkstra`, `bellman_ford`, `a_star_search`), minimum spanning tree, maximum flow, minimum-cost flow, global minimum cut and s-t minimum cut (`min_st_cut`), matching (bipartite and maximum-weight), node coloring, minimum Steiner tree, planar embedding, maximal planar subgraph, crossing minimization (`crossing_number`), and edge-insertion routing (`insert_edges`).
|
|
57
57
|
|
|
58
58
|
- **Generators:** classic graphs (complete, bipartite, wheel, cube, grid, Petersen, circulant, k-partite, globe, lattice), graph products (cartesian, tensor, strong, lexicographical), operations (union, complement, suspension), and random models (Erdos-Renyi, regular, planar, triconnected, Watts-Strogatz, preferential attachment, Chung-Lu, Waxman, geometric, series-parallel DAG, hierarchy).
|
|
59
59
|
|
|
@@ -20,15 +20,19 @@ uv run python demos/layouts_gallery.py
|
|
|
20
20
|
|
|
21
21
|
- **`layouts_gallery.py`** - renders graphs with every layout algorithm
|
|
22
22
|
(Sugiyama, FMMM, GEM, Kamada-Kawai, stress minimization, pivot MDS, Schnyder,
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
FPP, planar-straight, planar-draw, mixed-model, circular, tree, radial tree,
|
|
24
|
+
linear/arc, Tutte, dominance, visibility, multilevel, modular multilevel
|
|
25
|
+
mixer, balloon, and orthogonal), one SVG per layout.
|
|
25
26
|
- **`styling_showcase.py`** - a wheel graph styled with per-degree node colors,
|
|
26
27
|
ellipse shapes, sizes, labels, and edge arrows.
|
|
27
|
-
- **`algorithms_visual.py`** - visualizes algorithm results by coloring
|
|
28
|
-
connected
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
and
|
|
28
|
+
- **`algorithms_visual.py`** - visualizes algorithm results by coloring nodes
|
|
29
|
+
and edges: connected / strongly-connected / biconnected components, a proper
|
|
30
|
+
node coloring, Dijkstra and A* shortest paths, Bellman-Ford distances,
|
|
31
|
+
topological numbering, a minimum spanning tree, minimum-cost flow, s-t minimum
|
|
32
|
+
cut (with max flow), cut vertices and bridges, node/edge k-connectivity,
|
|
33
|
+
triconnectivity (separation pair and SPQR summary), a maximum-weight matching,
|
|
34
|
+
a minimum Steiner tree, the maximal planar subgraph, and crossing minimization
|
|
35
|
+
(crossing number and edge-insertion routing).
|
|
32
36
|
- **`generators_zoo.py`** - builds a variety of named graphs (complete,
|
|
33
37
|
bipartite, wheel, cube, grid, Petersen, trees, random regular) and draws each.
|
|
34
38
|
- **`io_roundtrip.py`** - writes a graph to GML, GraphML, DOT, GEXF, TLP, SVG,
|