No project description provided
Project description
Small Feedback Arc Set (sfas)
Efficient implementation of a greedy algorithm for computing small feedback arc sets in directed weighted multi-graphs. This implementation is an adaptation of the algorithm described in Section 2.3 of this article, with additional generalization to support weights and parallel edges.
Description
Given a weighted directed graph, calculates linear arrangement of the nodes that minimizes (greedily) the number of backward edges (feedback arc set). In particular, removing the set of edges going backward in the resulting order breaks all directed cycles in the graph.
Interface
Input:
- connections: list of edges, each represented as a 3-item list consisting of [, , ]
- verbosity: prints progress and other stats for values >0
- random_seed: randomness is in picking the next "greedy" step among equally qualified ones
Output:
- list with all nodes, ordered so that the total weight of edges going backwards (w.r.t. this order) is small
Install
pip install sfas
Example usage
from sfas import greedy
graph = [
['a', 'b', 1],
['b', 'c', 1],
['c', 'a', 2],
]
greedy.compute_order(graph, verbosity=0, random_seed=0)
output
['c', 'a', 'b']
Questions / suggestions welcome
arie.matsliah@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sfas-0.0.3.tar.gz.
File metadata
- Download URL: sfas-0.0.3.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
691239242606b6d34677276ef334de2404cc4fe7bc3ea194a18d024f401ba21e
|
|
| MD5 |
3c2b84c54cea3d08eaab51c907ba3c0f
|
|
| BLAKE2b-256 |
3202984b5d9bb0a49843b13665ed96e7476b80fb901e1183b9fc9cdd55ecf16e
|
File details
Details for the file sfas-0.0.3-py3-none-any.whl.
File metadata
- Download URL: sfas-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53330203aaa06756fa5afe2751a2004bdf81a4655d5a67d1dfb339a93c387b2d
|
|
| MD5 |
9bb4270c61be71439facae69993dfe3f
|
|
| BLAKE2b-256 |
43b3cb7da2a07f3548cc4e1c76a2997b7efe5f58434274049e22124de9ac0523
|