Skip to main content

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, computes a topological sorting (linear order 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.

Install

pip install sfas

Example usage

graph = [
    ['a', 'b', 1],
    ['a', 'c', 1],
    ['c', 'd', 2],
    ['d', 'a', 2],
]

Input Graph

from sfas import greedy
ouput = greedy.compute_order(graph)

output

['c', 'd', 'a', 'b']

Order with minimal FAS

Interface

Params:

  1. connections : List[List[Any, Any, Int]] - list of edges, each represented as a 3-item list consisting of [<from node>, <to node>, <edge weight>]
  2. verbosity : Int - prints progress and other stats for values > 0
  3. random_seed : Int randomness is in picking the next "greedy" step among equally qualified ones

Result:

  1. List with all nodes, ordered so that the total weight of edges going backwards (w.r.t. this order) is small

Questions / suggestions welcome

arie.matsliah@gmail.com

Metadata

Release files for sfas 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sfas 1.0.0
File Size Uploaded
sfas-1.0.0.tar.gz 118.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sfas 1.0.0
File Interpreter ABI Platform
sfas-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 124.5 kB

Release files / sfas-1.0.0.tar.gz

Download URL sfas-1.0.0.tar.gz
Size 118.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1177da11fd43a74151c5c1b59da1807f326d84066dbdcce07dba82dcaa07b51f
BLAKE2b-256 checksum
How to use checksums
e680f14c945960518c45081c67cd3a28541e1a9a63baeefd63d61770865f532a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.2

Release files / sfas-1.0.0-py3-none-any.whl

Download URL sfas-1.0.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f4878f6b71fcd1f031345d2bd5eb5b05e44c59e8e2bc0e2c69d2dbc185b94f5
BLAKE2b-256 checksum
How to use checksums
61edb55062ca4b105b184c379b5036e1d61ff9854ac9a94d91c08e2a8a1fadb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.2

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

1 release file

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page