Retworkx API Reference¶
Graph Classes¶
|
A class for creating undirected graphs |
|
A class for creating directed graphs |
|
A class for creating direct acyclic graphs. |
Algorithm Functions¶
Shortest Paths¶
Find the shortest path from a node |
|
Compute the lengths of the shortest paths for a graph object using Dijkstra’s algorithm. |
|
Find the shortest path from all nodes |
|
Find the shortest path from a node |
|
Get the distance matrix for a graph |
|
Find all-pairs shortest path lengths using Floyd’s algorithm |
|
Find all-pairs shortest path lengths using Floyd’s algorithm |
|
Compute the A* shortest path for a graph |
|
Compute the length of the kth shortest path |
|
Get the number of unweighted shortest paths from a source node |
|
Return the average shortest path length with unweighted edges. |
Centrality¶
Returns the betweenness centrality of each node in the graph. |
Traversal¶
Get edge list in depth first order |
|
|
Return successors in a breadth-first-search from a source node. |
|
Return the topological sort of node indexes from the provided graph |
Get the lexicographical topological sorted nodes from the provided DAG |
|
|
Return the descendants of a node in a graph. |
|
Return the ancestors of a node in a graph. |
|
Collect runs that match a filter function |
|
Collect runs that match a filter function given edge colors |
DAG Algorithms¶
|
Find the longest path in a DAG |
|
Find the length of the longest path in a DAG |
|
Find the weighted longest path in a DAG |
Find the length of the weighted longest path in a DAG |
|
|
Check that the PyDiGraph or PyDAG doesn’t have a cycle |
|
Return a list of layers |
Tree¶
|
Find the edges in the minimum spanning tree or forest of a graph using Kruskal’s algorithm. |
|
Find the minimum spanning tree or forest of a graph using Kruskal’s algorithm. |
|
Return an approximation to the minimum Steiner tree of a graph. |
Isomorphism¶
Determine if 2 graphs are isomorphic |
|
Determine if 2 graphs are subgraph isomorphic |
|
Determine if 2 graphs are isomorphic |
|
Return an iterator over all vf2 mappings between two graphs. |
Matching¶
|
Compute a maximum-weighted matching for a |
|
Check if matching is valid for graph |
|
Check if a matching is a maximal (not maximum) matching for a graph |
Connectivity and Cycles¶
|
Compute the strongly connected components for a directed graph |
Find the number of weakly connected components in a directed graph |
|
|
Find the weakly connected components in a directed graph |
|
Check if the graph is weakly connected |
|
Return a list of cycles which form a basis for cycles of a given PyGraph |
|
Return the first cycle encountered during DFS of a given PyDiGraph, empty list is returned if no cycle is found |
Other Algorithm Functions¶
Compute the complement of a graph. |
|
Return the adjacency matrix for a graph object |
|
Return all simple paths between 2 nodes in a PyGraph object |
|
Compute the transitivity of a graph. |
|
Return the core number for each node in the graph. |
|
|
Color a PyGraph using a largest_first strategy greedy graph coloring. |
Return a new graph by forming a union from two input graph objects |
|
|
Return the metric closure of a graph |
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 |
|
|
Generate an undirected binomial tree of order n recursively. |
Generate an undirected hexagonal lattice graph. |
|
Generate a directed hexagonal lattice graph. The edges propagate towards |
|
Generate an undirected heavy square graph. |
|
Generate an directed heavy square graph. |
|
|
Generate an undirected heavy hex graph. |
Generate a directed heavy hex graph. |
Random Circuit Functions¶
|
Return a \(G_{np}\) directed random graph, also known as an Erdős-Rényi graph or a binomial graph. |
|
Return a \(G_{np}\) random undirected graph, also known as an Erdős-Rényi graph or a binomial graph. |
|
Return a \(G_{nm}\) of a directed graph |
|
Return a \(G_{nm}\) of an undirected graph |
|
Returns a random geometric graph in the unit cube of dimensions dim. |
Layout Functions¶
Generate a random layout |
|
Position nodes using Fruchterman-Reingold force-directed algorithm. |
|
Generate a bipartite layout of the graph |
|
Generate a circular layout of the graph |
|
Generate a shell layout of the graph |
|
Generate a spiral layout of the graph |
Converters¶
|
Convert a networkx graph object into a retworkx graph object. |
API functions for PyDigraph¶
These functions are algorithm functions that are type specific for
PyDiGraph
or PyDAG
objects. Universal
functions from Retworkx API that work for both graph types internally call
the functions from the explicitly typed based on the data type.
|
Determine if 2 directed graphs are isomorphic |
Determine if 2 directed graphs are subgraph - isomorphic |
|
|
Return an iterator over all vf2 mappings between two |
|
Get the distance matrix for a directed graph |
|
Find all-pairs shortest path lengths using Floyd’s algorithm |
|
Find all-pairs shortest path lengths using Floyd’s algorithm |
|
Return the adjacency matrix for a PyDiGraph object |
Return all simple paths between 2 nodes in a PyDiGraph object |
|
|
Compute the A* shortest path for a PyDiGraph |
Find the shortest path from a node |
|
Find the shortest path from all nodes in a |
|
Compute the lengths of the shortest paths for a PyDiGraph object using Dijkstra’s algorithm |
|
Calculate the the shortest length from all nodes in a |
|
Compute the length of the kth shortest path |
|
|
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 |
|
Compute the transitivity of a directed graph. |
|
Return the core number for each node in the directed graph. |
|
Compute the complement of a graph. |
|
Return a new PyDiGraph by forming a union from two input PyDiGraph objects |
Generate a random layout |
|
|
Generate a bipartite layout of the graph |
|
Generate a circular layout of the graph |
|
Generate a shell layout of the graph |
|
Generate a spiral layout of the graph |
|
Position nodes using Fruchterman-Reingold force-directed algorithm. |
Get the number of unweighted shortest paths from a source node |
|
|
Compute the betweenness centrality of all nodes in a PyDiGraph. |
Return the average shortest path length for a |
API functions for PyGraph¶
These functions are algorithm functions that are type specific for
PyGraph
objects. Universal functions from Retworkx API that
work for both graph types internally call the functions from the explicitly
typed API based on the data type.
|
Determine if 2 undirected graphs are isomorphic |
|
Determine if 2 undirected graphs are subgraph - isomorphic |
|
Return an iterator over all vf2 mappings between two |
|
Get the distance matrix for an undirected graph |
|
Find all-pairs shortest path lengths using Floyd’s algorithm |
|
Find all-pairs shortest path lengths using Floyd’s algorithm |
|
Return the adjacency matrix for a PyGraph class |
Return all simple paths between 2 nodes in a PyGraph object |
|
|
Compute the A* shortest path for a PyGraph |
Find the shortest path from a node |
|
Compute the lengths of the shortest paths for a PyGraph object using Dijkstra’s algorithm |
|
Find the shortest path from all nodes in a |
|
Compute the length of the kth shortest path |
|
Calculate the the shortest length from all nodes in a |
|
|
Get edge list in depth first order |
|
Compute the transitivity of an undirected graph. |
|
Return the core number for each node in the graph. |
|
Compute the complement of a graph. |
|
Return a new PyGraph by forming a union from two input PyGraph objects |
Generate a random layout |
|
|
Generate a bipartite layout of the graph |
|
Generate a circular layout of the graph |
|
Generate a shell layout of the graph |
|
Generate a spiral layout of the graph |
|
Position nodes using Fruchterman-Reingold force-directed algorithm. |
Get the number of unweighted shortest paths from a source node |
|
|
Compute the betweenness centrality of all nodes in a PyGraph. |
Return the average shortest path length for a |
Exceptions¶
Custom Return 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 indices |
|
A custom class for the return of edge lists |
|
A custom class for the return of edge lists with weights |
|
A class representing a mapping of edge indices to a tuple of node indices and weight/data payload |
|
A custom class for the return of paths to target nodes |
|
A custom class for the return of path lengths to target nodes |
|
A class representing a mapping of node indices to 2D positions |
|
A custom class for the return of paths to target nodes from all nodes |
|
A custom class for the return of path lengths to target nodes from all nodes |
|
A custom class for the return of centralities at target nodes |