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
The University of Calgary main campus drawn as a graph of 56 buildings on their real positions, with the shortest walk from the Olympic Oval to Scurfield Hall highlighted

The University of Calgary main campus as a graph of buildings, drawn on real positions (© OpenStreetMap contributors, ODbL). Click for the interactive version.

133graph algorithms
14layout engines
2,460tests on Linux, Windows and macOS
1runtime dependency (numpy)

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 model

Graph, DiGraph and a DAG that refuses to become cyclic. Insertion order is preserved, so results are reproducible.

Graphs
Layout engines

Sugiyama hierarchical layout with network-simplex layering, tidy and radial trees, stress majorization, ForceAtlas2 and geometric layouts.

Layouts
Rendering

Data-driven colors, sizes and shapes with automatic legends, edges clipped to node outlines, overlap-avoiding labels, four themes.

Drawing
Algorithms

Shortest paths, connectivity, critical path, centrality, communities, flow, matching and more, tested against networkx where it has an equivalent.

Algorithms
Simulation

Epidemics (discrete and Gillespie), cascades, random walks, opinion dynamics, diffusion and DAG scheduling, with animated playback.

Simulation
Analysis reports

ag.analyze(g) returns a text summary, plain data, or an interactive dashboard of the graph.

Analysis reports

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
Campus graph with the shortest route from the Olympic Oval to Scurfield Hall highlighted

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.

An interactive AryaGraph page, embedded as a static HTML file. Building positions © OpenStreetMap contributors (ODbL). Open full screen

Plan with uncertainty

DAG tools cover the critical path, simulated execution on a limited number of workers, and Monte Carlo schedules.

Histogram of 2,000 simulated project durations with P50, P80 and P95 reference lines

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.

Read the case study

Gallery

A few figures made with AryaGraph. The gallery shows the code for each one.

Layered DAG with its critical path

Gallery

Communities in the dark theme

Gallery

A frame of an SIR epidemic

Gallery

Persian labels, right to left

Languages

Case studies

Complete analyses, from the question to the figures, with the code to reproduce every number.

How connected is the University of Calgary’s indoor network?

How connected are the campus tunnels and pedways, and which single links matter most?

How connected is the University of Calgary’s indoor network?
Scheduling a house build under uncertainty

Critical path, crew counts and Monte Carlo risk for a construction plan.

Scheduling a house build under uncertainty
Critical path and parallelism in an ML pipeline

Parallelism, worker counts, scheduling policies and retries in a machine-learning pipeline.

Critical path and parallelism in an ML pipeline
Epidemic interventions

How network structure and targeted immunization change an SIR outbreak.

Epidemic interventions
Les Misérables: a character network

Centrality, communities and the characters who connect them.

Les Misérables: a character network

Start learning

Getting started

Install AryaGraph and take the ten-minute tour.

Getting started
User guide

Every feature, explained with runnable examples.

User guide
Tutorials

Step-by-step projects, from a first network to publication figures.

Tutorials
API reference

Every public function and class, generated from the source.

API reference

AryaGraph is created by Ali Mohammadi Ruzbahani and released under the MIT License. If it helps your work, please cite it.