Skip to main content

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, 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.

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

Install

pip install sfas

Example usage

from sfas import greedy
graph = [
    ['a', 'b', 1],
    ['a', 'c', 1],
    ['c', 'd', 2],
    ['d', 'a', 2],
]

Input Graph

greedy.compute_order(graph, verbosity=0, random_seed=0)

output

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

Order with minimal FAS

Questions / suggestions welcome

arie.matsliah@gmail.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sfas-0.0.9.tar.gz (118.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sfas-0.0.9-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file sfas-0.0.9.tar.gz.

File metadata

  • Download URL: sfas-0.0.9.tar.gz
  • Upload date:
  • Size: 118.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.2

File hashes

Hashes for sfas-0.0.9.tar.gz
Algorithm Hash digest
SHA256 89a247af4ceaf244c2e9c7e1880bad21ccb0f47d18a037cdd8106b684d32661f
MD5 302831a06c4b119393e5306f10201371
BLAKE2b-256 3ba7d463b942a952b35f119a4931b9873ab73934158ac3dfb64cb20164028ca6

See more details on using hashes here.

File details

Details for the file sfas-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: sfas-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.2

File hashes

Hashes for sfas-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 75b8a68e44b057ea5b4475cd48ce3801e0e3d80f509296430f6af16258ca34cb
MD5 c936c1f1678314fac8cbd9072afd14c9
BLAKE2b-256 1942dc8e3e6f8afe0e1a38430f4322ab6f23c54936ef4fd5853c20d6b42447d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page