{"id":23647075,"url":"https://github.com/wey-gu/nebulagraph-ai","last_synced_at":"2025-04-15T06:41:27.083Z","repository":{"id":94656438,"uuid":"605568634","full_name":"wey-gu/nebulagraph-ai","owner":"wey-gu","description":"(Pre Alpha)NebulaGraph AI High-Level API, do Graph Algo, Analytics in 4 lines of code.","archived":false,"fork":false,"pushed_at":"2024-08-22T11:22:03.000Z","size":5096,"stargazers_count":77,"open_issues_count":19,"forks_count":8,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-11T01:52:25.125Z","etag":null,"topics":["graph","graph-algorithms","hacktoberfest","nebulagraph","networkx","spark"],"latest_commit_sha":null,"homepage":"https://siwei.io/en/nebulagraph-ai-suite/","language":"Python","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/wey-gu.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":"2023-02-23T12:42:47.000Z","updated_at":"2025-03-18T06:13:36.000Z","dependencies_parsed_at":"2024-01-09T00:11:30.446Z","dependency_job_id":"26236007-9167-466f-b405-69b41a20d791","html_url":"https://github.com/wey-gu/nebulagraph-ai","commit_stats":null,"previous_names":["wey-gu/nebulagraph-di"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wey-gu%2Fnebulagraph-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wey-gu%2Fnebulagraph-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wey-gu%2Fnebulagraph-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wey-gu%2Fnebulagraph-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wey-gu","download_url":"https://codeload.github.com/wey-gu/nebulagraph-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023723,"owners_count":21199958,"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":["graph","graph-algorithms","hacktoberfest","nebulagraph","networkx","spark"],"created_at":"2024-12-28T13:49:14.606Z","updated_at":"2025-04-15T06:41:27.064Z","avatar_url":"https://github.com/wey-gu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg alt=\"NebulaGraph AI Suite(ng_ai)\" src=\"https://user-images.githubusercontent.com/1651790/226242809-fe488ff2-bb4a-4e7d-b23a-70865a7b3228.png\"\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cem\u003eNebulaGraph AI Suite with 4 line code to run Graph Algo on NebulaGraph\u003c/em\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\n\u003ca href=\"https://github.com/vesoft-inc/nebula\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Toolchain-NebulaGraph-blue\" alt=\"for NebulaGraph\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://hub.docker.com/extensions/weygu/nebulagraph-dd-ext\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Docker-Extension-blue?logo=docker\" alt=\"Docker Extension\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/wey-gu/nebulagraph-ai/releases\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/v/release/wey-gu/nebulagraph-ai?label=Version\" alt=\"GitHub release (latest by date)\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"LICENSE\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-Apache_2.0-blue.svg\" alt=\"License\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://badge.fury.io/py/ng_ai\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://badge.fury.io/py/ng_ai.svg\" alt=\"PyPI version\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://pdm.fming.dev\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/pdm-managed-blueviolet\" alt=\"pdm-managed\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://github.com/wey-gu/nebulagraph-ai/actions/workflows/ci.yml\"\u003e\n  \u003cimg src=\"https://github.com/wey-gu/nebulagraph-ai/actions/workflows/ci.yml/badge.svg\" alt=\"Tests\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://hub.docker.com/r/weygu/ngai-jupyter-networkx\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/docker/v/weygu/ngai-jupyter-networkx?label=nx\u0026logo=docker\" alt=\"Docker Image\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://hub.docker.com/r/weygu/pyspark-notebook-nebulagraph\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/docker/v/weygu/pyspark-notebook-nebulagraph?label=spark\u0026logo=docker\" alt=\"Docker Image\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://hub.docker.com/r/weygu/ngai-graphd\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/docker/v/weygu/ngai-graphd?label=ngai_gateway\u0026logo=docker\" alt=\"Docker Image\"\u003e\n\u003c/a\u003e\n\n\u003cimg src=\"https://img.shields.io/badge/Python-3.9-blue.svg\" alt=\"Python 3.9\"\u003e\n\n\u003c/p\u003e\n\n---\n\n**Documentation**: \u003ca href=\"https://github.com/wey-gu/nebulagraph-ai#documentation\" target=\"_blank\"\u003ehttps://github.com/wey-gu/nebulagraph-ai#documentation\u003c/a\u003e\n\n**Source Code**: \u003ca href=\"https://github.com/wey-gu/nebulagraph-ai\" target=\"_blank\"\u003ehttps://github.com/wey-gu/nebulagraph-ai\u003c/a\u003e\n\n---\n\n\nNebulaGraph AI Suite for Python (ng_ai) is a powerful Python library that offers APIs for data scientists to effectively read, write, analyze, and compute data in NebulaGraph.\n\nWith the support of a single-machine engine(NetworkX), or distributed computing environment using Spark, we could perform Graph Analysis and Algorithms on top of NebulaGraph in less than 10 lines of code, in unified and intuitive API.\n\n## Quick Start in 5 Minutes\n\n**Option 1**: Try on your Desktop. Go with [NebulaGraph Docker Extension](https://hub.docker.com/extensions/weygu/nebulagraph-dd-ext)!\n\n**Option 2**: On Linux Server? Go with Nebula-Up 👇🏻\n\n- Set up env with Nebula-Up following [this guide](https://github.com/wey-gu/nebulagraph-ai/blob/main/docs/Environment_Setup.md).\n- Install ng_ai with pip from the Jupyter Notebook with http://localhost:8888 (password: `nebula`).\n- Open the demo notebook and run cells one by one.\n- Check the [API Reference](https://github.com/wey-gu/nebulagraph-ai/blob/main/docs/API.md)\n\n## Installation\n\n```bash\npip install ng_ai\n```\n\n## Usage\n\n### Call from nGQL\n\nSee more details in the [docs](https://github.com/wey-gu/nebulagraph-ai/blob/main/docs/ng_ai_API_Gateway.md)\n\n```cypher\nRETURN ng_ai(\"pagerank\", [\"follow\"], [\"degree\"], \"spark\",\n    {space: \"basketballplayer\", max_iter: 10}, {write_mode: \"insert\"})\n```\n\n### Spark Engine Examples\n\nSee also: [examples/spark_engine.ipynb](https://github.com/wey-gu/nebulagraph-ai/blob/main/examples/spark_engine.ipynb)\n\nRun Algorithm on top of NebulaGraph:\n\n\u003e Note, there is also a query mode, refer to [examples](https://github.com/wey-gu/nebulagraph-ai/blob/main/examples/spark_engine.ipynb) or [docs](https://github.com/wey-gu/nebulagraph-ai/blob/main/docs/API.md) for more details.\n\n```python\nfrom ng_ai import NebulaReader\n\n# read data with spark engine, scan mode\nreader = NebulaReader(engine=\"spark\")\nreader.scan(edge=\"follow\", props=\"degree\")\ndf = reader.read()\n\n# run pagerank algorithm\npr_result = df.algo.pagerank(reset_prob=0.15, max_iter=10)\n```\n\nWrite back to NebulaGraph:\n\n```python\nfrom ng_ai import NebulaWriter\nfrom ng_ai.config import NebulaGraphConfig\n\nconfig = NebulaGraphConfig()\n\nproperties = {\"louvain\": \"cluster_id\"}\n\nwriter = NebulaWriter(\n    data=df_result, sink=\"nebulagraph_vertex\", config=config, engine=\"spark\")\nwriter.set_options(\n    tag=\"louvain\", vid_field=\"_id\", properties=properties,\n    batch_size=256, write_mode=\"insert\",)\nwriter.write()\n```\n\nThen we could query the result in NebulaGraph:\n\n```cypher\nMATCH (v:louvain)\nRETURN id(v), v.louvain.cluster_id LIMIT 10;\n```\n\n### NebulaGraph Engine Examples\n\nBasically the same as Spark Engine, but with `engine=\"nebula\"`, refer to [examples](https://github.com/wey-gu/nebulagraph-ai/blob/main/examples/networkx_engine.ipynb) or [docs](https://github.com/wey-gu/nebulagraph-ai/blob/main/docs/API.md) for more details.\n\n```diff\n- reader = NebulaReader(engine=\"spark\")\n+ reader = NebulaReader(engine=\"nebula\")\n```\n\n## Documentation\n\n[Environment Setup](https://github.com/wey-gu/nebulagraph-ai/blob/main/docs/Environment_Setup.md)\n\n[API Reference](https://github.com/wey-gu/nebulagraph-ai/blob/main/docs/API.md)\n\n## How it works\n\nng_ai is a unified abstraction layer for different engines, the current implementation is based on Spark, NetworkX, DGL, and NebulaGraph, but it's easy to extend to other engines like Flink, GraphScope, PyG, etc.\n\n```\n          ┌───────────────────────────────────────────────────┐\n          │   Spark Cluster                                   │\n          │    .─────.    .─────.    .─────.    .─────.       │\n          │   ;       :  ;       :  ;       :  ;       :      │\n       ┌─▶│   :       ;  :       ;  :       ;  :       ;      │\n       │  │    ╲     ╱    ╲     ╱    ╲     ╱    ╲     ╱       │\n       │  │     `───'      `───'      `───'      `───'        │\n  Algo Spark                                                  │\n    Engine└───────────────────────────────────────────────────┘\n       │  ┌────────────────────────────────────────────────────┬──────────┐\n       └──┤                                                    │          │\n          │   NebulaGraph AI Suite(ngai)                       │ ngai-api │◀─┐\n          │                                                    │          │  │\n          │                                                    └──────────┤  │\n          │     ┌────────┐    ┌──────┐    ┌────────┐   ┌─────┐            │  │\n          │     │ Reader │    │ Algo │    │ Writer │   │ GNN │            │  │\n ┌───────▶│     └────────┘    └──────┘    └────────┘   └─────┘            │  │\n │        │          │            │            │          │               │  │\n │        │          ├────────────┴───┬────────┴─────┐    └──────┐        │  │\n │        │          ▼                ▼              ▼           ▼        │  │\n │        │   ┌─────────────┐ ┌──────────────┐ ┌──────────┐┌──────────┐   │  │\n │     ┌──┤   │ SparkEngine │ │ NebulaEngine │ │ NetworkX ││ DGLEngine│   │  │\n │     │  │   └─────────────┘ └──────────────┘ └──────────┘└──────────┘   │  │\n │     │  └──────────┬────────────────────────────────────────────────────┘  │\n │     │             │        Spark                                          │\n │     │             └────────Reader ────────────┐                           │\n │  Spark                   Query Mode           │                           │\n │  Reader                                       │                           │\n │Scan Mode                                      ▼                      ┌─────────┐\n │     │  ┌───────────────────────────────────────────────────┬─────────┤ ngai-udf│◀─────────────┐\n │     │  │                                                   │         └─────────┤              │\n │     │  │  NebulaGraph Graph Engine         Nebula-GraphD   │   ngai-GraphD     │              │\n │     │  ├──────────────────────────────┬────────────────────┼───────────────────┘              │\n │     │  │                              │                    │                                  │\n │     │  │  NebulaGraph Storage Engine  │                    │                                  │\n │     │  │                              │                    │                                  │\n │     └─▶│  Nebula-StorageD             │    Nebula-Metad    │                                  │\n │        │                              │                    │                                  │\n │        └──────────────────────────────┴────────────────────┘                                  │\n │                                                                                               │\n │    ┌───────────────────────────────────────────────────────────────────────────────────────┐  │\n │    │ RETURN ng_ai(\"pagerank\", [\"follow\"], [\"degree\"], \"spark\", {space:\"basketballplayer\"}) │──┘\n │    └───────────────────────────────────────────────────────────────────────────────────────┘\n │  ┌─────────────────────────────────────────────────────────────┐\n │  │ from ng_ai import NebulaReader                              │\n │  │                                                             │\n │  │ # read data with spark engine, scan mode                    │\n │  │ reader = NebulaReader(engine=\"spark\")                       │\n │  │ reader.scan(edge=\"follow\", props=\"degree\")                  │\n └──│ df = reader.read()                                          │\n    │                                                             │\n    │ # run pagerank algorithm                                    │\n    │ pr_result = df.algo.pagerank(reset_prob=0.15, max_iter=10)  │\n    │                                                             │\n    └─────────────────────────────────────────────────────────────┘  \n```\n\n### Spark Engine Prerequisites\n- Spark 2.4, 3.0(not yet tested)\n- [NebulaGraph 3.4+](https://github.com/vesoft-inc/nebula)\n- [NebulaGraph Spark Connector 3.4+](https://repo1.maven.org/maven2/com/vesoft/nebula-spark-connector/)\n- [NebulaGraph Algorithm 3.1+](https://repo1.maven.org/maven2/com/vesoft/nebula-algorithm/)\n\n### NebulaGraph Engine Prerequisites\n- [NebulaGraph 3.4+](https://github.com/vesoft-inc/nebula)\n- [NebulaGraph Python Client 3.4+](https://github.com/vesoft-inc/nebula-python)\n- [NetworkX](https://networkx.org/)\n\n\n## Contributing\n\nSee [HACKING.md](https://github.com/wey-gu/nebulagraph-ai/blob/main/HACKING.md) for details.\n\n## License\n\nThis project is licensed under the terms of the Apache License 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwey-gu%2Fnebulagraph-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwey-gu%2Fnebulagraph-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwey-gu%2Fnebulagraph-ai/lists"}