AryaGraph#

Graphs and DAGs, drawn precisely and analyzed in depth.
AryaGraph is a Python library for visualizing, analyzing and simulating networks and directed acyclic graphs. Layout engines, a static and interactive renderer, graph algorithms and simulation engines work together in one package whose only runtime dependency is numpy.
pip install git+https://github.com/ruzbahani/AryaGraph.git
Everything a graph project needs
Model the network, lay it out, measure it, simulate what happens on it, and publish the result as a static figure or an interactive page.
Graph, DiGraph and a DAG that refuses to become cyclic. Insertion order is preserved, so results are reproducible.
Sugiyama hierarchical layout with network-simplex layering, tidy and radial trees, stress majorization, ForceAtlas2 and geometric layouts.
Data-driven colors, sizes and shapes with automatic legends, edges clipped to node outlines, overlap-avoiding labels, four themes.
Shortest paths, connectivity, critical path, centrality, communities, flow, matching and more, tested against networkx where it has an equivalent.
Epidemics (discrete and Gillespie), cascades, random walks, opinion dynamics, diffusion and DAG scheduling, with animated playback.
ag.analyze(g) returns a text summary, plain data, or an interactive dashboard of the graph.
From data to figure in a few lines
Load the bundled campus graph, find the shortest walk between two buildings, and draw it on the real map.
import aryagraph as ag
campus = ag.gen.ucalgary_campus()
route = ag.alg.shortest_path(
campus, "OO", "SH", weight="length")
pos = {n: d["pos"] for n, d in campus.nodes.data()}
fig = ag.draw(campus, layout=pos,
node_color="kind",
highlight_path=route,
title="University of Calgary main campus")
fig.save("campus.html") # or .svg, .png, .pdf
print(" → ".join(route))
OO → KNB → KNA → IH → RC → RT → CH → MFH
→ PF → EDT → SH
The route is 1,002 m long, measured in straight lines between buildings, and passes through 11 of them. Building positions © OpenStreetMap contributors (ODbL).
Explore it live
Every figure can also be saved as a self-contained interactive page: pan and zoom, hover a building to see its neighborhood, drag nodes, search, filter by legend entry, or open the table view.
Plan with uncertainty
DAG tools cover the critical path, simulated execution on a limited number of workers, and Monte Carlo schedules.
The bundled house-construction plan has a deterministic critical path of 572 working hours. With PERT uncertainty on every task, 2,000 simulated schedules put the median completion at about 607 hours and the 95th percentile at about 673 hours. The case study adds the plan’s curing and drying waits, which bring the critical path to 668 hours.
monte_carlo_schedule also reports how often each task lands on the critical path, which points at the tasks that deserve the most attention.
Gallery
A few figures made with AryaGraph. The gallery shows the code for each one.
Layered DAG with its critical path
Communities in the dark theme
A frame of an SIR epidemic
Persian labels, right to left
Case studies
Complete analyses, from the question to the figures, with the code to reproduce every number.
How connected are the campus tunnels and pedways, and which single links matter most?
Critical path, crew counts and Monte Carlo risk for a construction plan.
Parallelism, worker counts, scheduling policies and retries in a machine-learning pipeline.
How network structure and targeted immunization change an SIR outbreak.
Centrality, communities and the characters who connect them.
Start learning
Install AryaGraph and take the ten-minute tour.
Every feature, explained with runnable examples.
Step-by-step projects, from a first network to publication figures.
Every public function and class, generated from the source.
AryaGraph is created by Ali Mohammadi Ruzbahani and released under the MIT License. If it helps your work, please cite it.
