Retworkx API Reference¶
Graph Classes¶
A class for creating undirected graphs 


A class for creating directed graphs 

A class for creating direct acyclic graphs. 
Generators¶

Generate an undirected cycle graph 
Generate a cycle graph 


Generate an undirected path graph 
Generate a directed path graph 


Generate an undirected star graph 
Generate a directed star graph 


Generate an undirected mesh graph where every node is connected to every other 
Generate a directed mesh graph where every node is connected to every other 


Generate an undirected grid graph. 
Generate a directed grid graph. The edges propagate towards right and 
Random Circuit Functions¶

Return a \(G_{np}\) directed random graph, also known as an ErdősRényi graph or a binomial graph. 

Return a \(G_{np}\) random undirected graph, also known as an ErdősRényi graph or a binomial graph. 

Return a \(G_{nm}\) of a directed graph 

Return a \(G_{nm}\) of an undirected graph 
Algorithm Functions¶

Return successors in a breadthfirstsearch from a source node. 

Find the longest path in a DAG 

Find the length of the longest path in a DAG 
Find the number of weakly connected components in a DAG. 


Find the weakly connected components in a directed graph 

Check if the graph is weakly connected 

Check that the PyDiGraph or PyDAG doesn’t have a cycle 

Determine if 2 graphs are structurally isomorphic 

Determine if 2 DAGs are isomorphic 

Return the topological sort of node indexes from the provided graph 

Return the descendants of a node in a graph. 

Return the ancestors of a node in a graph. 
Get the lexicographical topological sorted nodes from the provided DAG 


Get the distance matrix for an undirected graph 

Get the distance matrix for a directed graph 

Return the shortest path lengths between ever pair of nodes that has a path connecting them 

Find allpairs shortest path lengths using Floyd’s algorithm 
Find allpairs shortest path lengths using Floyd’s algorithm 


Collect runs that match a filter function 

Return a list of layers 

Return the adjacency matrix for a PyDiGraph object 

Return the adjacency matrix for a PyGraph class 
Return all simple paths between 2 nodes in a PyGraph object 

Return all simple paths between 2 nodes in a PyDiGraph object 


Compute the A* shortest path for a PyGraph 

Compute the A* shortest path for a PyDiGraph 
Find the shortest path from a node 

Find the shortest path from a node 

Compute the lengths of the shortest paths for a PyGraph object using Dijkstra’s algorithm 

Compute the lengths of the shortest paths for a PyDiGraph object using Dijkstra’s algorithm 

Compute the length of the kth shortest path 

Compute the length of the kth shortest path 


Color a PyGraph using a largest_first strategy greedy graph coloring. 

Return a list of cycles which form a basis for cycles of a given PyGraph 

Compute the strongly connected components for a directed graph 

Get edge list in depth first order 

Get edge list in depth first order 

Return the first cycle encountered during DFS of a given PyDiGraph, empty list is returned if no cycle is found 

Return a new PyDiGraph by forming a union from two input PyDiGraph objects 
Exceptions¶
Return Iterator Types¶
A custom class for the return from 

A custom class for the return of node indices 

A custom class for the return of edge lists 

A custom class for the return of edge lists with weights 