NebulaGraph NetowrkX adaptor
Project description
Manipulation of graphs in NebulaGraph using the NetworkX API.
Documentation: https://github.com/wey-gu/nebulagraph-nx#documentation
Source Code: https://github.com/wey-gu/nebulagraph-nx
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
pip install ng_nx
Run Algorithm on NebulaGraph
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
CREATE TAG IF NOT EXISTS pagerank (
pagerank double NOT NULL
);
CREATE TAG IF NOT EXISTS louvain (
cluster_id int NOT NULL
);
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ng-nx-0.1.8.tar.gz
.
File metadata
- Download URL: ng-nx-0.1.8.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.4.9 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3a0ad3ef56c49c1ef68dcb503a279a9d8345ee103ac8066d23985ac0df933c5 |
|
MD5 | 99ba22d1a41a2c9767428236bd355136 |
|
BLAKE2b-256 | 9982fb70b87fc591f4cdf904e676f0652c9986fc617b84ec7d66c1fc28199b9d |
File details
Details for the file ng_nx-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: ng_nx-0.1.8-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.4.9 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd221fcf97b2faeaed12aa1cf4b9f982877ad1018a6ccb2b6e81f5a865dabca0 |
|
MD5 | fe1bba926e88cacf865d355f3b4b3c70 |
|
BLAKE2b-256 | 27fcfd86d6e55d4413b71f5d0c24233f81e1b621404bcceb6ca2de768cb1f8c0 |