This release is a pre-release and may not be stable for production use.
networkx-reverse-topological-sort
Reverse topological sort utilities for NetworkX: easily stratify or sort nodes in a DAG from leaves to root.
Features
- Reverse Topological Sort: Get a valid reverse of NetworkX's
topological_sort, yielding from "leaf" nodes up to roots. - Reverse Topological Generations: Partition your DAG into generations in reverse order (each generation, all children are in earlier generations).
Motivation
NetworkX includes tools for forward (root-to-leaf) topological traversals, but some applications (e.g., evaluating dependencies after their dependents, post-order processing, certain scheduling schemes) need the reverse order: leaves to root.
This tiny package offers that for networkx.
Installation
pip install networkx-reverse-topological-sort
Usage
import networkx as nx
from networkx_reverse_topological_sort import (
reverse_topological_generations,
reverse_topological_sort,
)
DG = nx.DiGraph([(2, 1), (3, 1)])
print([sorted(generation) for generation in reverse_topological_generations(DG)])
# Output: [[1], [2, 3]]
print(list(reverse_topological_sort(DG)))
# Output: [1, 2, 3] (or [1, 3, 2]: nodes before their parents)
Contributing
Contributions are welcome! Please submit pull requests or open issues on the GitHub repository.
License
This project is licensed under the MIT License.
Release files for networkx-reverse-topological-sort 0.1.0a0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| networkx_reverse_topological_sort-0.1.0a0.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| networkx_reverse_topological_sort-0.1.0a0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 7.1 kB
Release files / networkx_reverse_topological_sort-0.1.0a0.tar.gz
| Download URL | networkx_reverse_topological_sort-0.1.0a0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
84f0c942e1770fbebae5ec95875e98a4ead985c068b5d628b46f09b8ea468c5c
|
|
BLAKE2b-256 checksum How to use checksums |
bafa90ca14a7701542d40456f6983e77d09d2c819fd9230c97201b0c8c7cce29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / networkx_reverse_topological_sort-0.1.0a0-py2.py3-none-any.whl
| Download URL | networkx_reverse_topological_sort-0.1.0a0-py2.py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
4e51b626b29465c2dcf63976cd1fa3df6ba078991fb412b515591ac8b2301b35
|
|
BLAKE2b-256 checksum How to use checksums |
0edb0e751020d32b0af11e9f5606136cb8374938a2322dc978e22c77a0ae4591
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|