Convert ArangoDB graphs to NetworkX & vice-versa.
Project description
ArangoDB-Networkx-cuGraph Adapter
The ArangoDB-Networkx-cuGraph Adapter exports Graphs from ArangoDB, a multi-model Graph Database, into NetworkX, the swiss army knife for graph analysis with python, and vice-versa. Additionally you can export ArangoDB graphs into RAPIDS cuGraph library, which is a collection of GPU accelerated graph algorithms.
About NetworkX
Networkx is a commonly used tool for analysis of network-data. If your analytics use cases require the use of all your graph data, for example, to summarize graph structure, or answer global path traversal queries, then using the ArangoDB Pregel API is recommended. If your analysis pertains to a subgraph, then you may be interested in getting the Networkx representation of the subgraph for one of the following reasons:
1. An algorithm for your use case is available in Networkx.
2. A library that you want to use for your use case works with Networkx Graphs as input.
About RAPIDS cuGraph
While offering a similar API and set of graph algorithms to NetworkX, RAPIDS cuGraph library is GPU based. Especially for large graphs, this results in a significant performance improvement of cuGraph compared to NetworkX. Please note that storing node attributes is currently not supported by cuGraph. In order to run cuGraph, a Nvidia CUDA enabled GPU is required.
Quickstart: ArangoDB → NetworkX
# Import the ArangoDB-NetworkX-cuGraph Adapter
from adbnx_adapter.adapter import ADBNX_Adapter
# Import a sample graph from NetworkX
from networkx import grid_2d_graph
# This is the connection information for your ArangoDB instance
# (Let's assume that the ArangoDB fraud-detection data dump is imported to this endpoint)
con = {
"hostname": "localhost",
"protocol": "http",
"port": 8529,
"username": "root",
"password": "rootpassword",
"dbName": "_system",
}
# This instantiates your ADBNX Adapter with your connection credentials
adbnx_adapter = ADBNX_Adapter(con)
# ArangoDB to NetworkX via Graph
nx_fraud_graph = adbnx_adapter.arangodb_graph_to_networkx("fraud-detection")
# ArangoDB to NetworkX via Collections
nx_fraud_graph_2 = adbnx_adapter.arangodb_collections_to_networkx(
"fraud-detection",
{"account", "bank", "branch", "Class", "customer"}, # Specify vertex collections
{"accountHolder", "Relationship", "transaction"} # Specify edge collections
)
# ArangoDB to NetworkX via Metagraph
metagraph = {
"vertexCollections": {
"account": {"Balance", "account_type", "customer_id", "rank"},
"customer": {"Name", "rank"},
},
"edgeCollections": {
"transaction": {"transaction_amt", "sender_bank_id", "receiver_bank_id"},
"accountHolder": {},
},
}
nx_fraud_graph_3 = adbnx_adapter.arangodb_to_networkx("fraud-detection", metagraph)
# NetworkX to ArangoDB
nx_grid_graph = grid_2d_graph(5, 5)
adb_grid_edge_definitions = [
{
"edge_collection": "to",
"from_vertex_collections": ["Grid_Node"],
"to_vertex_collections": ["Grid_Node"],
}
]
adb_grid_graph = adbnx_adapter.networkx_to_arangodb("Grid", nx_grid_graph, adb_grid_edge_definitions)
Quickstart: ArangoDB → cuGraph
# Import the ArangoDB-NetworkX-cuGraph Adapter
from adbnx_adapter.adapter import ADBNX_Adapter
# This is the connection information for your ArangoDB instance
# (Let's assume that the ArangoDB fraud-detection data dump is imported to this endpoint)
con = {
"hostname": "localhost",
"protocol": "http",
"port": 8529,
"username": "root",
"password": "rootpassword",
"dbName": "_system",
}
# This instantiates your ADBNX Adapter with your connection credentials
adbnx_adapter = ADBNX_Adapter(con)
# ArangoDB to cuGraph via Graph
nx_fraud_graph = adbnx_adapter.arangodb_graph_to_cugraph("fraud-detection")
# ArangoDB to cuGraph via Collections
nx_fraud_graph_2 = adbnx_adapter.arangodb_collections_to_cugraph(
"fraud-detection",
{"account", "bank", "branch", "Class", "customer"}, # Specify vertex collections
{"accountHolder", "Relationship", "transaction"} # Specify edge collections
)
Development & Testing
Prerequisite: arangorestore
must be installed
git clone https://github.com/arangoml/networkx-adapter.git
cd networkx-adapter
python -m venv .venv
source .venv/bin/activate
(MacOS) or.venv/scripts/activate
(Windows)pip install -e .[dev]
pytest
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 adbnx_adapter-3.1.1.tar.gz
.
File metadata
- Download URL: adbnx_adapter-3.1.1.tar.gz
- Upload date:
- Size: 26.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd380e345ab590b162aeea02312a9fb9274d722bcbf63be4de08e0597d09822c |
|
MD5 | 3df098664a44d11b02c418c1bfd65670 |
|
BLAKE2b-256 | 7fddafc57243484bceec95178195f0ae8d069f04ce43938aa8140adc4d6f0cd2 |
File details
Details for the file adbnx_adapter-3.1.1-py3-none-any.whl
.
File metadata
- Download URL: adbnx_adapter-3.1.1-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c14a852a7429df9b7956fc0a537ef265ef77e7a1ba6804aaf92b731a69e1f32 |
|
MD5 | 5f2249311a6574278dc30d02dd22c904 |
|
BLAKE2b-256 | 93af8cb46b3bbea441ed34531db77c997b6e9f5a6b1d1ee5585cdbba5b04a57d |