# Retworkx API Reference¶

## Graph Classes¶

 A class for creating undirected graphs. retworkx.PyDiGraph([check_cycle]) A class for creating directed graphs retworkx.PyDAG([check_cycle]) A class for creating direct acyclic graphs.

## Generators¶

 retworkx.generators.cycle_graph([num_nodes, …]) Generate an undirected cycle graph Generate a cycle graph retworkx.generators.path_graph([num_nodes, …]) Generate an undirected path graph Generate a directed path graph retworkx.generators.star_graph([num_nodes, …]) Generate an undirected star graph Generate a directed star graph

## Random Circuit Functions¶

 retworkx.directed_gnp_random_graph(…[, seed]) 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.

## Algorithm Functions¶

 retworkx.bfs_successors(graph, node, /) Return successors in a breadth-first-search from a source node. retworkx.dag_longest_path(graph, /) 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. Check that the PyDiGraph or PyDAG doesn’t have a cycle retworkx.is_isomorphic(first, second, /) Determine if 2 graphs are structurally isomorphic Determine if 2 DAGs are isomorphic retworkx.topological_sort(graph, /) Return the topological sort of node indexes from the provided graph retworkx.descendants(graph, node, /) Return the descendants of a node in a graph. retworkx.ancestors(graph, node, /) Return the ancestors of a node in a graph. Get the lexicographical topological sorted nodes from the provided DAG Return the shortest path lengths between ever pair of nodes that has a path connecting them Find all-pairs shortest path lengths using Floyd’s algorithm Find all-pairs shortest path lengths using Floyd’s algorithm retworkx.layers(dag, first_layer, /) Return a list of layers Return the adjacency matrix for a PyDiGraph object Return the adjacency matrix for a PyGraph class retworkx.graph_all_simple_paths Return all simple paths between 2 nodes in a PyGraph object retworkx.digraph_all_simple_paths 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 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 retworkx.graph_greedy_color(graph, /) Color a PyGraph using a largest_first strategy greedy graph coloring. retworkx.cycle_basis(graph, /[, root]) Return a list of cycles which form a basis for cycles of a given PyGraph Compute the strongly connected components for a directed graph