{"id":13413746,"url":"https://github.com/hmdsefi/gograph","last_synced_at":"2026-01-14T14:51:49.202Z","repository":{"id":94633103,"uuid":"518926762","full_name":"hmdsefi/gograph","owner":"hmdsefi","description":"A golang generic graph library that provides mathematical graph-theory and algorithms.","archived":false,"fork":false,"pushed_at":"2025-09-05T22:00:56.000Z","size":199,"stargazers_count":91,"open_issues_count":2,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-06T00:10:39.639Z","etag":null,"topics":["datastructure","generic","generic-graph","golang","graph","graph-algorithms","graph-datastructures","graph-theory","graph-traversal"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hmdsefi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-07-28T16:54:30.000Z","updated_at":"2025-09-05T22:01:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"b0523de2-2344-4c74-8a40-ff8722bcf5a8","html_url":"https://github.com/hmdsefi/gograph","commit_stats":{"total_commits":73,"total_committers":2,"mean_commits":36.5,"dds":0.04109589041095896,"last_synced_commit":"3ffe439558ec54dd4faff4944e935914ecb2369c"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/hmdsefi/gograph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmdsefi%2Fgograph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmdsefi%2Fgograph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmdsefi%2Fgograph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmdsefi%2Fgograph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hmdsefi","download_url":"https://codeload.github.com/hmdsefi/gograph/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hmdsefi%2Fgograph/sbom","scorecard":{"id":466674,"data":{"date":"2025-08-11","repo":{"name":"github.com/hmdsefi/gograph","commit":"4168bfe5a6c6cafd62d313929f312f37c65a20d8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Maintained","score":5,"reason":"6 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 5","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 1/16 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/hmdsefi/gograph/build.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/hmdsefi/gograph/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:8: update your workflow using https://app.stepsecurity.io/secureworkflow/hmdsefi/gograph/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/hmdsefi/gograph/build.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/build.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/hmdsefi/gograph/build.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/hmdsefi/gograph/build.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 23 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T12:42:47.253Z","repository_id":94633103,"created_at":"2025-08-19T12:42:47.254Z","updated_at":"2025-08-19T12:42:47.254Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28424003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["datastructure","generic","generic-graph","golang","graph","graph-algorithms","graph-datastructures","graph-theory","graph-traversal"],"created_at":"2024-07-30T20:01:48.001Z","updated_at":"2026-01-14T14:51:49.196Z","avatar_url":"https://github.com/hmdsefi.png","language":"Go","readme":"![build](https://github.com/hmdsefi/gograph/actions/workflows/build.yml/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/hmdsefi/gograph)](https://goreportcard.com/report/github.com/hmdsefi/gograph)\n[![codecov](https://codecov.io/gh/hmdsefi/gograph/branch/master/graph/badge.svg?token=BstHl9wXTN)](https://codecov.io/gh/hmdsefi/gograph)\n[![Go Reference](https://pkg.go.dev/badge/github.com/hmdsefi/gograph.svg)](https://pkg.go.dev/github.com/hmdsefi/gograph)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go#science-and-data-analysis)\n\n\n  \u003cimg alt=\"golang generic graph package\" src=\"https://github.com/user-attachments/assets/b5728572-9c17-47e8-aa32-28aeeedf1e25\" height=\"600\" title=\"gograph\"/\u003e\n\n# GoGraph\n\u003cbr/\u003e\n\u003cbr/\u003e\n\u003cp\u003eGoGraph is a lightweight, efficient, and easy-to-use graph data structure\nimplementation written in Go. It provides a versatile framework for representing \ngraphs and performing various operations on them, making it ideal for both\neducational purposes and practical applications.\u003c/p\u003e\n\u003cbr/\u003e\u003cbr/\u003e\u003cbr/\u003e\n\n## Table of Contents\n\n* [Install](#Install)\n* [How to Use](#How-to-Use)\n    * [Graph](#Graph)\n        * [Directed](#Directed)\n        * [Acyclic](#Acyclic)\n        * [Undirected](#Undirected)\n        * [Weighted](#Weighted)\n    * [Traverse](#Traverse)\n    * [Connectivity](https://github.com/hmdsefi/gograph/tree/master/connectivity#gograph---connectivity)\n    * [Shortest Path]()\n        * [Dijkstra](https://github.com/hmdsefi/gograph/blob/master/path/dijkstra.md)\n        * [Bellman-Ford](https://github.com/hmdsefi/gograph/blob/master/path/bellman-ford.md)\n        * [Floyd-Warshall](https://github.com/hmdsefi/gograph/blob/master/path/floyd-warshall.md)\n* [License](#License)\n\n## Install\n\nUse `go get` command to get the latest version of the `gograph`:\n\n```shell\ngo get github.com/hmdsefi/gograph\n```\n\nThen you can use import the `gograph` to your code:\n\n```go\npackage main\n\nimport \"github.com/hmdsefi/gograph\"\n```\n\n## How to Use\n\n### Graph\n\n`gograph` contains the `Graph[T comparable]` interface that provides all needed APIs to\nmanage a graph. All the supported graph types in `gograph` library implemented this interface.\n\n```go\ntype Graph[T comparable] interface {\nGraphType\n\nAddEdge(from, to *Vertex[T], options ...EdgeOptionFunc) (*Edge[T], error)\nGetAllEdges(from, to *Vertex[T]) []*Edge[T]\nGetEdge(from, to *Vertex[T]) *Edge[T]\nEdgesOf(v *Vertex[T]) []*Edge[T]\nRemoveEdges(edges ...*Edge[T])\nAddVertexByLabel(label T, options ...VertexOptionFunc) *Vertex[T]\nAddVertex(v *Vertex[T])\nGetVertexByID(label T) *Vertex[T]\nGetAllVerticesByID(label ...T) []*Vertex[T]\nGetAllVertices() []*Vertex[T]\nRemoveVertices(vertices ...*Vertex[T])\nContainsEdge(from, to *Vertex[T]) bool\nContainsVertex(v *Vertex[T]) bool\n}\n```\n\nThe generic type of the `T` in `Graph` interface represents the vertex label. The type of `T`\nshould be comparable. You cannot use slices and function types for `T`.\n\n#### Directed\n\n![directed-graph](https://user-images.githubusercontent.com/11541936/221904292-face2083-16da-491f-a339-2164b7040264.png)\n\n```go\ngraph := New[int](gograph.Directed())\n\ngraph.AddEdge(gograph.NewVertex(1), gograph.NewVertex(2))\ngraph.AddEdge(gograph.NewVertex(1), gograph.NewVertex(3))\ngraph.AddEdge(gograph.NewVertex(2), gograph.NewVertex(2))\ngraph.AddEdge(gograph.NewVertex(3), gograph.NewVertex(4))\ngraph.AddEdge(gograph.NewVertex(4), gograph.NewVertex(5))\ngraph.AddEdge(gograph.NewVertex(5), gograph.NewVertex(6))\n```\n\n#### Acyclic\n\n![acyclic-graph](https://user-images.githubusercontent.com/11541936/221911652-ce2dfb5f-5547-4f26-8412-94ad9124d4fa.png)\n\n```go\ngraph := New[int](gograph.Acyclic())\n\ngraph.AddEdge(gograph.NewVertex(1), gograph.NewVertex(2))\ngraph.AddEdge(gograph.NewVertex(2), gograph.NewVertex(3))\n_, err := graph.AddEdge(gograph.NewVertex(3), gograph.NewVertex(1))\nif err != nil {\n// do something\n}\n```\n\n#### Undirected\n\n![undirected-graph](https://user-images.githubusercontent.com/11541936/221908261-a009049d-2b71-46c3-9026-faa4dcc2a693.png)\n\n```go\n// by default graph is undirected\ngraph := New[string]()\n\ngraph.AddEdge(gograph.NewVertex(\"A\"), gograph.NewVertex(\"B\"))\ngraph.AddEdge(gograph.NewVertex(\"A\"), gograph.NewVertex(\"D\"))\ngraph.AddEdge(gograph.NewVertex(\"B\"), gograph.NewVertex(\"C\"))\ngraph.AddEdge(gograph.NewVertex(\"B\"), gograph.NewVertex(\"D\"))\n```\n\n#### Weighted\n\n![weighted-edge](https://user-images.githubusercontent.com/11541936/221908269-b6db15fb-6104-49d9-b9b9-acc062d94e4a.png)\n\n```go\ngraph := New[string]()\n\nvA := gograph.AddVertexByLabel(\"A\")\nvB := gograph.AddVertexByLabel(\"B\")\nvC := gograph.AddVertexByLabel(\"C\")\nvD := gograph.AddVertexByLabel(\"D\")\n\ngraph.AddEdge(vA, vB, gograph.WithEdgeWeight(4))\ngraph.AddEdge(vA, vD, gograph.WithEdgeWeight(3))\ngraph.AddEdge(vB, vC, gograph.WithEdgeWeight(3))\ngraph.AddEdge(vB, vD, gograph.WithEdgeWeight(1))\ngraph.AddEdge(vC, vD, gograph.WithEdgeWeight(2))\n```\n\n![weighted-vertex](https://user-images.githubusercontent.com/11541936/221908278-83f3138d-8b28-4c38-825a-627a46d65294.png)\n\n```go\ngraph := New[string]()\nvA := gograph.AddVertexByLabel(\"A\", gograph.WithVertexWeight(3))\nvB := gograph.AddVertexByLabel(\"B\", gograph.WithVertexWeight(2))\nvC := gograph.AddVertexByLabel(\"C\", gograph.WithVertexWeight(4))\n\ngraph.AddEdge(vA, vB)\ngraph.AddEdge(vB, vC)\n```\n\n### Traverse\n\nTraverse package provides the iterator interface that guarantees all the algorithm export the same APIs:\n\n```go\ntype Iterator[T comparable] interface {\n\tHasNext() bool\n\tNext() *gograph.Vertex[T]\n\tIterate(func(v *gograph.Vertex[T]) error) error\n\tReset()\n}\n```\n\nThis package contains the following iterators:\n\n- [Breadth-First iterator](https://github.com/hmdsefi/gograph/tree/master/traverse#BFS)\n- [Depth-First iterator](https://github.com/hmdsefi/gograph/tree/master/traverse#DFS)\n- [Topological iterator](https://github.com/hmdsefi/gograph/tree/master/traverse#Topological-Sort)\n- [Closest-First iterator](https://github.com/hmdsefi/gograph/tree/master/traverse#Closest-First)\n- [Random Walk iterator](https://github.com/hmdsefi/gograph/tree/master/traverse#random-walk)\n\n## License\n\nApache License, please see [LICENSE](https://github.com/hmdsefi/gograph/blob/master/LICENSE) for details.\n","funding_links":[],"categories":["Science and Data Analysis","科学与数据分析"],"sub_categories":["HTTP Clients","HTTP客户端"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmdsefi%2Fgograph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhmdsefi%2Fgograph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhmdsefi%2Fgograph/lists"}