{"id":17002610,"url":"https://github.com/johnfercher/graph-study","last_synced_at":"2026-04-20T10:02:41.341Z","repository":{"id":99038505,"uuid":"269975696","full_name":"johnfercher/graph-study","owner":"johnfercher","description":null,"archived":false,"fork":false,"pushed_at":"2020-06-19T23:59:01.000Z","size":1837,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-01T16:01:36.984Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/johnfercher.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":"2020-06-06T12:31:07.000Z","updated_at":"2024-06-19T09:14:32.747Z","dependencies_parsed_at":null,"dependency_job_id":"e39506ab-9626-4b6c-9dfb-e6389af53ac0","html_url":"https://github.com/johnfercher/graph-study","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/johnfercher/graph-study","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnfercher%2Fgraph-study","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnfercher%2Fgraph-study/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnfercher%2Fgraph-study/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnfercher%2Fgraph-study/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnfercher","download_url":"https://codeload.github.com/johnfercher/graph-study/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnfercher%2Fgraph-study/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32042293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-14T04:28:31.611Z","updated_at":"2026-04-20T10:02:41.282Z","avatar_url":"https://github.com/johnfercher.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphStudy\n\nThis repository contains a graph study, handling specifically trees. Here are two approaches to deal with graphs,\nthe first solution uses a [MySQL](mysql.com) database, which contains tables that represents vertices and edges,\nand the second solution uses a [Neo4j](https://neo4j.com/) database, which is graph based.\n\nThe idea is to compare the performance from both approaches to solve common graph problems. There is a REST API which\ncalls both databases and saves information. The API was written in Golang and here is the [postman collection](docs).\n\n## Data\n| Id | Type | ParentId |\n|---|---|---|\n| c37e04a4-01e6-4b6f-bb34-94bc60dd1495 | A (Root) | NULL |\n| 77d0b81c-612a-4a5a-919f-2f7f6e4de91d | B | c37e04a4-01e6-4b6f-bb34-94bc60dd1495 |\n| 4ab50ac3-6ec6-421a-8b27-4687f7bc6572 | B | c37e04a4-01e6-4b6f-bb34-94bc60dd1495 |\n| ... | ... | ... |\n\n## MySQL\n\n### Config\n```\n$ cd mysql\n$ bash build.sh\n$ bash run.sh\n$ docker ps // obtain the \u003ccontainer_id\u003e\n$ bash initdb.sh\nContainer ID: \u003ccontainer_id\u003e\n```\n\n### Run\n```\n$ bash run.sh\n```\n\n### Stop\n```\n$ docker ps // obtain the \u003ccontainer_id\u003e\n$ docker stop \u003ccontainer_id\u003e\n```\n\n## Neo4j\n\n### Config\n```\n$ cd neo4j\n$ bash build.sh\n$ bash run.sh\n$ docker ps // obtain the \u003ccontainer_id\u003e\n$ bash initdb.sh\nContainer ID: \u003ccontainer_id\u003e\n```\n\n### Run\n```\n$ bash run.sh\n```\n\n### Stop\n```\n$ docker ps // obtain the \u003ccontainer_id\u003e\n$ docker stop \u003ccontainer_id\u003e\n```\n\n## Queries\n\n### Recursive Tree\n**SQL**\n```sql\nWITH RECURSIVE get_vertices AS (\n    SELECT\n        c.id as vertex_id\n         , cp.parent_id\n    FROM vertex as c\n             LEFT JOIN edge cp on cp.vertex_id = c.id\n    WHERE\n            c.id = 'c37e04a4-01e6-4b6f-bb34-94bc60dd1495'\n    UNION ALL\n    SELECT\n        cp2.vertex_id\n         , cp2.parent_id\n    FROM edge cp2\n             INNER JOIN get_vertices o on o.vertex_id = cp2.parent_id\n)\nSELECT c.id, c.type, parent_id\nFROM get_vertices gc\n         JOIN vertex c on c.id = gc.vertex_id\n```\nResponse: Array\n\n**Cypher**\n```cypher\nMATCH p = (r:Vertex {id: \"c37e04a4-01e6-4b6f-bb34-94bc60dd1495\"})-[:has]-\u003e(x)\nWHERE NOT ((x)--\u003e())\nRETURN nodes(p) AS Vertices, relationships(p) AS Edges\n```\nResponse: Tree\n\n### Outgoing Relations\n**SQL**\n```\nTODO\n```\nResponse: Number\n\n**Cypher**\n```cypher\nMATCH (v:Vertex)-[r]-\u003e() WHERE v.id = 'c37e04a4-01e6-4b6f-bb34-94bc60dd1495s' RETURN COUNT(r)\n```\nResponse: Number\n\n## TODO\n- Access Neo4j from Golang API inside a docker container\n\n## Infos\n- Current Openssl openssl@1.1","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnfercher%2Fgraph-study","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnfercher%2Fgraph-study","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnfercher%2Fgraph-study/lists"}