{"id":16965008,"url":"https://github.com/propensive/acyclicity","last_synced_at":"2025-03-22T14:31:01.012Z","repository":{"id":80754885,"uuid":"350105301","full_name":"propensive/acyclicity","owner":"propensive","description":"Monadic directed acyclic graph datastructures for Scala","archived":false,"fork":false,"pushed_at":"2025-02-12T18:51:18.000Z","size":6996,"stargazers_count":12,"open_issues_count":3,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-18T11:52:00.590Z","etag":null,"topics":["dag","functional-programming","graph","immutable","outgoing-edges","scala","subgraph"],"latest_commit_sha":null,"homepage":"https://soundness.dev/acyclicity/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/propensive.png","metadata":{"files":{"readme":".github/readme.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-21T20:02:26.000Z","updated_at":"2025-02-12T18:51:22.000Z","dependencies_parsed_at":"2023-11-16T09:25:11.273Z","dependency_job_id":"d3dc3a8c-df39-48d0-9abc-4b89a61e4bd0","html_url":"https://github.com/propensive/acyclicity","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Facyclicity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Facyclicity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Facyclicity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Facyclicity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/propensive","download_url":"https://codeload.github.com/propensive/acyclicity/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244971781,"owners_count":20540854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dag","functional-programming","graph","immutable","outgoing-edges","scala","subgraph"],"created_at":"2024-10-13T23:44:49.520Z","updated_at":"2025-03-22T14:31:00.999Z","avatar_url":"https://github.com/propensive.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg alt=\"GitHub Workflow\" src=\"https://img.shields.io/github/actions/workflow/status/propensive/acyclicity/main.yml?style=for-the-badge\" height=\"24\"\u003e](https://github.com/propensive/acyclicity/actions)\n[\u003cimg src=\"https://img.shields.io/discord/633198088311537684?color=8899f7\u0026label=DISCORD\u0026style=for-the-badge\" height=\"24\"\u003e](https://discord.com/invite/MBUrkTgMnA)\n\u003cimg src=\"/doc/images/github.png\" valign=\"middle\"\u003e\n\n# Acyclicity\n\n__Monadic directed acyclic graph datastructures__\n\nAcyclicity provides a single data structure, `Dag[T]`, representing a graph of\nnodes of type `T`, with monadic operations and several other utility methods,\nplus the means to generate DOT for input to GraphViz.\n\n## Features\n\n- provides a simple immutable monadic implementation of a DAG\n- implements `map`, `flatMap` and `filter` for `Dag`s\n- can deduce a partial order on a graph\n- generates `Dot` instances representing a DOT abstract syntax tree\n- serializes `Dot` instances to `String`s, which can be rendered by GraphViz\n- can find the transitive closure, transitive reduction and inverse of a graph\n- methods for addition and subtraction of graph nodes\n\n\n## Availability\n\n\n\n\n\n\n\n## Getting Started\n\nAcyclicity provides a monadic representation of a directed, acyclic graph (DAG) called `Dag`, and support for\ngenerating [DOT](https://bit.ly/3vFumLW) files which can be rendered with tools such as\n[GraphViz](https://graphviz.org/).\n\nAll Acyclicity terms and types are defined in the `acyclicity` package.\n```scala\nimport acyclicity.*\n```\n\nThe `Dag[T]` type represents a mapping from nodes of type `T` to zero, one or many other nodes in the graph, and\ncan be constructed by providing the mapping from each node to its `Set` of dependent nodes, or by calling,\n```scala\nval nodes: Set[Int] = Set(2, 3, 4, 5, 10, 15, 30)\ndef fn(n: Int): Set[Int] = (0 until n).filter(n%_ == 0).to(Set)\nval dag = Dag(nodes)(fn)\n```\nwhere `nodes` is a `Set` of nodes, and `fn` is a function from each node to its dependencies.\n\nFor example,\n```scala\nval factors = Dag(\n  30 -\u003e Set(2, 3, 4, 5, 10, 15),\n  15 -\u003e Set(5, 3),\n  10 -\u003e Set(5, 2),\n  5 -\u003e Set(),\n  3 -\u003e Set(),\n  2 -\u003e Set()\n)\n```\n\n### Monadic Operations\n\nA `Dag[T]` may be mapped to a `Dag[S]` with a function `T =\u003e S`, like so:\n```scala\nval dag2 = factors.map(_*10)\n```\n\nCare should be taken when more than one node in the domain maps to a single node in the range, but both incoming\nand outgoing edges will be merged in such cases.\n\nIt's also possible to `flatMap` with a function `T =\u003e Dag[S]`. This will replace every node of type `T` with a\nsubgraph, `Dag[S]` with incoming edges attached to all source nodes of the subgraph, and pre-existing outgoing\nedges attached to all destination nodes of the subgraph.\n\nA `Dag[T]` may also be filtered with a predicate, `T =\u003e Boolean`. The removal of a node during filtering will\nreattach every incoming edge to every outgoing edge of that node.\n\n### Other Operations\n\nThe method `Dag#reduction` will calculate the transitive reduction of the graph, removing any direct edge\nbetween two nodes when transitive edges exist between those nodes.\n\nThe dual of this operation is the transitive closure, which adds direct edges between each pair of nodes between\nwhich a transitive path exists. This is available with the `Dag#closure` method.\n\nA list of nodes will be returned in topologically-sorted order by calling `Dag#sorted`.\n\n### DOT output\n\nAn extension method, `dot`, on `Dag`s of `Text`s will produce a `Dot` instance, an AST of the DOT code\nnecessary to render a graph. This can then be serialized to a `Text` with the `serialize` method.\n\nTypical usage would be to first convert a `Dag[T]` to a `Dag[Text]`, then produce the `Dot` instance and\nserialize it, for example:\n```scala\nimport spectacular.show\n\n@main\ndef graph() = println(dag.map(_.show).dot.serialize)\n```\n\n### Limitations\n\nThis library is incomplete, inadequately tested and subject to further development, and is recommended to be\nused by developers who do not mind examining the source code to diagnose unexpected behavior.\n\n\n\n\n\n\n## Status\n\nAcyclicity is classified as __fledgling__. For reference, Soundness projects are\ncategorized into one of the following five stability levels:\n\n- _embryonic_: for experimental or demonstrative purposes only, without any guarantees of longevity\n- _fledgling_: of proven utility, seeking contributions, but liable to significant redesigns\n- _maturescent_: major design decisions broady settled, seeking probatory adoption and refinement\n- _dependable_: production-ready, subject to controlled ongoing maintenance and enhancement; tagged as version `1.0.0` or later\n- _adamantine_: proven, reliable and production-ready, with no further breaking changes ever anticipated\n\nProjects at any stability level, even _embryonic_ projects, can still be used,\nas long as caution is taken to avoid a mismatch between the project's stability\nlevel and the required stability and maintainability of your own project.\n\nAcyclicity is designed to be _small_. Its entire source code currently consists\nof 262 lines of code.\n\n## Building\n\nAcyclicity will ultimately be built by Fury, when it is published. In the\nmeantime, two possibilities are offered, however they are acknowledged to be\nfragile, inadequately tested, and unsuitable for anything more than\nexperimentation. They are provided only for the necessity of providing _some_\nanswer to the question, \"how can I try Acyclicity?\".\n\n1. *Copy the sources into your own project*\n   \n   Read the `fury` file in the repository root to understand Acyclicity's build\n   structure, dependencies and source location; the file format should be short\n   and quite intuitive. Copy the sources into a source directory in your own\n   project, then repeat (recursively) for each of the dependencies.\n\n   The sources are compiled against the latest nightly release of Scala 3.\n   There should be no problem to compile the project together with all of its\n   dependencies in a single compilation.\n\n2. *Build with [Wrath](https://github.com/propensive/wrath/)*\n\n   Wrath is a bootstrapping script for building Acyclicity and other projects in\n   the absence of a fully-featured build tool. It is designed to read the `fury`\n   file in the project directory, and produce a collection of JAR files which can\n   be added to a classpath, by compiling the project and all of its dependencies,\n   including the Scala compiler itself.\n   \n   Download the latest version of\n   [`wrath`](https://github.com/propensive/wrath/releases/latest), make it\n   executable, and add it to your path, for example by copying it to\n   `/usr/local/bin/`.\n\n   Clone this repository inside an empty directory, so that the build can\n   safely make clones of repositories it depends on as _peers_ of `acyclicity`.\n   Run `wrath -F` in the repository root. This will download and compile the\n   latest version of Scala, as well as all of Acyclicity's dependencies.\n\n   If the build was successful, the compiled JAR files can be found in the\n   `.wrath/dist` directory.\n\n## Contributing\n\nContributors to Acyclicity are welcome and encouraged. New contributors may like\nto look for issues marked\n[beginner](https://github.com/propensive/acyclicity/labels/beginner).\n\nWe suggest that all contributors read the [Contributing\nGuide](/contributing.md) to make the process of contributing to Acyclicity\neasier.\n\nPlease __do not__ contact project maintainers privately with questions unless\nthere is a good reason to keep them private. While it can be tempting to\nrepsond to such questions, private answers cannot be shared with a wider\naudience, and it can result in duplication of effort.\n\n## Author\n\nAcyclicity was designed and developed by Jon Pretty, and commercial support and\ntraining on all aspects of Scala 3 is available from [Propensive\nO\u0026Uuml;](https://propensive.com/).\n\n\n\n## Name\n\nAcyclicity takes its name from the graphs it represents, which must not contain cycles.\n\nIn general, Soundness project names are always chosen with some rationale,\nhowever it is usually frivolous. Each name is chosen for more for its\n_uniqueness_ and _intrigue_ than its concision or catchiness, and there is no\nbias towards names with positive or \"nice\" meanings—since many of the libraries\nperform some quite unpleasant tasks.\n\nNames should be English words, though many are obscure or archaic, and it\nshould be noted how willingly English adopts foreign words. Names are generally\nof Greek or Latin origin, and have often arrived in English via a romance\nlanguage.\n\n## Logo\n\nThe logo shows a single dot, alluding to the [DOT language](https://graphviz.org/doc/info/lang.html).\n\n## License\n\nAcyclicity is copyright \u0026copy; 2025 Jon Pretty \u0026 Propensive O\u0026Uuml;, and\nis made available under the [Apache 2.0 License](/license.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Facyclicity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpropensive%2Facyclicity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Facyclicity/lists"}