networkx.algorithms¶

Functions¶

LFR_benchmark_graph(n, tau1, tau2, mu[, ...]) Returns the LFR benchmark graph for testing community-finding algorithms.
adamic_adar_index(G[, ebunch]) Compute the Adamic-Adar index of all node pairs in ebunch.
all_node_cuts(G[, k, flow_func]) Returns all minimum k cutsets of an undirected graph G.
all_pairs_bellman_ford_path(G[, cutoff, weight]) Compute shortest paths between all nodes in a weighted graph.
all_pairs_bellman_ford_path_length(G[, ...]) Compute shortest path lengths between all nodes in a weighted graph.
all_pairs_dijkstra_path(G[, cutoff, weight]) Compute shortest paths between all nodes in a weighted graph.
all_pairs_dijkstra_path_length(G[, cutoff, ...]) Compute shortest path lengths between all nodes in a weighted graph.
all_pairs_node_connectivity(G[, nbunch, ...]) Compute node connectivity between all pairs of nodes of G.
all_pairs_shortest_path(G[, cutoff]) Compute shortest paths between all nodes.
all_pairs_shortest_path_length(G[, cutoff]) Computes the shortest path lengths between all nodes in G.
all_shortest_paths(G, source, target[, weight]) Compute all shortest paths in the graph.
all_simple_paths(G, source, target[, cutoff]) Generate all simple paths in the graph G from source to target.
ancestors(G, source) Return all nodes having a path to source in G.
antichains(G) Generates antichains from a DAG.
approximate_current_flow_betweenness_centrality(G) Compute the approximate current-flow betweenness centrality for nodes.
articulation_points(G) Return a generator of articulation points, or cut vertices, of a graph.
astar_path(G, source, target[, heuristic, ...]) Return a list of nodes in a shortest path between source and target using the A* (“A-star”) algorithm.
astar_path_length(G, source, target[, ...]) Return the length of the shortest path between source and target using the A* (“A-star”) algorithm.
asyn_lpa_communities(G[, weight]) Returns communities in G as detected by asynchronous label propagation.
attracting_component_subgraphs(G[, copy]) Generates a list of attracting component subgraphs from G.
attracting_components(G) Generates a list of attracting components in G.
attribute_assortativity_coefficient(G, attribute) Compute assortativity for node attributes.
attribute_mixing_dict(G, attribute[, nodes, ...]) Return dictionary representation of mixing matrix for attribute.
attribute_mixing_matrix(G, attribute[, ...]) Return mixing matrix for attribute.
authority_matrix(G[, nodelist]) Return the HITS authority matrix.
average_clustering(G[, nodes, weight, ...]) Compute the average clustering coefficient for the graph G.
average_degree_connectivity(G[, source, ...]) Compute the average degree connectivity of graph.
average_neighbor_degree(G[, source, target, ...]) Returns the average degree of the neighborhood of each node.
average_node_connectivity(G[, flow_func]) Returns the average connectivity of a graph G.
average_shortest_path_length(G[, weight]) Return the average shortest path length.
bellman_ford(G, source[, weight]) DEPRECATED: Has been replaced by function bellman_ford_predecessor_and_distance().
bellman_ford_path(G, source, target[, weight]) Returns the shortest path from source to target in a weighted graph G.
bellman_ford_path_length(G, source, target) Returns the shortest path length from source to target in a weighted graph.
bellman_ford_predecessor_and_distance(G, source) Compute shortest path lengths and predecessors on shortest paths in weighted graphs.
betweenness_centrality(G[, k, normalized, ...]) Compute the shortest-path betweenness centrality for nodes.
betweenness_centrality_source(G[, ...])
betweenness_centrality_subset(G, sources, ...) Compute betweenness centrality for a subset of nodes.
bfs_edges(G, source[, reverse]) Produce edges in a breadth-first-search starting at source.
bfs_predecessors(G, source) Returns an iterator of predecessors in breadth-first-search from source.
bfs_successors(G, source) Returns an iterator of successors in breadth-first-search from source.
bfs_tree(G, source[, reverse]) Return an oriented tree constructed from of a breadth-first-search starting at source.
biconnected_component_edges(G) Return a generator of lists of edges, one list for each biconnected component of the input graph.
biconnected_component_subgraphs(G[, copy]) Return a generator of graphs, one graph for each biconnected component of the input graph.
biconnected_components(G) Return a generator of sets of nodes, one set for each biconnected
bidirectional_dijkstra(G, source, target[, ...]) Dijkstra’s algorithm for shortest paths using bidirectional search.
bidirectional_shortest_path(G, source, target) Return a list of nodes in a shortest path between source and target.
blockmodel(G, partition[, multigraph]) Returns a reduced graph constructed using the generalized block modeling technique.
boundary_expansion(G, S) Returns the boundary expansion of the set S.
capacity_scaling(G[, demand, capacity, ...]) Find a minimum cost flow satisfying all demands in digraph G.
cartesian_product(G, H) Return the Cartesian product of G and H.
center(G[, e]) Return the center of the graph G.
chordal_graph_cliques(G) Returns the set of maximal cliques of a chordal graph.
chordal_graph_treewidth(G) Returns the treewidth of the chordal graph G.
cliques_containing_node(G[, nodes, cliques]) Returns a list of cliques containing the given node.
closeness_centrality(G[, u, distance, ...]) Compute closeness centrality for nodes.
closeness_vitality(G[, node, weight, ...]) Returns the closeness vitality for nodes in the graph.
clustering(G[, nodes, weight]) Compute the clustering coefficient for nodes.
cn_soundarajan_hopcroft(G[, ebunch, community]) Count the number of common neighbors of all node pairs in ebunch using community information.
communicability(G) Return communicability between all pairs of nodes in G.
communicability_betweenness_centrality(G[, ...]) Return subgraph communicability for all pairs of nodes in G.
communicability_exp(G) Return communicability between all pairs of nodes in G.
complement(G[, name]) Return the graph complement of G.
complete_bipartite_graph(n1, n2[, create_using]) Return the complete bipartite graph K_{n_1,n_2}.
compose(G, H[, name]) Return a new graph of G composed with H.
compose_all(graphs[, name]) Return the composition of all graphs.
condensation(G[, scc]) Returns the condensation of G.
conductance(G, S[, T, weight]) Returns the conductance of two sets of nodes.
connected_component_subgraphs(G[, copy]) Generate connected components as subgraphs.
connected_components(G) Generate connected components.
connected_double_edge_swap(G[, nswap, ...]) Attempts the specified number of double-edge swaps in the graph G.
contracted_edge(G, edge[, self_loops]) Returns the graph that results from contracting the specified edge.
contracted_nodes(G, u, v[, self_loops]) Returns the graph that results from contracting u and v.
core_number(G) Return the core number for each vertex.
cost_of_flow(G, flowDict[, weight]) Compute the cost of the flow given by flowDict on graph G.
could_be_isomorphic(G1, G2) Returns False if graphs are definitely not isomorphic.
coverage(*args, **kw) Returns the coverage of a partition.
current_flow_betweenness_centrality(G[, ...]) Compute current-flow betweenness centrality for nodes.
current_flow_betweenness_centrality_subset(G, ...) Compute current-flow betweenness centrality for subsets of nodes.
current_flow_closeness_centrality(G[, ...]) Compute current-flow closeness centrality for nodes.
cut_size(G, S[, T, weight]) Returns the size of the cut between two sets of nodes.
cycle_basis(G[, root]) Returns a list of cycles which form a basis for cycles of G.
dag_longest_path(G[, weight, default_weight]) Returns the longest path in a DAG If G has edges with ‘weight’ attribute the edge data are used as weight values.
dag_longest_path_length(G) Returns the longest path length in a DAG
degree_assortativity_coefficient(G[, x, y, ...]) Compute degree assortativity of graph.
degree_centrality(G) Compute the degree centrality for nodes.
degree_mixing_dict(G[, x, y, weight, nodes, ...]) Return dictionary representation of mixing matrix for degree.
degree_mixing_matrix(G[, x, y, weight, ...]) Return mixing matrix for attribute.
degree_pearson_correlation_coefficient(G[, ...]) Compute degree assortativity of graph.
descendants(G, source) Return all nodes reachable from source in G.
dfs_edges(G[, source]) Produce edges in a depth-first-search (DFS).
dfs_labeled_edges(G[, source]) Produce edges in a depth-first-search (DFS) labeled by type.
dfs_postorder_nodes(G[, source]) Produce nodes in a depth-first-search post-ordering starting from source.
dfs_predecessors(G[, source]) Return dictionary of predecessors in depth-first-search from source.
dfs_preorder_nodes(G[, source]) Produce nodes in a depth-first-search pre-ordering starting from source.
dfs_successors(G[, source]) Return dictionary of successors in depth-first-search from source.
dfs_tree(G, source) Return oriented tree constructed from a depth-first-search from source.
diameter(G[, e]) Return the diameter of the graph G.
difference(G, H) Return a new graph that contains the edges that exist in G but not in H.
dijkstra_path(G, source, target[, weight]) Returns the shortest weighted path from source to target in G.
dijkstra_path_length(G, source, target[, weight]) Returns the shortest weighted path length in G from source to target.
dijkstra_predecessor_and_distance(G, source) Compute weighted shortest path length and predecessors.
disjoint_union(G, H) Return the disjoint union of graphs G and H.
disjoint_union_all(graphs) Return the disjoint union of all graphs.
dispersion(G[, u, v, normalized, alpha, b, c]) Calculate dispersion between u and v in G.
dominance_frontiers(G, start) Returns the dominance frontiers of all nodes of a directed graph.
dominating_set(G[, start_with]) Finds a dominating set for the graph G.
double_edge_swap(G[, nswap, max_tries]) Swap two edges in the graph while keeping the node degrees fixed.
eccentricity(G[, v, sp]) Return the eccentricity of nodes in G.
edge_betweenness(G[, k, normalized, weight, ...])
edge_betweenness_centrality(G[, k, ...]) Compute betweenness centrality for edges.
edge_betweenness_centrality_subset(G, ...[, ...]) Compute betweenness centrality for edges for a subset of nodes.
edge_boundary(G, nbunch1[, nbunch2, data, ...]) Returns the edge boundary of nbunch1.
edge_connectivity(G[, s, t, flow_func]) Returns the edge connectivity of the graph or digraph G.
edge_current_flow_betweenness_centrality(G) Compute current-flow betweenness centrality for edges.
edge_current_flow_betweenness_centrality_subset(G, ...) Compute current-flow betweenness centrality for edges using subsets of nodes.
edge_dfs(G[, source, orientation]) A directed, depth-first traversal of edges in G, beginning at source.
edge_expansion(G, S[, T, weight]) Returns the edge expansion between two node sets.
edge_load_centrality(G[, cutoff]) Compute edge load.
efficiency(G, u, v) Returns the efficiency of a pair of nodes in a graph.
eigenvector_centrality(G[, max_iter, tol, ...]) Compute the eigenvector centrality for the graph G.
eigenvector_centrality_numpy(G[, weight, ...]) Compute the eigenvector centrality for the graph G.
enumerate_all_cliques(G) Returns all cliques in an undirected graph.
estrada_index(G) Return the Estrada index of a the graph G.
eulerian_circuit(G[, source]) Returns an iterator over the edges of an Eulerian circuit in G.
fast_could_be_isomorphic(G1, G2) Returns False if graphs are definitely not isomorphic.
faster_could_be_isomorphic(G1, G2) Returns False if graphs are definitely not isomorphic.
find_cliques(G) Returns all maximal cliques in an undirected graph.
find_cliques_recursive(G) Returns all maximal cliques in a graph.
find_cores(G) Return the core number for each vertex.
find_cycle(G[, source, orientation]) Returns the edges of a cycle found via a directed, depth-first traversal.
find_induced_nodes(G, s, t[, treewidth_bound]) Returns the set of induced nodes in the path from s to t.
flow_hierarchy(G[, weight]) Returns the flow hierarchy of a directed network.
floyd_warshall(G[, weight]) Find all-pairs shortest path lengths using Floyd’s algorithm.
floyd_warshall_numpy(G[, nodelist, weight]) Find all-pairs shortest path lengths using Floyd’s algorithm.
floyd_warshall_predecessor_and_distance(G[, ...]) Find all-pairs shortest path lengths using Floyd’s algorithm.
girvan_newman(G[, most_valuable_edge]) Finds communities in a graph using the Girvan–Newman method.
global_efficiency(G) Returns the average global efficiency of the graph.
global_parameters(b, c) Return global parameters for a given intersection array.
global_reaching_centrality(G[, weight, ...]) Returns the global reaching centrality of a directed graph.
goldberg_radzik(G, source[, weight]) Compute shortest path lengths and predecessors on shortest paths in weighted graphs.
google_matrix(G[, alpha, personalization, ...]) Return the Google matrix of the graph.
graph_clique_number(G[, cliques]) Returns the clique number of the graph.
graph_number_of_cliques(G[, cliques]) Returns the number of maximal cliques in the graph.
greedy_color(G[, strategy, interchange]) Color a graph using various strategies of greedy graph coloring.
harmonic_centrality(G[, distance]) Compute harmonic centrality for nodes.
has_path(G, source, target) Return True if G has a path from source to target.
hits(G[, max_iter, tol, nstart, normalized]) Return HITS hubs and authorities values for nodes.
hits_numpy(G[, normalized]) Return HITS hubs and authorities values for nodes.
hits_scipy(G[, max_iter, tol, normalized]) Return HITS hubs and authorities values for nodes.
hub_matrix(G[, nodelist]) Return the HITS hub matrix.
identified_nodes(G, u, v[, self_loops]) Returns the graph that results from contracting u and v.
immediate_dominators(G, start) Returns the immediate dominators of all nodes of a directed graph.
in_degree_centrality(G) Compute the in-degree centrality for nodes.
information_centrality(G[, weight, dtype, ...]) Compute current-flow closeness centrality for nodes.
intersection(G, H) Return a new graph that contains only the edges that exist in both G and H.
intersection_all(graphs) Return a new graph that contains only the edges that exist in all graphs.
intersection_array(G) Returns the intersection array of a distance-regular graph.
is_aperiodic(G) Return True if G is aperiodic.
is_arborescence(G) Returns True if G is an arborescence.
is_attracting_component(G) Returns True if G consists of a single attracting component.
is_biconnected(G) Return True if the graph is biconnected, False otherwise.
is_bipartite(G) Returns True if graph G is bipartite, False if not.
is_branching(G) Returns True if G is a branching.
is_chordal(G) Checks whether G is a chordal graph.
is_connected(G) Return True if the graph is connected, false otherwise.
is_digraphical(in_sequence, out_sequence) Returns True if some directed graph can realize the in- and out-degree sequences.
is_directed_acyclic_graph(G) Return True if the graph G is a directed acyclic graph (DAG) or False if not.
is_distance_regular(G) Returns True if the graph is distance regular, False otherwise.
is_dominating_set(G, nbunch) Checks if nbunch is a dominating set for G.
is_eulerian(G) Returns True if and only if G is Eulerian.
is_forest(G) Returns True if G is a forest.
is_graphical(sequence[, method]) Returns True if sequence is a valid degree sequence.
is_isolate(G, n) Determines whether a node is an isolate.
is_isomorphic(G1, G2[, node_match, edge_match]) Returns True if the graphs G1 and G2 are isomorphic and False otherwise.
is_kl_connected(G, k, l[, low_memory]) Returns True if and only if G is locally (k, l)-connected.
is_matching(G, matching) Decides whether the given set or dictionary represents a valid matching in G.
is_maximal_matching(G, matching) Decides whether the given set or dictionary represents a valid maximal matching in G.
is_multigraphical(sequence) Returns True if some multigraph can realize the sequence.
is_pseudographical(sequence) Returns True if some pseudograph can realize the sequence.
is_semiconnected(G) Return True if the graph is semiconnected, False otherwise.
is_simple_path(G, nodes) Returns True if and only if the given nodes form a simple path in G.
is_strongly_connected(G) Test directed graph for strong connectivity.
is_strongly_regular(G) Returns True if and only if the given graph is strongly regular.
is_tree(G) Returns True if G is a tree.
is_valid_degree_sequence(sequence[, method]) Returns True if sequence is a valid degree sequence.
is_valid_degree_sequence_erdos_gallai(...) Returns True if deg_sequence can be realized by a simple graph.
is_valid_degree_sequence_havel_hakimi(...) Returns True if deg_sequence can be realized by a simple graph.
is_weakly_connected(G) Test directed graph for weak connectivity.
isolates(G) Iterator over isolates in the graph.
jaccard_coefficient(G[, ebunch]) Compute the Jaccard coefficient of all node pairs in ebunch.
johnson(G[, weight]) Uses Johnson’s Algorithm to compute shortest paths.
k_clique_communities(G, k[, cliques]) Find k-clique communities in graph using the percolation method.
k_components(G[, flow_func]) Returns the k-component structure of a graph G.
k_core(G[, k, core_number]) Return the k-core of G.
k_corona(G, k[, core_number]) Return the k-corona of G.
k_crust(G[, k, core_number]) Return the k-crust of G.
k_nearest_neighbors(G[, source, target, ...]) Compute the average degree connectivity of graph.
k_shell(G[, k, core_number]) Return the k-shell of G.
katz_centrality(G[, alpha, beta, max_iter, ...]) Compute the Katz centrality for the nodes of the graph G.
katz_centrality_numpy(G[, alpha, beta, ...]) Compute the Katz centrality for the graph G.
kernighan_lin_bisection(G[, partition, ...]) Partition a graph into two blocks using the Kernighan–Lin algorithm.
kl_connected_subgraph(G, k, l[, low_memory, ...]) Returns the maximum locally (k, l)-connected subgraph of G.
kosaraju_strongly_connected_components(G[, ...]) Generate nodes in strongly connected components of graph.
lexicographic_product(G, H) Return the lexicographic product of G and H.
lexicographical_topological_sort(G[, key]) Return a generator of nodes in lexicographically topologically sorted order.
load_centrality(G[, v, cutoff, normalized, ...]) Compute load centrality for nodes.
local_efficiency(G) Returns the average local efficiency of the graph.
local_reaching_centrality(G, v[, paths, ...]) Returns the local reaching centrality of a node in a directed graph.
make_clique_bipartite(G[, fpos, ...]) Returns the bipartite clique graph corresponding to G.
make_max_clique_graph(G[, create_using]) Returns the maximal clique graph of the given graph.
max_flow_min_cost(G, s, t[, capacity, weight]) Return a maximum (s, t)-flow of minimum cost.
max_weight_matching(G[, maxcardinality, weight]) Compute a maximum-weighted matching of G.
maximal_independent_set(G[, nodes]) Return a random maximal independent set guaranteed to contain a given set of nodes.
maximal_matching(G) Find a maximal cardinality matching in the graph.
maximum_branching(G[, attr, default]) Returns a maximum branching from G.
maximum_flow(G, s, t[, capacity, flow_func]) Find a maximum single-commodity flow.
maximum_flow_value(G, s, t[, capacity, ...]) Find the value of maximum single-commodity flow.
maximum_spanning_arborescence(G[, attr, default]) Returns a maximum spanning arborescence from G.
maximum_spanning_edges(G[, algorithm, ...]) Generate edges in a maximum spanning forest of an undirected weighted graph.
maximum_spanning_tree(G[, weight, algorithm]) Returns a maximum spanning tree or forest on an undirected graph G.
min_cost_flow(G[, demand, capacity, weight]) Return a minimum cost flow satisfying all demands in digraph G.
min_cost_flow_cost(G[, demand, capacity, weight]) Find the cost of a minimum cost flow satisfying all demands in digraph G.
minimum_branching(G[, attr, default]) Returns a minimum branching from G.
minimum_cut(G, s, t[, capacity, flow_func]) Compute the value and the node partition of a minimum (s, t)-cut.
minimum_cut_value(G, s, t[, capacity, flow_func]) Compute the value of a minimum (s, t)-cut.
minimum_edge_cut(G[, s, t, flow_func]) Returns a set of edges of minimum cardinality that disconnects G.
minimum_node_cut(G[, s, t, flow_func]) Returns a set of nodes of minimum cardinality that disconnects G.
minimum_spanning_arborescence(G[, attr, default]) Returns a minimum spanning arborescence from G.
minimum_spanning_edges(G[, algorithm, ...]) Generate edges in a minimum spanning forest of an undirected weighted graph.
minimum_spanning_tree(G[, weight, algorithm]) Returns a minimum spanning tree or forest on an undirected graph G.
mixing_dict(xy[, normalized]) Return a dictionary representation of mixing matrix.
mixing_expansion(G, S[, T, weight]) Returns the mixing expansion between two node sets.
multi_source_dijkstra(G, sources[, target, ...]) Find shortest weighted paths and lengths from a given set of source nodes.
multi_source_dijkstra_path(G, sources[, ...]) Find shortest weighted paths in G from a given set of source nodes.
multi_source_dijkstra_path_length(G, sources) Find shortest weighted path lengths in G from a given set of source nodes.
negative_edge_cycle(G[, weight]) Return True if there exists a negative edge cycle anywhere in G.
network_simplex(G[, demand, capacity, weight]) Find a minimum cost flow satisfying all demands in digraph G.
node_attribute_xy(G, attribute[, nodes]) Return iterator of node-attribute pairs for all edges in G.
node_boundary(G, nbunch1[, nbunch2]) Returns the node boundary of nbunch1.
node_clique_number(G[, nodes, cliques]) Returns the size of the largest maximal clique containing each given node.
node_connected_component(G, n) Return the nodes in the component of graph containing node n.
node_connectivity(G[, s, t, flow_func]) Returns node connectivity for a graph or digraph G.
node_degree_xy(G[, x, y, weight, nodes]) Generate node degree-degree pairs for edges in G.
node_expansion(G, S) Returns the node expansion of the set S.
normalized_cut_size(G, S[, T, weight]) Returns the normalized size of the cut between two sets of nodes.
number_attracting_components(G) Returns the number of attracting components in G.
number_connected_components(G) Return the number of connected components.
number_of_cliques(G[, nodes, cliques]) Returns the number of maximal cliques for each node.
number_of_isolates(G) Returns the number of isolates in the graph.
number_strongly_connected_components(G) Return number of strongly connected components in graph.
number_weakly_connected_components(G) Return the number of weakly connected components in G.
numeric_assortativity_coefficient(G, attribute) Compute assortativity for numerical node attributes.
numeric_mixing_matrix(G, attribute[, nodes, ...]) Return numeric mixing matrix for attribute.
out_degree_centrality(G) Compute the out-degree centrality for nodes.
overall_reciprocity(G) Compute the reciprocity for the whole graph.
pagerank(G[, alpha, personalization, ...]) Return the PageRank of the nodes in the graph.
pagerank_numpy(G[, alpha, personalization, ...]) Return the PageRank of the nodes in the graph.
pagerank_scipy(G[, alpha, personalization, ...]) Return the PageRank of the nodes in the graph.
performance(*args, **kw) Returns the performance of a partition.
periphery(G[, e]) Return the periphery of the graph G.
power(G, k) Returns the specified power of a graph.
predecessor(G, source[, target, cutoff, ...]) Returns dictionary of predecessors for the path from source to all nodes in G.
preferential_attachment(G[, ebunch]) Compute the preferential attachment score of all node pairs in ebunch.
project(B, nodes[, create_using])
projected_graph(B, nodes[, multigraph]) Returns the projection of B onto one of its node sets.
quotient_graph(G, partition[, ...]) Returns the quotient graph of G under the specified equivalence relation on nodes.
ra_index_soundarajan_hopcroft(G[, ebunch, ...]) Compute the resource allocation index of all node pairs in ebunch using community information.
radius(G[, e]) Return the radius of the graph G.
reciprocity(G[, nodes]) Compute the reciprocity in a directed graph.
recursive_simple_cycles(G) Find simple cycles (elementary circuits) of a directed graph.
resource_allocation_index(G[, ebunch]) Compute the resource allocation index of all node pairs in ebunch.
reverse(G[, copy]) Return the reverse directed graph of G.
rich_club_coefficient(G[, normalized, Q]) Returns the rich-club coefficient of the graph G.
s_metric(G[, normalized]) Return the s-metric of graph.
shortest_path(G[, source, target, weight]) Compute shortest paths in the graph.
shortest_path_length(G[, source, target, weight]) Compute shortest path lengths in the graph.
shortest_simple_paths(G, source, target[, ...]) Generate all simple paths in the graph G from source to target, starting from shortest ones.
simple_cycles(G) Find simple cycles (elementary circuits) of a directed graph.
single_source_bellman_ford(G, source[, ...]) Compute shortest paths and lengths in a weighted graph G.
single_source_bellman_ford_path(G, source[, ...]) Compute shortest path between source and all other reachable nodes for a weighted graph.
single_source_bellman_ford_path_length(G, source) Compute the shortest path length between source and all other reachable nodes for a weighted graph.
single_source_dijkstra(G, source[, target, ...]) Find shortest weighted paths and lengths from a source node.
single_source_dijkstra_path(G, source[, ...]) Find shortest weighted paths in G from a source node.
single_source_dijkstra_path_length(G, source) Find shortest weighted path lengths in G from a source node.
single_source_shortest_path(G, source[, cutoff]) Compute shortest path between source and all other nodes reachable from source.
single_source_shortest_path_length(G, source) Compute the shortest path lengths from source to all reachable nodes.
square_clustering(G[, nodes]) Compute the squares clustering coefficient for nodes.
stoer_wagner(G[, weight, heap]) Returns the weighted minimum edge cut using the Stoer-Wagner algorithm.
strong_product(G, H) Return the strong product of G and H.
strongly_connected_component_subgraphs(G[, copy]) Generate strongly connected components as subgraphs.
strongly_connected_components(G) Generate nodes in strongly connected components of graph.
strongly_connected_components_recursive(G) Generate nodes in strongly connected components of graph.
subgraph_centrality(G) Return subgraph centrality for each node in G.
subgraph_centrality_exp(G) Return the subgraph centrality for each node of G.
symmetric_difference(G, H) Return new graph with edges that exist in either G or H but not both.
tensor_product(G, H) Return the tensor product of G and H.
topological_sort(G) Return a generator of nodes in topologically sorted order.
transitive_closure(G) Returns transitive closure of a directed graph
transitivity(G) Compute graph transitivity, the fraction of all possible triangles present in G.
triadic_census(G) Determines the triadic census of a directed graph.
triangles(G[, nodes]) Compute the number of triangles.
union(G, H[, rename, name]) Return the union of graphs G and H.
union_all(graphs[, rename, name]) Return the union of all graphs.
volume(G, S[, weight]) Returns the volume of a set of nodes.
voronoi_cells(G, center_nodes[, weight]) Returns the Voronoi cells centered at center_nodes with respect to the shortest-path distance metric.
weakly_connected_component_subgraphs(G[, copy]) Generate weakly connected components as subgraphs.
weakly_connected_components(G) Generate weakly connected components of G.
wiener_index(G[, weight]) Returns the Wiener index of the given graph.
within_inter_cluster(G[, ebunch, delta, ...]) Compute the ratio of within- and inter-cluster common neighbors of all node pairs in ebunch.

Exceptions¶

NetworkXTreewidthBoundExceeded Exception raised when a treewidth bound has been provided and it has