Skip to content

Conversation

aMahanna
Copy link
Member

@aMahanna aMahanna commented Oct 15, 2024

Introduces a new parameter (mirror_crud_to_nxcg) to the nxadb.Graph constructor.

If set to True, any CRUD operations performed on the ArangoDB Graph will be reflected on the cached cuGraph Graph, if it exists.

# Assumption: NVIDIA GPU available, and `nx-cugraph` installed

import os
import networkx as nx
import nx_arangodb as nxadb

os.environ["..."] = ...

G = nxadb.Graph(name="MyGraph", mirror_crud_to_nxcg=True)

res = nx.pagerank(G) # Pulls the data as an NetworkX-cuGraph object, and caches it to G.nxcg_Graph

If mirror_crud_to_nxcg is False

G.add_node(999, foo="bar") # does not update the `G.nxcg_graph` object

assert G.number_of_nodes() == G.nxcg_graph.number_of_nodes() + 1

print(G.nxcg_graph.nodes[999]) # KeyError

If mirror_crud_to_nxcg is True

G.add_node(999, foo="bar") # updates the `G.nxcg_graph` object

assert G.number_of_nodes() == G.nxcg_graph.number_of_nodes()

print(G.nxcg_graph.nodes[999]) # Works

@aMahanna aMahanna marked this pull request as draft October 15, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant