{"id":22666657,"url":"https://github.com/fireblade-engine/graph","last_synced_at":"2025-04-12T09:53:07.011Z","repository":{"id":56625688,"uuid":"208573752","full_name":"fireblade-engine/graph","owner":"fireblade-engine","description":"A lightweight, fast and easy to use directed acyclic graph (DAG) implementation in Swift.","archived":false,"fork":false,"pushed_at":"2025-04-05T14:55:05.000Z","size":395,"stargazers_count":10,"open_issues_count":4,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-12T09:52:59.122Z","etag":null,"topics":["dag","directed-acyclic-graph","library","mit-license","spm","swift","swift-package-manager"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fireblade-engine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":["ctreffs"],"custom":["https://www.paypal.com/donate?hosted_button_id=GCG3K54SKRALQ"]}},"created_at":"2019-09-15T09:56:29.000Z","updated_at":"2025-03-07T17:04:09.000Z","dependencies_parsed_at":"2023-10-03T05:29:32.632Z","dependency_job_id":"84f8b0dc-d234-4b51-a7ee-d751122c7603","html_url":"https://github.com/fireblade-engine/graph","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/fireblade-engine%2Fgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireblade-engine%2Fgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireblade-engine%2Fgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireblade-engine%2Fgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fireblade-engine","download_url":"https://codeload.github.com/fireblade-engine/graph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248550636,"owners_count":21122932,"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","directed-acyclic-graph","library","mit-license","spm","swift","swift-package-manager"],"created_at":"2024-12-09T14:17:33.718Z","updated_at":"2025-04-12T09:53:06.982Z","avatar_url":"https://github.com/fireblade-engine.png","language":"Swift","readme":"# Fireblade Graph\n\n[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)\n\nThis is a **lightweight**, **fast** and **easy to use** [directed acyclic graph (DAG)](https://en.wikipedia.org/wiki/Directed_acyclic_graph) implementation in Swift.    \nIt is developed and maintained as part of the [Fireblade Game Engine](https://github.com/fireblade-engine) project.\n\n## 🚀 Getting Started\n\nThese instructions will get you a copy of the project up and running on your local machine and provide a code example.\n\n### 📋 Prerequisites\n\n* [Swift Package Manager (SPM)](https://github.com/apple/swift-package-manager)\n* [Swiftlint](https://github.com/realm/SwiftLint) for linting - (optional)\n* [SwiftEnv](https://swiftenv.fuller.li/) for Swift version management - (optional)\n\n### 💻 Installing\n\nFireblade Graph is available for all platforms that support [Swift 5](https://swift.org/) and higher and the [Swift Package Manager (SPM)](https://github.com/apple/swift-package-manager).\n\nExtend the following lines in your `Package.swift` file or use it to create a new project.\n\n```swift\n// swift-tools-version:5.2\n\nimport PackageDescription\n\nlet package = Package(\n    name: \"YourPackageName\",\n    dependencies: [\n    .package(url: \"https://github.com/fireblade-engine/graph.git\", from: \"1.3.0\")\n    ],\n    targets: [\n        .target(\n            name: \"YourTargetName\",\n            dependencies: [\"FirebladeGraph\"])\n    ]\n)\n\n```\n\n## 📝 Code Example\n\nThe `Node` is the core element of the package.   \nIt is representing a node in a [directed acyclic graph (DAG)](https://en.wikipedia.org/wiki/Directed_acyclic_graph)  and holds a (weak) reference to its parent node and references to its child nodes.\n\nTo create a graph create a node and add children.\n\n```swift\nlet rootNode = Node\u003cVoid\u003e()\n\nlet child1 = Node\u003cVoid\u003e()\nlet child2 = Node\u003cVoid\u003e()\n\nrootNode.addChild(child1)\nrootNode.addChild(child2)\n\n```\n\nA DAG implementation starts to shine when you can add functionality or behavior to its nodes.   \nThis is acchieved by subclassing `Node` and implementing the desired behavior in its `.updateFromParent()` method as well as setting the node's generic `Content` constraint.\n\n```swift\nclass StringNode: Node\u003cString\u003e {\n\n\tlet content: String\n\t\n\tfunc myFunc() { ... } // or functions\n\n    override open func updateFromParent() {\n        super.updateFromParent()\n    \n        // ... and do fancy stuff here ...\n    }\n}\n\nlet node = StringNode(\"Hello World!\")\n\n```\n\nTo traverse through the graph from root to leave nodes call `.update()` on the root node of the graph.\n\n```swift\nlet rootNode = Node\u003cVoid\u003e()\n\n// ... build up your graph here ...\n\nrootNode.update()\n\n```\n\n\n## 🏷️ Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the tags on this repository. \n\n## ✍️ Authors\n\n* [Christian Treffs](https://github.com/ctreffs)\n\nSee also the list of contributors who participated in this project.\n\n## 🔏 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","funding_links":["https://github.com/sponsors/ctreffs","https://www.paypal.com/donate?hosted_button_id=GCG3K54SKRALQ"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireblade-engine%2Fgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffireblade-engine%2Fgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireblade-engine%2Fgraph/lists"}