ng-nx


Nameng-nx JSON
Version 0.1.8 PyPI version JSON
download
home_page
SummaryNebulaGraph NetowrkX adaptor
upload_time2023-03-27 05:53:30
maintainer
docs_urlNone
author
requires_python>=3.7.1,<3.11
licenseApache-2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <img alt="NebulaGraph NetworkX Adaptor(ng_nx)" src="https://user-images.githubusercontent.com/1651790/227207918-7c023215-b7cf-4aa5-b734-bc50411dab77.png">

<p align="center">
    <em>Manipulation of graphs in NebulaGraph using the NetworkX API.</em>
</p>

<p align="center">
<a href="LICENSE" target="_blank">
    <img src="https://img.shields.io/badge/License-Apache_2.0-blue.svg" alt="License">
</a>

<a href="https://badge.fury.io/py/ng_nx" target="_blank">
    <img src="https://badge.fury.io/py/ng_nx.svg" alt="PyPI version">
</a>

<a href="https://pdm.fming.dev" target="_blank">
    <img src="https://img.shields.io/badge/pdm-managed-blueviolet" alt="pdm-managed">
</a>

<!-- <a href="https://github.com/wey-gu/nebulagraph-nx/actions/workflows/ci.yml">
  <img src="https://github.com/wey-gu/nebulagraph-nx/actions/workflows/ci.yml/badge.svg" alt="Tests">
</a> -->

</p>

---

**Documentation**: <a href="https://github.com/wey-gu/nebulagraph-nx#documentation" target="_blank">https://github.com/wey-gu/nebulagraph-nx#documentation</a>

**Source Code**: <a href="https://github.com/wey-gu/nebulagraph-nx" target="_blank">https://github.com/wey-gu/nebulagraph-nx</a>

---

NebulaGraph NetworkX (ng_nx) is a tool that allows you to use the NetworkX API for manipulating graphs in NebulaGraph. It makes it easy to analyze and manipulate graphs using NebulaGraph's advanced capabilities while still using the familiar NetworkX interface. In short, ng_nx bridges the gap between NebulaGraph and NetworkX.

## Quick Start

### Install

```bash
pip install ng_nx
```

### Run Algorithm on NebulaGraph

```python
from ng_nx import NebulaReader
from ng_nx.utils import NebulaGraphConfig

import networkx as nx

config = NebulaGraphConfig()

reader = NebulaReader(
    space="basketballplayer",
    edges=["follow", "serve"],
    properties=[["degree"], ["start_year", "end_year"]],
    nebula_config=config, limit=10000)

g = reader.read()

pr = nx.pagerank(
    g, alpha=0.85,
    max_iter=100,
    tol=1e-06,
    weight='degree')

import community as community_louvain

ug = g.to_undirected()
louvain = community_louvain.best_partition(ug)
```

### Write Result to NebulaGraph

#### Create Schema for the result writing

```ngql
CREATE TAG IF NOT EXISTS pagerank (
    pagerank double NOT NULL
);

CREATE TAG IF NOT EXISTS louvain (
    cluster_id int NOT NULL
);
```

```python
from ng_nx import NebulaWriter

pr_writer = NebulaWriter(data=pr, nebula_config=config)

# properties to write
properties = ["pagerank"]

pr_writer.set_options(
    label="pagerank",
    properties=properties,
    batch_size=256,
    write_mode="insert",
    sink="nebulagraph_vertex",
)
# write back to NebulaGraph
pr_writer.write()

# write louvain result

louvain_writer = NebulaWriter(data=louvain, nebula_config=config)
# properties to write
properties = ["cluster_id"]
louvain_writer.set_options(
    label="louvain",
    properties=properties,
    batch_size=256,
    write_mode="insert",
    sink="nebulagraph_vertex",
)
louvain_writer.write()
```


## Documentation

[API Reference](https://github.com/wey-gu/nebulagraph-nx/blob/main/docs/API.md)

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ng-nx",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.1,<3.11",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Wey Gu <weyl.gu@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/99/82/fb70b87fc591f4cdf904e676f0652c9986fc617b84ec7d66c1fc28199b9d/ng-nx-0.1.8.tar.gz",
    "platform": null,
    "description": "<img alt=\"NebulaGraph NetworkX Adaptor(ng_nx)\" src=\"https://user-images.githubusercontent.com/1651790/227207918-7c023215-b7cf-4aa5-b734-bc50411dab77.png\">\n\n<p align=\"center\">\n    <em>Manipulation of graphs in NebulaGraph using the NetworkX API.</em>\n</p>\n\n<p align=\"center\">\n<a href=\"LICENSE\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/License-Apache_2.0-blue.svg\" alt=\"License\">\n</a>\n\n<a href=\"https://badge.fury.io/py/ng_nx\" target=\"_blank\">\n    <img src=\"https://badge.fury.io/py/ng_nx.svg\" alt=\"PyPI version\">\n</a>\n\n<a href=\"https://pdm.fming.dev\" target=\"_blank\">\n    <img src=\"https://img.shields.io/badge/pdm-managed-blueviolet\" alt=\"pdm-managed\">\n</a>\n\n<!-- <a href=\"https://github.com/wey-gu/nebulagraph-nx/actions/workflows/ci.yml\">\n  <img src=\"https://github.com/wey-gu/nebulagraph-nx/actions/workflows/ci.yml/badge.svg\" alt=\"Tests\">\n</a> -->\n\n</p>\n\n---\n\n**Documentation**: <a href=\"https://github.com/wey-gu/nebulagraph-nx#documentation\" target=\"_blank\">https://github.com/wey-gu/nebulagraph-nx#documentation</a>\n\n**Source Code**: <a href=\"https://github.com/wey-gu/nebulagraph-nx\" target=\"_blank\">https://github.com/wey-gu/nebulagraph-nx</a>\n\n---\n\nNebulaGraph NetworkX (ng_nx) is a tool that allows you to use the NetworkX API for manipulating graphs in NebulaGraph. It makes it easy to analyze and manipulate graphs using NebulaGraph's advanced capabilities while still using the familiar NetworkX interface. In short, ng_nx bridges the gap between NebulaGraph and NetworkX.\n\n## Quick Start\n\n### Install\n\n```bash\npip install ng_nx\n```\n\n### Run Algorithm on NebulaGraph\n\n```python\nfrom ng_nx import NebulaReader\nfrom ng_nx.utils import NebulaGraphConfig\n\nimport networkx as nx\n\nconfig = NebulaGraphConfig()\n\nreader = NebulaReader(\n    space=\"basketballplayer\",\n    edges=[\"follow\", \"serve\"],\n    properties=[[\"degree\"], [\"start_year\", \"end_year\"]],\n    nebula_config=config, limit=10000)\n\ng = reader.read()\n\npr = nx.pagerank(\n    g, alpha=0.85,\n    max_iter=100,\n    tol=1e-06,\n    weight='degree')\n\nimport community as community_louvain\n\nug = g.to_undirected()\nlouvain = community_louvain.best_partition(ug)\n```\n\n### Write Result to NebulaGraph\n\n#### Create Schema for the result writing\n\n```ngql\nCREATE TAG IF NOT EXISTS pagerank (\n    pagerank double NOT NULL\n);\n\nCREATE TAG IF NOT EXISTS louvain (\n    cluster_id int NOT NULL\n);\n```\n\n```python\nfrom ng_nx import NebulaWriter\n\npr_writer = NebulaWriter(data=pr, nebula_config=config)\n\n# properties to write\nproperties = [\"pagerank\"]\n\npr_writer.set_options(\n    label=\"pagerank\",\n    properties=properties,\n    batch_size=256,\n    write_mode=\"insert\",\n    sink=\"nebulagraph_vertex\",\n)\n# write back to NebulaGraph\npr_writer.write()\n\n# write louvain result\n\nlouvain_writer = NebulaWriter(data=louvain, nebula_config=config)\n# properties to write\nproperties = [\"cluster_id\"]\nlouvain_writer.set_options(\n    label=\"louvain\",\n    properties=properties,\n    batch_size=256,\n    write_mode=\"insert\",\n    sink=\"nebulagraph_vertex\",\n)\nlouvain_writer.write()\n```\n\n\n## Documentation\n\n[API Reference](https://github.com/wey-gu/nebulagraph-nx/blob/main/docs/API.md)\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "NebulaGraph NetowrkX adaptor",
    "version": "0.1.8",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "27fcfd86d6e55d4413b71f5d0c24233f81e1b621404bcceb6ca2de768cb1f8c0",
                "md5": "fe1bba926e88cacf865d355f3b4b3c70",
                "sha256": "cd221fcf97b2faeaed12aa1cf4b9f982877ad1018a6ccb2b6e81f5a865dabca0"
            },
            "downloads": -1,
            "filename": "ng_nx-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fe1bba926e88cacf865d355f3b4b3c70",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.1,<3.11",
            "size": 11413,
            "upload_time": "2023-03-27T05:53:27",
            "upload_time_iso_8601": "2023-03-27T05:53:27.435441Z",
            "url": "https://files.pythonhosted.org/packages/27/fc/fd86d6e55d4413b71f5d0c24233f81e1b621404bcceb6ca2de768cb1f8c0/ng_nx-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9982fb70b87fc591f4cdf904e676f0652c9986fc617b84ec7d66c1fc28199b9d",
                "md5": "99ba22d1a41a2c9767428236bd355136",
                "sha256": "a3a0ad3ef56c49c1ef68dcb503a279a9d8345ee103ac8066d23985ac0df933c5"
            },
            "downloads": -1,
            "filename": "ng-nx-0.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "99ba22d1a41a2c9767428236bd355136",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.1,<3.11",
            "size": 11804,
            "upload_time": "2023-03-27T05:53:30",
            "upload_time_iso_8601": "2023-03-27T05:53:30.007459Z",
            "url": "https://files.pythonhosted.org/packages/99/82/fb70b87fc591f4cdf904e676f0652c9986fc617b84ec7d66c1fc28199b9d/ng-nx-0.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-27 05:53:30",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "ng-nx"
}
        
Elapsed time: 0.06682s