The Python Simple Directed Graph whith Cicle Detector and TopoloGical sorter utilities.
## Authors
- [Moises P. Sena](http://moisespsena.com)
## Install
```bash
sudo pip install py_sdag2
```
## Scripts
### tsort.py
Sources from Standard Input:
```bash
echo -e 'C A\nA B\nB D\nC D' | tsort.py
```
Sources from another file:
```bash
echo -e 'C A\nA B\nB D\nC D' > verticies.txt
```
```bash
tsort.py verticies.txt
```
More Options:
```bash
tsort.py --help
Usage: tsort.py [options] [FILE [OUT_FILE]]
Options:
-h, --help show this help message and exit
-f FILE, --file=FILE With no FILE, or when FILE is -, read standard input.
-o OUT_FILE, --out-file=OUT_FILE
Write result to OUT_FILE, default is standard output.
-s SEP, --separator=SEP
Items separator, default is \s regex.
-q QUIT_SEQ, --quit-sequence=QUIT_SEQ
Stop read FILE where line equals QUIT_SEQ, default is
:quit.
```
## Tests
```python
import unittest
from sdag2 import DAG, CycleDetectedException
class DAGTest(unittest.TestCase):
def test_simple(self):
'''
Tests the verticles order in:
C --> A --> B --> D
'''
dag = DAG()
a = dag.add("A")
b = dag.add("B")
c = dag.add("C")
d = dag.add("D")
dag.add_edge(c, a)
dag.add_edge(a, b)
dag.add_edge(b, d)
dag.add_edge(c, d)
rs = dag.topologicaly()
self.assertTrue(rs.index("C") < rs.index("A"))
self.assertTrue(rs.index("A") < rs.index("B"))
self.assertTrue(rs.index("B") < rs.index("D"))
self.assertTrue(rs.index("C") < rs.index("D"))
def test_cicle_detect(self):
'''
Tests the verticles order in:
C --> A --> B --> D -> C
'''
dag = DAG()
a = dag.add("A")
b = dag.add("B")
c = dag.add("C")
d = dag.add("D")
dag.add_edge(c, a)
dag.add_edge(a, b)
dag.add_edge(b, d)
dag.add_edge(c, d)
try:
# add cicle at A --> C --> A
dag.add_edge(a, c)
raise Exception("Cycle not detected")
except CycleDetectedException: pass
def main():
unittest.main()
if __name__ == "__main__":
main()
```
Metadata
Release files for py_sdag2 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 | |
|---|---|---|---|---|
| py_sdag2-1.0.1.tar.gz | 5.6 kB | Without provenance | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_sdag2-1.0.1-py3.4.egg | Legacy Egg format | - | - | Details |
| py_sdag2-1.0.1-py2.7.egg | Legacy Egg format | - | - | Details |
Total release size: 25.2 kB
Release files / py_sdag2-1.0.1.tar.gz
| Download URL | py_sdag2-1.0.1.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efb000f8038bc58d10b30c3a985e787b5876150b72f41dd4e71e268981c5a83e
|
|
BLAKE2b-256 checksum How to use checksums |
500930950184a190d35adf002ec0f48a973ff6fd294af658a9fdccd611408cc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / py_sdag2-1.0.1-py3.4.egg
| Download URL | py_sdag2-1.0.1-py3.4.egg |
|---|---|
| Size | 10.0 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
2360a7b2683f6e0b8e9a8c1bdb5323f75849d03657ae35a14b68988cab6105a9
|
|
BLAKE2b-256 checksum How to use checksums |
ccb9eb68971d1a36f0d6674430a73e90c57d35ad2a4ac1da04875a4a864338e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / py_sdag2-1.0.1-py2.7.egg
| Download URL | py_sdag2-1.0.1-py2.7.egg |
|---|---|
| Size | 9.6 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
aa87e5eb7c28cbdc07819361cad95e9bc917a4ecabb8f430e633b0963cb5e7cd
|
|
BLAKE2b-256 checksum How to use checksums |
1af6cc33ef4700fdb6e8aeb6663463f8b5995641e84a0f08320557be1436df43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for py_sdag2 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.