{"id":15673979,"url":"https://github.com/s1ck/nom-gdl","last_synced_at":"2025-11-11T11:16:24.781Z","repository":{"id":46575987,"uuid":"343205614","full_name":"s1ck/nom-gdl","owner":"s1ck","description":"Graph Definition Language in Rust","archived":false,"fork":false,"pushed_at":"2023-02-12T21:15:56.000Z","size":54,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-26T23:16:52.410Z","etag":null,"topics":["cypher","gdl","hacktoberfest","nom","parser","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/s1ck.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}},"created_at":"2021-02-28T20:18:20.000Z","updated_at":"2024-09-03T18:32:55.000Z","dependencies_parsed_at":"2024-10-23T11:26:25.680Z","dependency_job_id":null,"html_url":"https://github.com/s1ck/nom-gdl","commit_stats":{"total_commits":71,"total_committers":4,"mean_commits":17.75,"dds":0.3802816901408451,"last_synced_commit":"c824734b79ae9ea396f5f19e67f79b6cb5931119"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1ck%2Fnom-gdl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1ck%2Fnom-gdl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1ck%2Fnom-gdl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s1ck%2Fnom-gdl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s1ck","download_url":"https://codeload.github.com/s1ck/nom-gdl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252775894,"owners_count":21802455,"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":["cypher","gdl","hacktoberfest","nom","parser","rust"],"created_at":"2024-10-03T15:43:18.738Z","updated_at":"2025-11-11T11:16:24.724Z","avatar_url":"https://github.com/s1ck.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Graph Definition Language (GDL)\n\nInspired by the [Neo4j Cypher](http://neo4j.com/docs/stable/cypher-query-lang.html) query language, GDL allows the simple definition of property graphs.\nGDL contains a parser and simple structs that represent the property graph and its elements.\nThe Rust implementation is inspired by my [Java implementation](https://github.com/s1ck/gdl).\n\n### Property graph data model\n\nA property graph consists of nodes and relationships.\nNodes have zero or more labels, relationships have zero or one relationship type.\nBoth, nodes and relationships have properties, organized as key-value-pairs.\nRelationships are directed, starting at a source node and pointing at a target node.\n\n### Quickstart example\n\n```rust\nuse gdl::{CypherValue, Graph};\nuse std::rc::Rc;\n\nlet gdl_string = \"(alice:Person { name: 'Alice', age: 23 }),\n                  (bob:Person { name: 'Bob', age: 42 }),\n                  (alice)-[r:KNOWS { since: 1984 }]-\u003e(bob)\";\n\nlet graph = gdl_string.parse::\u003cgdl::Graph\u003e().unwrap();\n\nassert_eq!(graph.node_count(), 2);\nassert_eq!(graph.relationship_count(), 1);\n\nlet alice = graph.get_node(\"alice\").unwrap();\nassert_eq!(alice.property_value(\"age\"), Some(\u0026CypherValue::from(23)));\nassert_eq!(alice.property_value(\"name\"), Some(\u0026CypherValue::from(\"Alice\")));\n\nlet relationship = graph.get_relationship(\"r\").unwrap();\nassert_eq!(relationship.rel_type(), Some(\"KNOWS\"));\n```\n\n### More GDL language examples\n\nDefine a node:\n\n```rust\nlet g = \"()\".parse::\u003cgdl::Graph\u003e().unwrap();\n\nassert_eq!(g.node_count(), 1);\n```\n\nDefine a node and assign it to variable `alice`:\n\n```rust\nlet g = \"(alice)\".parse::\u003cgdl::Graph\u003e().unwrap();\n\nassert!(g.get_node(\"alice\").is_some());\n```\n\nDefine a node with label `User` and multiple properties:\n\n```rust\nlet g = \"(alice:User { name: 'Alice', age : 23 })\".parse::\u003cgdl::Graph\u003e().unwrap();\n\nassert_eq!(g.get_node(\"alice\").unwrap().labels().collect::\u003cVec\u003c_\u003e\u003e(), vec![\"User\"]);\nassert!(g.get_node(\"alice\").unwrap().property_value(\"name\").is_some());\nassert!(g.get_node(\"alice\").unwrap().property_value(\"age\").is_some());\n```\n\n Define an outgoing relationship:\n\n```rust\nlet g = \"(alice)--\u003e()\".parse::\u003cgdl::Graph\u003e().unwrap();\n\nassert_eq!(g.relationship_count(), 1);\n```\n\nDefine an incoming relationship:\n\n```rust\nlet g = \"(alice)\u003c--()\".parse::\u003cgdl::Graph\u003e().unwrap();\n\nassert_eq!(g.relationship_count(), 1);\n```\n\nDefine a relationship with type `KNOWS`, assign it to variable `r1` and add a property:\n\n```rust\nuse std::rc::Rc;\n\nlet g = \"(alice)-[r1:KNOWS { since : 2014 }]-\u003e(bob)\".parse::\u003cgdl::Graph\u003e().unwrap();\n\nassert!(g.get_relationship(\"r1\").is_some());\nassert_eq!(g.get_relationship(\"r1\").unwrap().rel_type(), Some(\"KNOWS\"));\n```\n\nDefine multiple outgoing relationships from the same source node (i.e. `alice`):\n\n```rust\nlet g = \"\n    (alice)-[r1:KNOWS { since : 2014 }]-\u003e(bob)\n    (alice)-[r2:KNOWS { since : 2013 }]-\u003e(eve)\n\".parse::\u003cgdl::Graph\u003e().unwrap();\n\nassert_eq!(g.node_count(), 3);\nassert_eq!(g.relationship_count(), 2);\n```\n\nDefine paths (four nodes and three relationships are created):\n\n```rust\nlet g = \"()--\u003e()\u003c--()--\u003e()\".parse::\u003cgdl::Graph\u003e().unwrap();\n\nassert_eq!(g.node_count(), 4);\nassert_eq!(g.relationship_count(), 3);\n```\n\nPaths can be comma separated to express arbitrary complex patterns:\n\n```rust\nlet g = \"\n    ()--\u003e()\u003c--()--\u003e(),\n    ()\u003c--()--\u003e()--\u003e(),\n    ()--\u003e()\u003c--()--\u003e()\n\".parse::\u003cgdl::Graph\u003e().unwrap();\n\nassert_eq!(g.node_count(), 12);\nassert_eq!(g.relationship_count(), 9);\n```\n\n### License\n\nApache 2.0 or MIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs1ck%2Fnom-gdl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs1ck%2Fnom-gdl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs1ck%2Fnom-gdl/lists"}