Functions overview

info

This site is under construction.

Graph functions#

FunctionDescription
degree(G[, nbunch, weight])Returns a degree view of single node or of nbunch of nodes.
degree_histogram(G)Returns a list of the frequency of each degree value.
density(G)Returns the density of a graph.
info(G[, n])Return a summary of information for the graph G or a single node n.
create_empty_copy(G[, with_data])Returns a copy of the graph G with all of the edges removed.
is_directed(G)Return True if graph is directed.
to_directed(graph)Returns a directed view of the graph graph.
to_undirected(graph)Returns an undirected view of the graph graph.
is_empty(G)Returns True if G has no edges.
subgraph(G, nbunch)Returns the subgraph induced on nodes in nbunch.
subgraph_view(G[, filter_node, filter_edge])View of G applying a filter on nodes and edges.
induced_subgraph(G, nbunch)Returns a SubGraph view of G showing only nodes in nbunch.
restricted_view(G, nodes, edges)Returns a view of G with hidden nodes and edges.
reverse_view(G)View of G with edge directions reversed.
edge_subgraph(G, edges)Returns a view of the subgraph induced by the specified edges.

Node functions#

FunctionDescription
nodes(G)Returns an iterator over the graph nodes.
number_of_nodes(G)Returns the number of nodes in the graph.
neighbors(G, n)Returns a list of nodes connected to node n.
all_neighbors(graph, node)Returns all of the neighbors of a node in the graph.
non_neighbors(graph, node)Returns the non-neighbors of the node in the graph.
common_neighbors(G, u, v)Returns the common neighbors of two nodes in a graph.

Edge functions#

FunctionDescription
edges(G[, nbunch])Returns an edge view of edges incident to nodes in nbunch.
number_of_edges(G)Returns the number of edges in the graph.
density(G)Returns the density of a graph.
non_edges(G)Returns the non-existent edges in the graph.

Self loop functions#

FunctionDescription
selfloop_edges(G[, data, keys, default])Returns an iterator over selfloop edges.
number_of_selfloops(G)Returns the number of selfloop edges.
nodes_with_selfloops(G)Returns an iterator over nodes with self loops.

Attribute functions#

FunctionDescription
is_weighted(G[, edge, weight])Returns True if G has weighted edges.
is_negatively_weighted(G[, edge, weight])Returns True if G has negatively weighted edges.
set_node_attributes(G, values[, name])Sets node attributes from a given value or dictionary of values.
get_node_attributes(G, name)Get node attributes from graph.
set_edge_attributes(G, values[, name])Sets edge attributes from a given value or dictionary of values.
get_edge_attributes(G, name)Get edge attributes from graph.

Path functions#

FunctionDescription
is_path(G, path)Returns whether or not the specified path exists.
path_weight(G, path, weight)Returns total cost associated with specified path and weight.

Freezing graph structure functions#

FunctionDescription
freeze(G)Modify graph to prevent further change by adding or removing nodes or edges.
is_frozen(G)Returns True if graph is frozen.