Convert ArangoDB graphs to DGL & vice-versa.
Project description
ArangoDB-DGL Adapter
The ArangoDB-DGL Adapter exports Graphs from ArangoDB, a multi-model Graph Database, into Deep Graph Library (DGL), a python package for graph neural networks, and vice-versa.
About DGL
The Deep Graph Library (DGL) is an easy-to-use, high performance and scalable Python package for deep learning on graphs. DGL is framework agnostic, meaning if a deep graph model is a component of an end-to-end application, the rest of the logics can be implemented in any major frameworks, such as PyTorch, Apache MXNet or TensorFlow.
Quickstart
# Import the ArangoDB-DGL Adapter
from adbdgl_adapter.adapter import ADBDGL_Adapter
# Import a sample graph from DGL
from dgl.data import KarateClubDataset
# 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 ADBDGL Adapter with your connection credentials
adbdgl_adapter = ADBDGL_Adapter(con)
# ArangoDB to DGL via Graph
dgl_fraud_graph = adbdgl_adapter.arangodb_graph_to_dgl("fraud-detection")
# ArangoDB to DGL via Collections
dgl_fraud_graph_2 = adbdgl_adapter.arangodb_collections_to_dgl(
"fraud-detection",
{"account", "Class", "customer"}, # Specify vertex collections
{"accountHolder", "Relationship", "transaction"}, # Specify edge collections
)
# ArangoDB to DGL 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": {},
},
}
dgl_fraud_graph_3 = adbdgl_adapter.arangodb_to_dgl("fraud-detection", metagraph)
# DGL to ArangoDB
dgl_karate_graph = KarateClubDataset()[0]
adb_karate_graph = adbdgl_adapter.dgl_to_arangodb("Karate", karate_dgl_g)
Development & Testing
Prerequisite: arangorestore
must be installed
git clone https://github.com/arangoml/dgl-adapter.git
cd dgl-adapter
python -m venv .venv
source .venv/bin/activate
(MacOS) or.venv/scripts/activate
(Windows)pip install -e . pytest
pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
adbdgl_adapter-1.0.1.tar.gz
(22.5 kB
view hashes)
Built Distribution
Close
Hashes for adbdgl_adapter-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60440968331ada293ddc44320cb9e88d7f9226889c92f671805e8131ed27b345 |
|
MD5 | eb2e599ba60eac4b5b3a4b94133a905b |
|
BLAKE2b-256 | 2295cfe76b500763afb80a73780a9bead4acb177550d24023673fe5ad0e0d8fb |