Skip to main content

Convert ArangoDB graphs to NetworkX & vice-versa.

Project description

ArangoDB-Networkx Adapter

build Coverage Status

PyPI version badge Python versions badge

License Code style: black Downloads per month

The ArangoDB-Networkx Adapter exports Graphs from ArangoDB, a multi-model Graph Database, into NetworkX, the swiss army knife for graph analysis with python, and vice-versa.

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.

Quickstart

Get Started on Colab: Open In Colab

import networkx as nx
from adbnx_adapter.adbnx_adapter import ArangoDB_Networkx_Adapter

con = {
    "hostname": "localhost",
    "protocol": "http",
    "port": 8529,
    "username": "root",
    "password": "rootpassword",
    "dbName": "_system",
}

adbnx_adapter = ArangoDB_Networkx_Adapter(con)

# (Assume ArangoDB fraud-detection data dump is imported)

fraud_nx_g = adbnx_adapter.create_networkx_graph_from_arangodb_graph("fraud-detection")
fraud_nx_g_2 = adbnx_adapter.create_networkx_graph_from_arangodb_collections(
        "fraud-detection", 
        {"account", "bank", "branch", "Class", "customer"},
        {"accountHolder", "Relationship", "transaction"}
)


grid_nx_g = nx.grid_2d_graph(5, 5)
grid_edge_definitions = [
    {
        "edge_collection": "to",
        "from_vertex_collections": ["Grid_Node"],
        "to_vertex_collections": ["Grid_Node"],
    }
]
adb_g = adbnx_adapter.create_arangodb_graph("Grid", grid_nx_g, grid_edge_definitions)

Development & Testing

Prerequisite: arangorestore must be installed

  1. git clone https://github.com/arangoml/networkx-adapter.git
  2. cd networkx-adapter
  3. python -m venv .venv
  4. source .venv/bin/activate (MacOS) or .venv/scripts/activate (Windows)
  5. cd adbnx_adapter
  6. pip install -e . pytest
  7. pytest
    • If you encounter ModuleNotFoundError, try closing & relaunching your virtual environment by running deactivate in your terminal & restarting from Step 4.

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

adbnx_adapter-1.0.1.1rc1.tar.gz (3.5 MB view details)

Uploaded Source

Built Distribution

adbnx_adapter-1.0.1.1rc1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file adbnx_adapter-1.0.1.1rc1.tar.gz.

File metadata

  • Download URL: adbnx_adapter-1.0.1.1rc1.tar.gz
  • Upload date:
  • Size: 3.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for adbnx_adapter-1.0.1.1rc1.tar.gz
Algorithm Hash digest
SHA256 dbafcee941ca06e62c222f87620eebcefb7878968f76ba15fd062c2001592e97
MD5 0ae89c8be3cc0e0dc30f9d95560cbced
BLAKE2b-256 19640c4800428e886d34e6efa9ec91810fe386d7ea5745779f934c6511f21061

See more details on using hashes here.

File details

Details for the file adbnx_adapter-1.0.1.1rc1-py3-none-any.whl.

File metadata

  • Download URL: adbnx_adapter-1.0.1.1rc1-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for adbnx_adapter-1.0.1.1rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 4112922475c93ae32db89aad5243d01ee37dd18e5e845b9008a020991fc40b42
MD5 c095fdaec3efb15b110c56995827de91
BLAKE2b-256 71374df62be3b6e2a131c60ba2bcb94d3abe762fef3ca2f66b85be8687a03137

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page