Metadata-Version: 2.1
Name: graphlib2
Version: 0.1.1
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: typing-extensions>=3; python_version < '3.8'
Summary: Rust port of the Python stdlib graphlib modules
Author: Adrian Garcia Badaracco
License: Copyright (c) 2012-2021 Scott Chacon and others
	
	Permission is hereby granted, free of charge, to any person obtaining
	a copy of this software and associated documentation files (the
	"Software"), to deal in the Software without restriction, including
	without limitation the rights to use, copy, modify, merge, publish,
	distribute, sublicense, and/or sell copies of the Software, and to
	permit persons to whom the Software is furnished to do so, subject to
	the following conditions:
	
	The above copyright notice and this permission notice shall be
	included in all copies or substantial portions of the Software.
	
	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
	NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
	LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
	OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
	WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
	
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# graphlib2

This is a Rust port of Python's stdlib [graphlib].
It passes all of the standard libraries tests and is a drop in replacement.
This also happens to be Python 3.7 compatible, so it can be used as a backport.
Since usage is exactly the same as the standard libraries, please refer to their documentation for usage details.

## Example

```python
from graphlib2 import TopologicalSorter

graph = {0: [1], 1: [2]}  # 0 depends on 1, 1 depends on 2
ts = TopologicalSorter(graph)
ts.prepare()
while ts.is_active():
    ready_nodes = ts.get_ready()
    ts.done(*ready_nodes)  # all at a time or one by one
```

## Motivation

This was primarily written for [di] and for me to learn Rust.
In other words: please vet the code yourself before using this.

## Differences with the stdlib implementation

1. Additional APIs for removing nodes from the graph (`TopologicalSorter.remove_nodes`) and copying a prepared `TopologicalSorter` (`TopologicalSorter.copy`).
1. A couple factors (~5x) faster for large highly branched graphs.
1. Unlocks the GIL during certain operations, which can considerably speed up multithreaded workloads.

## Development

1. Clone the repo.
1. Run `make init`
1. Run `make test`

[di]: https://github.com/adriangb/di
[graphlib]: https://docs.python.org/3/library/graphlib.html

