Node Labeling
This repository implements a two-phase algorithm for labeling line diagrams of ordered sets.
Usage
Install via PyPI
Install the package from PyPI using pip.
pip install node-labeling
Execute the layout generation using the node-labeling command.
node-labeling
Install from source
Clone the repository and initialize the environment. uv will automatically create a virtual environment and sync dependencies based on the pyproject.toml.
uv sync
Execute the layout generation using uv run to ensure the correct environment context.
uv run node-labeling
The script will prompt you for a path to a .graphml file. Each node needs x/y position data,
and optionally general data as a plain string and extent/intent label data (;-separated
names).
To export the final layout to a PDF add the --export flag.
uv run node-labeling --export
The --export flag also works with the PyPI install:
node-labeling --export
Use as a library
Node Labeling can also be called directly from Python via node_labeling.label.
from node_labeling import label
# graphml is a path to a .graphml file
labels = label('path/to/graph.graphml')
By default label returns the final label placement for every node as a dict mapping label id to
LabelCandidate. Pass export=True to instead write the final layout to a PDF in figs/.
label('path/to/graph.graphml', export=True)
Pass a Config instance to override any parameter listed below.
from node_labeling import label
from node_labeling.utils.config import Config
labels = label('path/to/graph.graphml', cfg=Config(top_k=200))
Configuration
| Category | Parameter | Description |
|---|---|---|
| Dev Mode | plot |
Whether to plot intermediate steps |
runtime |
Whether to display runtime information | |
| Data | label_config |
Label configuration |
| Visualize | font_size |
Font size for labels |
k_rows |
Number of rows for layout | |
max_row_chars |
Maximum characters per row | |
| Grid | grid_step |
Grid step size |
min_label_dist |
Minimum label distance from drawing | |
max_label_dist |
Maximum label distance from drawing | |
top_k |
Top k labels to consider | |
| Weights (cost) | w_align |
Anchor alignment |
w_angle |
Natural angle | |
w_boundary |
Close to polygon boundary | |
w_binder |
Length of binding line | |
w_binder_intersect |
Penalty for binder intersecting another label | |
w_binder_cross |
Penalty for crossing binding lines | |
w_tight_overlap |
Penalty for ink overlaps | |
w_overlap |
Penalty for padding overlaps | |
w_padding |
Penalty for padding | |
w_miss |
Penalty for unplaced label | |
w_type |
Penalty for label type mismatch | |
| Hungarian Solver | max_hungarian_iterations |
Maximum iterations for the Hungarian solver |
max_hungarian_fixes |
Maximum fixes for the Hungarian solver | |
iter_penalty_multiplier |
Multiplier for penalties in each iteration of the Hungarian solver | |
| Forces | w_inner_proximity |
Weight for pushing away from internal drawing |
w_global_proximity |
Weight for pushing away from other overflow labels | |
w_spring |
Weight for pulling toward node | |
w_binder_dodge |
Weight for pushing binder away from fixed labels | |
w_half_plane |
Weight for keeping labels in the correct half plane | |
force_iterations |
Number of iterations for force refinement | |
force_step_size |
Step size for force refinement | |
min_binder_length |
Minimum length for binding lines |
License
This work is licensed under a Creative Commons Attribution 4.0 International License.
Metadata
Release files for node-labeling 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| node_labeling-1.0.1.tar.gz | 42.1 kB | Without provenance | Details for node_labeling-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| node_labeling-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for node_labeling-1.0.1-py3-none-any.whl |
Total release size: 96.7 kB
Release files / node_labeling-1.0.1.tar.gz
| Download URL | node_labeling-1.0.1.tar.gz |
|---|---|
| Size | 42.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc44184f229b916502d6f4db607dc58a9417d0456d984d241e9ce0f4c3863e98
|
|
BLAKE2b-256 checksum How to use checksums |
50fb8117f442d059a345a32827553eaa55a64b956c80fda2bf480e927194aeaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / node_labeling-1.0.1-py3-none-any.whl
| Download URL | node_labeling-1.0.1-py3-none-any.whl |
|---|---|
| Size | 54.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ac93bf514559a4ee8a8207cb9d14584fbdf9bffc9cd4c93070236d4f3a711cc
|
|
BLAKE2b-256 checksum How to use checksums |
63e46cd870968998848fb8514b09c67dbfb36a0877e6419b44cfa043c2973f53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"25.10","id":"questing","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for node-labeling 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.