Metadata-Version: 2.4
Name: pd-code-components
Version: 0.1.1
Summary: get all components from a link pd code.
License: MIT
License-File: LICENSE
Author: GGN_2015
Author-email: premierbob@qq.com
Requires-Python: >=3.10
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Description-Content-Type: text/markdown

# pd-code-components

Find the components represented by a planar-diagram code.

## Installation

```bash
pip install pd-code-components
```

## Usage example

```python
from pd_code_components import get_components_from_pd_code

hopf = [[2, 3, 1, 4], [4, 1, 3, 2]]
print(get_components_from_pd_code(hopf))
# [[1, 2], [3, 4]]
```

## Algorithm

At each crossing, slots `0` and `2` belong to one strand and slots `1` and `3` to the other. These opposite-slot pairs form an undirected graph on arc labels. Iterative depth-first traversal finds connected components in `O(V + E)` time. Sets are used for adjacency and visitation, avoiding the quadratic membership checks in the original list-based implementation.

## Input conventions

A PD code is represented as a list of four-entry crossings. Arc labels normally occur exactly twice. Public functions validate inputs and return new values rather than mutating caller-owned data unless their API explicitly says otherwise.

## External software

No external software is required.

## Development

Run examples and package checks before release. Python packages require Python 3.10 or newer. Build PyPI artifacts with:

```bash
poetry check
poetry build
```

## License

MIT. See `LICENSE`.

