{"id":21740143,"url":"https://github.com/bserdar/digraph","last_synced_at":"2025-03-21T01:13:03.339Z","repository":{"id":57581689,"uuid":"368018974","full_name":"bserdar/digraph","owner":"bserdar","description":"Go directed labeled/unlabeled graph data structure with constant-time accessors ","archived":false,"fork":false,"pushed_at":"2021-10-06T05:31:19.000Z","size":64,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-25T21:27:18.384Z","etag":null,"topics":["data-structures","go","golang","golang-package","graph","graph-algorithms"],"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/bserdar.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":"2021-05-17T01:07:19.000Z","updated_at":"2023-04-24T20:35:21.000Z","dependencies_parsed_at":"2022-09-26T19:31:23.062Z","dependency_job_id":null,"html_url":"https://github.com/bserdar/digraph","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bserdar%2Fdigraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bserdar%2Fdigraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bserdar%2Fdigraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bserdar%2Fdigraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bserdar","download_url":"https://codeload.github.com/bserdar/digraph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244717339,"owners_count":20498284,"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":["data-structures","go","golang","golang-package","graph","graph-algorithms"],"created_at":"2024-11-26T06:12:22.885Z","updated_at":"2025-03-21T01:13:03.317Z","avatar_url":"https://github.com/bserdar.png","language":"Go","readme":"# Digraph\n\n[![GoDoc](https://godoc.org/github.com/bserdar/digraph?status.svg)](https://godoc.org/github.com/bserdar/digraph)\n[![Go Report](https://goreportcard.com/badge/github.com/bserdar/digraph)](https://goreportcard.com/report/github.com/bserdar/digraph)\n\nThis package provides the `digraph` package that implements a directed\ngraph data structure. Nodes and edges may be labeled. The graph\nsupports application-defined structs as nodes and edges.\n\n\nThe graph structure is designed so that nodes know the outgoing edges,\nand edges know both the source and target nodes. The graph structure\nitself knows only \"some\" of the nodes, so retrieving all the nodes of\nthe graph or accessing nodes by label requires an intermediate\nstructure, the `NodeIndex`. A `NodeIndex` discovers all nodes when\nrequested, and then provides indexes access to the nodes. A\n`NodeIndex` only sees the nodes that were accessible from the `Graph`\nwhen it is created, thus it does not provide a dynamic view of the\ngraph.\n\nDigraph is not thread-safe. \n\n## Example\n\nConstruct a graph, and add nodes:\n\n```\ng:=digraph.New()\nnode1:=digraph.NewBasicNode(\"node1\",nil)\nnode2:=digraph.NewBasicNode(\"node2\",nil)\n```\n\nConnect the nodes with edges:\n\n```\n// edge node1 --edge1--\u003e node2\nedge:=g.NewBasicEdge(\"edge1\",nil)\ndigraph.Connect(node1,node2,edge)\n```\n\nGet the nodes accessible via a label:\n\n```\nn:=node1.Next(\"edge1\")\n```\n\nIf there are multiple, iterate:\n\n```\nedges:=node1.GetAllOutgoingEdgesWithLabel(\"edge1\")\nfor edges.HasNext() {\n   edge:=edges.Next()\n}\n```\n\nThe `BasicNode` and `BasicEdge` contains an application-defined\n`Payload` field. This allows for `container/list` style graph\ncontainer. It is also possible to use application-specific node and\nedge objects.\n\n```\ntype CustomNode struct {\n  digraph.NodeHeader\n  // other fields\n}\n\ntype CustomEdge struct {\n  digraph.EdgeHeader\n  // other fields\n}\n```\n\nThe `*CustomNode` and `*CustomEdge` instances can be added to the\ngraph. The embeded `NodeHeader` and `EdgeHeader` connects the object\nto the underlying graph.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbserdar%2Fdigraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbserdar%2Fdigraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbserdar%2Fdigraph/lists"}