Note

This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.

API functions for PyGraph#

These functions are algorithm functions that are type specific for PyGraph objects. Universal functions from Rustworkx API that work for both graph types internally call the functions from the explicitly typed API based on the data type.

rustworkx.graph_is_isomorphic(first, second, /)

Determine if 2 undirected graphs are isomorphic

rustworkx.graph_is_subgraph_isomorphic(...)

Determine if 2 undirected graphs are subgraph - isomorphic

rustworkx.graph_vf2_mapping(first, second, /)

Return an iterator over all vf2 mappings between two PyGraph objects

rustworkx.graph_distance_matrix(graph, /[, ...])

Get the distance matrix for an undirected graph

rustworkx.graph_floyd_warshall(graph, /[, ...])

Find all-pairs shortest path lengths using Floyd's algorithm

rustworkx.graph_floyd_warshall_numpy(graph, /)

Find all-pairs shortest path lengths using Floyd's algorithm

rustworkx.graph_floyd_warshall_successor_and_distance(...)

Find all-pairs shortest path lengths using Floyd's algorithm

rustworkx.graph_adjacency_matrix(graph, /[, ...])

Return the adjacency matrix for a PyGraph class

rustworkx.graph_all_simple_paths(graph, ...)

Return all simple paths between 2 nodes in a PyGraph object

rustworkx.graph_all_pairs_all_simple_paths(...)

Return all the simple paths between all pairs of nodes in the graph

rustworkx.graph_astar_shortest_path(graph, ...)

Compute the A* shortest path for a PyGraph

rustworkx.graph_dijkstra_shortest_paths

Find the shortest path from a node

rustworkx.graph_dijkstra_shortest_path_lengths(...)

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

rustworkx.graph_all_pairs_dijkstra_shortest_paths(...)

For each node in the graph, finds the shortest paths to all others in a PyGraph object

rustworkx.graph_k_shortest_path_lengths(...)

Compute the length of the kth shortest path

rustworkx.graph_all_pairs_dijkstra_path_lengths(...)

For each node in the graph, calculates the lengths of the shortest paths to all others in a PyGraph object

rustworkx.graph_bellman_ford_shortest_path_lengths(...)

Compute the lengths of the shortest paths for a PyGraph object using the Bellman-Ford algorithm with the SPFA heuristic.

rustworkx.graph_bellman_ford_shortest_path_lengths(...)

Compute the lengths of the shortest paths for a PyGraph object using the Bellman-Ford algorithm with the SPFA heuristic.

rustworkx.graph_all_pairs_bellman_ford_shortest_paths(...)

For each node in the graph, finds the shortest paths to all others in a PyGraph object

rustworkx.graph_all_pairs_bellman_ford_path_lengths(...)

For each node in the graph, calculates the lengths of the shortest paths to all others in a PyGraph object

rustworkx.graph_all_shortest_paths(graph, ...)

Find all shortest paths between two nodes

rustworkx.graph_dfs_edges(graph, /[, source])

Get an edge list of the tree edges from a depth-first traversal

rustworkx.graph_dfs_search(graph[, source, ...])

Depth-first traversal of an undirected graph.

rustworkx.graph_transitivity(graph, /)

Compute the transitivity of an undirected graph.

rustworkx.graph_core_number(graph, /)

Return the core number for each node in the graph.

rustworkx.graph_complement(graph, /)

Compute the complement of an undirected graph.

rustworkx.graph_union(first, second, /[, ...])

Return a new PyGraph by forming a union from two input PyGraph objects

rustworkx.graph_tensor_product(first, second, /)

Return a new PyGraph by forming the tensor product from two input PyGraph objects

rustworkx.graph_token_swapper(graph, mapping, /)

This module performs an approximately optimal Token Swapping algorithm Supports partial mappings (i.e.

rustworkx.graph_cartesian_product(first, ...)

Return a new PyGraph by forming the cartesian product from two input PyGraph objects

rustworkx.graph_random_layout

Generate a random layout

rustworkx.graph_bipartite_layout(graph, ...)

Generate a bipartite layout of the graph

rustworkx.graph_circular_layout(graph, /[, ...])

Generate a circular layout of the graph

rustworkx.graph_shell_layout(graph, /[, ...])

Generate a shell layout of the graph

rustworkx.graph_spiral_layout(graph, /[, ...])

Generate a spiral layout of the graph

rustworkx.graph_spring_layout(graph[, pos, ...])

Position nodes using Fruchterman-Reingold force-directed algorithm.

rustworkx.graph_num_shortest_paths_unweighted(...)

Get the number of unweighted shortest paths from a source node

rustworkx.graph_betweenness_centrality(graph, /)

Compute the betweenness centrality of all nodes in a PyGraph.

rustworkx.graph_edge_betweenness_centrality(...)

Compute the edge betweenness centrality of all edges in a PyGraph.

rustworkx.graph_closeness_centrality(graph)

Compute the closeness centrality of each node in a PyGraph object.

rustworkx.graph_eigenvector_centrality(graph, /)

Compute the eigenvector centrality of a PyGraph.

rustworkx.graph_katz_centrality(graph, /[, ...])

Compute the Katz centrality of a PyGraph.

rustworkx.graph_unweighted_average_shortest_path_length(...)

Return the average shortest path length for a PyGraph with unweighted edges.

rustworkx.graph_bfs_search(graph[, source, ...])

Breadth-first traversal of an undirected graph.

rustworkx.graph_dijkstra_search(graph[, ...])

Dijkstra traversal of an undirected graph.

rustworkx.graph_node_link_json(graph, /[, ...])

Generate a JSON object representing a PyGraph in a node-link format

rustworkx.graph_longest_simple_path(graph, /)

Return a longest simple path in the graph