{"id":19206633,"url":"https://github.com/horothesun/immutablegraph","last_synced_at":"2025-05-12T17:28:02.889Z","repository":{"id":56915389,"uuid":"98823709","full_name":"horothesun/ImmutableGraph","owner":"horothesun","description":"Functional Swift graph algorithms.","archived":false,"fork":false,"pushed_at":"2021-04-17T20:21:08.000Z","size":85,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-20T15:43:47.284Z","etag":null,"topics":["algorithms","bfs","breadth-first-search","cocoapods","depth-first-search","dfs","fp","functional-programming","github-actions","graph","swift","swift-package","swift-package-manager","swiftpm"],"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/horothesun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-30T20:44:01.000Z","updated_at":"2022-09-02T15:02:46.000Z","dependencies_parsed_at":"2022-08-20T20:50:34.321Z","dependency_job_id":null,"html_url":"https://github.com/horothesun/ImmutableGraph","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/horothesun%2FImmutableGraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horothesun%2FImmutableGraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horothesun%2FImmutableGraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/horothesun%2FImmutableGraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/horothesun","download_url":"https://codeload.github.com/horothesun/ImmutableGraph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253786560,"owners_count":21964172,"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":["algorithms","bfs","breadth-first-search","cocoapods","depth-first-search","dfs","fp","functional-programming","github-actions","graph","swift","swift-package","swift-package-manager","swiftpm"],"created_at":"2024-11-09T13:16:31.032Z","updated_at":"2025-05-12T17:28:02.868Z","avatar_url":"https://github.com/horothesun.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ImmutableGraph\n\n[![CI Linux](https://github.com/horothesun/ImmutableGraph/workflows/CI%20Linux/badge.svg)](https://github.com/horothesun/ImmutableGraph/blob/master/.github/workflows/ci-linux.yml)\n[![CI macOS](https://github.com/horothesun/ImmutableGraph/workflows/CI%20macOS/badge.svg)](https://github.com/horothesun/ImmutableGraph/blob/master/.github/workflows/ci-macos.yml)\n[![codecov](https://codecov.io/gh/horothesun/ImmutableGraph/branch/master/graph/badge.svg?token=Z60dMMK1Lp)](https://codecov.io/gh/horothesun/ImmutableGraph)\n\n[![SwiftPM](https://img.shields.io/badge/SwiftPM-Compatible-brightgreen.svg)](https://swift.org/package-manager/)\n[![Version](https://img.shields.io/cocoapods/v/ImmutableGraph.svg?style=flat)](http://cocoapods.org/pods/ImmutableGraph)\n[![Platform](https://img.shields.io/cocoapods/p/ImmutableGraph.svg?style=flat)](http://cocoapods.org/pods/ImmutableGraph)\n\n[![License](https://img.shields.io/cocoapods/l/ImmutableGraph.svg?style=flat)](http://cocoapods.org/pods/ImmutableGraph)\n\n## Examples\n\nDirected graph:\n\n```swift\nlet u = \"☝️\", v = \"✌️\"\nlet vertices = Set(arrayLiteral: u, v)\n\nlet e = Edge(source: u, destination: v)\nlet edges = Set(arrayLiteral: e)\n\nlet graph = Graph(vertices: vertices, edges: edges)\n```\n\nWeighted directed graph:\n\n```swift\nlet w_e = WeightedEdge(source: u, destination: v, weight: 3.9)\nlet weightedEdges = Set(arrayLiteral: w_e)\n\nlet weightedGraph = Graph(vertices: vertices, edges: weightedEdges)\n```\n\nDFS from source:\n\n```swift\nlet simpleGraphAnnotation = dfs(graph, source: v)\n```\n\nDFS on graph:\n\n```swift\nlet simpleGraphAnnotation = dfs(graph)\n```\n\nBFS from source:\n\n```swift\nlet simpleGraphAnnotation = bfs(graph, source: v)\n```\n\nFinding paths from graph annotations:\n\n```swift\nlet parentByVertex = simpleGraphAnnotation.parentByVertex\nlet result = findPath(parentByVertex: parentByVertex, source: s, destination: d)\n```\n\n## CocoaPods installation\n\n`ImmutableGraph` is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your `Podfile`:\n\n```ruby\npod \"ImmutableGraph\"\n```\n\n## Swift Package installation\n\nIf your package depends on `ImmutableGraph`, add the following dependency to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/horothesun/ImmutableGraph\", .upToNextMinor(from: \"0.1.0\"))\n]\n```\n\n## Generate Xcode project\n\n```bash\nswift package generate-xcodeproj\n```\n\n## Testing\n\n### macOS\n\n```bash\nswift test\n```\n\n### Docker Linux\n\nIMPORTANT: regenerate Linux test list executing\n\n```bash\nswift test --generate-linuxmain\n```\n\nExecute on base `swift:5.2` image\n\n```bash\ndocker run --rm \\\n    --volume \"$(pwd):/package\" \\\n    --workdir '/package' \\\n    swift:5.2 \\\n    /bin/bash -c 'swift test'\n```\n\nor create a new image based on `Dockerfile` and run it\n\n```bash\ndocker build --tag immutable-graph .\ndocker run --rm immutable-graph\n```\n\n## Notes\n\nThis library was built using TDD.\n\nSome of the graphs used to unit test BFS and DFS algorithms come from [Algorithms with Attitude](https://www.youtube.com/channel/UCUGQA2H6AXFolADHf9mBb4Q) YouTube channel's related videos:\n\n* [Graphs: Breadth First Search (BFS) with Example](https://www.youtube.com/watch?v=ls4cHglfc0g)\n* [Graphs: Depth First Search (DFS) with Example](https://www.youtube.com/watch?v=qH-mHxkoK0Q)\n\n## Author\n\nNicola Di Pol, horothesun@gmail.com\n\n\n## License\n\n`ImmutableGraph` is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorothesun%2Fimmutablegraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhorothesun%2Fimmutablegraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhorothesun%2Fimmutablegraph/lists"}