NetworkX algorithms. Graph database scale.
Keep writing NetworkX code. Run it against a persistent, in-memory graph database. No more reloading data on every run. No more hitting Python memory limits on large datasets.
import networkx as nx
from gqlalchemy import Memgraph
from gqlalchemy.transformations.translators.nx_translator import NxTranslator
# Build your graph in NetworkX as usual
G = nx.karate_club_graph()
# Load into Memgraph once
memgraph = Memgraph("127.0.0.1", 7687)
translator = NxTranslator()
for query in list(translator.to_cypher_queries(G)):
memgraph.execute(query)
# Run NetworkX algorithms via nxalg, no reloading needed
results = memgraph.execute_and_fetch("""
CALL nxalg.pagerank()
YIELD node, rank
RETURN node, rank
ORDER BY rank DESC LIMIT 5
""")
for row in results:
print(row)Stop reloading data. Start analysing it.
NetworkX algorithms run on in-memory graphs, which means every time you restart your script, you reload your data from scratch. With Memgraph, you load once and query as many times as you want.
Your existing NetworkX code keeps working. Memgraph provides wrapper objects (MemgraphGraph and MemgraphDiGraph) that are NetworkX-compatible and stream directly from the database.
- Load once via NxTranslator, query indefinitely
- NetworkX-compatible graph objects stream live from Memgraph
- Skip the boilerplate: no manual CSV parsing or import scripts
- Support for CSV, Parquet, S3, and streaming sources via GQLAlchemy
from gqlalchemy.transformations.translators.nx_translator import NxTranslator
# Export Memgraph data back to NetworkX
translator = NxTranslator()
graph = translator.get_instance()
print(graph.number_of_nodes())
print(graph.number_of_edges())
# Use any NetworkX algorithm on the exported graph
import networkx as nx
centrality = nx.betweenness_centrality(graph)
print(sorted(centrality.items(), key=lambda x: x[1], reverse=True)[:5])-- Run NetworkX algorithms via Cypher
-- nxalg wraps the full NetworkX algorithm library
-- PageRank
CALL nxalg.pagerank()
YIELD node, rank
RETURN node, rank
ORDER BY rank DESC LIMIT 10;
-- All shortest paths between two nodes
MATCH (n:Person {name: "Alice"}), (m:Person {name: "Bob"})
CALL nxalg.all_shortest_paths(n, m)
YIELD paths
RETURN paths;Scale to datasets that break pure Python.
NetworkX holds everything in Python memory. That works fine for small graphs, but it slows down fast at scale. Memgraph's C++ in-memory engine handles large datasets without the Python overhead, and the nxalg module wraps NetworkX algorithms to stream graph data directly from the database.
- C++ implementation outperforms Python NetworkX on both small and large scale
- nxalg streams graph data from Memgraph directly, saving memory
- Connect to Kafka, Pulsar, or Redpanda for live streaming datasets
- If nxalg performance isn't enough, swap to native C++ algorithms with no code rewrite
Deploy your analysis without rewriting it.
NetworkX scripts are hard to productionize: they are not persistent, they're single-user, and sharing results means exporting files. Memgraph gives your NetworkX work a production home: persistent storage, concurrent access, and live visualization in Memgraph Lab.
- Results available to your team the moment the algorithm runs
- Visualize graph results directly in Memgraph Lab
- Paste NetworkX code into a custom query module and call it from Cypher
- Edit and reload modules from Memgraph Lab without restarting
Import your graph once
Use NxTranslator to push your NetworkX graph into Memgraph.
Run algorithms via nxalg
Call any NetworkX algorithm as a Cypher procedure. Results stream from the database.
Store and visualize instantly
Results are persistent and available to your entire team in Memgraph Lab.
Built for the workloads Python developers run.
Performance
Algorithms
Flexibility
Create a graph model from a dataset, run Memgraph with Docker, connect via GQLAlchemy, and perform graph queries, all from a Jupyter Notebook.Watch for free
When NetworkX can no longer handle the analysis and visualisation requirements of your project, find out how Memgraph gets your graph analytics back on track.Read blog