{"id":21068947,"url":"https://github.com/cloudprivacylabs/lpg","last_synced_at":"2025-05-16T03:33:47.555Z","repository":{"id":59044321,"uuid":"528261801","full_name":"cloudprivacylabs/lpg","owner":"cloudprivacylabs","description":"Labeled property graphs","archived":false,"fork":false,"pushed_at":"2023-10-02T14:50:52.000Z","size":2563,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"v2","last_synced_at":"2023-11-03T00:03:02.803Z","etag":null,"topics":["go","golang","graph","labeled-graphs"],"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/cloudprivacylabs.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}},"created_at":"2022-08-24T04:16:16.000Z","updated_at":"2023-10-02T14:56:08.000Z","dependencies_parsed_at":"2023-10-02T18:43:39.775Z","dependency_job_id":null,"html_url":"https://github.com/cloudprivacylabs/lpg","commit_stats":null,"previous_names":[],"tags_count":18,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Flpg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Flpg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Flpg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudprivacylabs%2Flpg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudprivacylabs","download_url":"https://codeload.github.com/cloudprivacylabs/lpg/tar.gz/refs/heads/v2","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225405271,"owners_count":17469317,"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":["go","golang","graph","labeled-graphs"],"created_at":"2024-11-19T18:29:39.151Z","updated_at":"2024-11-19T18:29:39.949Z","avatar_url":"https://github.com/cloudprivacylabs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GoDoc](https://godoc.org/github.com/cloudprivacylabs/lpg?status.svg)](https://godoc.org/github.com/cloudprivacylabs/lpg/v2)\n[![Go Report Card](https://goreportcard.com/badge/github.com/cloudprivacylabs/lpg)](https://goreportcard.com/report/github.com/cloudprivacylabs/lpg/v2)\n[![Build Status](https://github.com/cloudprivacylabs/lpg/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/cloudprivacylabs/lpg/actions/workflows/CI.yml)\n# Labeled property graphs\n\nThis labeled property graph package implements the openCypher model of\nlabeled property graphs. A labeled property graph (LPG) contains nodes\nand directed edges between those nodes. Every node contains:\n\n  * Labels: Set of string tokens that usually identify the type of the\n    node,\n  * Properties: Key-value pairs.\n  \nEvery edge contains:\n  * A label: String token that identifies a relationship, and\n  * Properties: Key-value pairs.\n\nA `Graph` objects keeps an index of the nodes and edges included in\nit. Create a graph using `NewGraph` function:\n\n```\ng := lpg.NewGraph()\n// Create two nodes\nn1 := g.NewNode([]string{\"label1\"},map[string]any{\"prop\": \"value1\" })\nn2 := g.NewNode([]string{\"label2\"},map[string]any{\"prop\": \"value2\" })\n// Connect the two nodes with an edge\nedge:=g.NewEdge(n1,n2,\"relatedTo\",nil)\n```\n\nThe LPG library uses iterators to address nodes and edges.\n\n``` go\nfor nodes:=graph.GetNodes(); nodes.Next(); {\n  node:=nodes.Node()\n}\nfor edges:=graph.GetEdges(); edges.Next(); {\n  edge:edges.Edge()\n}\n```\n\nEvery node knows its adjacent edges. \n\n```go\n// Get outgoing edges\nfor edges:=node1.GetEdges(lpg.OutgoingEdge); edges.Next(); {\n  edge:=edges.Edge\n}\n\n// Get all edges\nfor edges:=node1.GetEdges(lpg.AnyEdge); edges.Next(); {\n  edge:=edges.Edge\n}\n```\n\nThe graph indexes nodes by label, so access to nodes using labels is\nfast. You can add additional indexes on properties:\n\n```\ng := lpg.NewGraph()\n// Index all nodes with property 'prop'\ng.AddNodePropertyIndex(\"prop\")\n\n// This access should be fast\nnodes := g.GetNodesWithProperty(\"prop\")\n\n// This will go through all nodes\nslowNodes:= g.GetNodesWithProperty(\"propWithoutIndex\")\n```\n\n## Pattern Searches\n\nGraph library supports searching patterns within a graph. The\nfollowing example searches for the pattern that match\n\n```\n(:label1) -[]-\u003e({prop:value})`\n```\n\nand returns the head nodes for every matching path:\n\n```\npattern := lpg.Pattern{ \n // Node containing label 'label1'\n {\n   Labels: lpg.NewStringSet(\"label1\"),\n },\n // Edge of length 1\n {\n   Min: 1, \n   Max: 1,\n },\n // Node with property prop=value\n {\n   Properties: map[string]interface{} {\"prop\":\"value\"},\n }}\nnodes, err:=pattern.FindNodes(g,nil)\n```\n\nVariable length paths are supported:\n\n``` go\npattern := lpg.Pattern{ \n // Node containing label 'label1'\n {\n   Labels: lpg.NewStringSet(\"label1\"),\n },\n // Minimum paths of length 2, no maximum length\n {\n   Min: 2, \n   Max: -1,\n },\n // Node with property prop=value\n {\n   Properties: map[string]interface{} {\"prop\":\"value\"},\n }}\n\n```\n\n## JSON Encoding\n\nThis graph library uses the following JSON representation:\n\n```\n{\n  \"nodes\": [\n     {\n       \"n\": 0,\n       \"labels\": [ \"l1\", \"l2\",... ],\n       \"properties\": {\n          \"key1\": value,\n          \"key2\": value,\n          ...\n        },\n        \"edges\": [\n           {\n             \"to\": \"1\",\n             \"label\": \"edgeLabel\",\n             \"properties\": {\n               \"key1\": value,\n               \"key2\": value,\n               ...\n             }\n           },\n           ...\n        ]\n     },\n      ...\n  ],\n  \"edges\": [\n     {\n        \"from\": 0,\n        \"to\": 1,\n        \"label\": \"edgeLabel\",\n        \"properties\": {\n           \"key1\": value1,\n           \"key2\": value2,\n           ...\n        }\n     },\n     ...\n  ]\n}\n```\n\nAll graph nodes are under the `nodes` key as an array. The `n` key\nidentifies the node using a unique index. All node references in edges\nuse these indexes. A node may include all outgoing edges embedded in\nit, or edges may be included under a separate top-level array\n`edges`. If the edge is included in the node, the edge only has a `to`\nfield that gives the target node index as the node containing the edge\nis assumed to be the source node. Edges under the top-level `edges`\narray include both a `from` and a `to` index.\n\nStandard library JSON marshaler/unmarshaler does not work with graphs,\nbecause the edge and node property values are of type\n`any`. The `JSON` struct can be used to marshal and unmarshal\ngraphs with custom property marshaler and unmarshalers.\n\nThis Go module is part of the [Layered Schema\nArchitecture](https://layeredschemas.org).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudprivacylabs%2Flpg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudprivacylabs%2Flpg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudprivacylabs%2Flpg/lists"}