功能

Graph

degree(G[, nbunch, weight])

返回单个节点或一组节点的度数视图。

degree_histogram(G)

返回每个度值出现频率的列表。

density(G)

返回图的密度。

info(G[, n])

返回图G或单个节点n的信息摘要。

create_empty_copy(G[, with_data])

返回移除所有边后的图G副本。

is_directed(G)

如果图是有向的,则返回True。

to_directed(graph)

返回图graph的有向视图。

to_undirected(graph)

返回图graph的无向视图。

is_empty(G)

如果G没有边,则返回True。

add_star(G_to_add_to, nodes_for_star, **attr)

向Graph G_to_add_to添加一个星形结构。

add_path(G_to_add_to, nodes_for_path, **attr)

向Graph G_to_add_to添加一条路径。

add_cycle(G_to_add_to, nodes_for_cycle, **attr)

向Graph G_to_add_to添加一个循环。

subgraph(G, nbunch)

返回由nbunch中的节点诱导的子图。

induced_subgraph(G, nbunch)

返回一个由nbunch节点集导出的独立深拷贝子图。

edge_subgraph(G, edges)

返回由指定边导出的独立深拷贝子图。

节点

nodes(G)

返回图中节点的迭代器。

number_of_nodes(G)

返回图中节点的数量。

neighbors(G, n)

返回与节点n相连的节点列表。

all_neighbors(graph, node)

返回图中某个节点的所有邻居节点。

non_neighbors(graph, node)

返回图中该节点的非邻居节点。

common_neighbors(G, u, v)

返回图中两个节点的共同邻居。

edges(G[, nbunch])

返回与节点集合nbunch相关联的边的视图。

number_of_edges(G)

返回图中的边数。

density(G)

返回图的密度。

non_edges(graph)

返回图中不存在的边。

自循环

selfloop_edges(G[, data, keys, default])

返回自环边的迭代器。

number_of_selfloops(G)

返回自环边的数量。

nodes_with_selfloops(G)

返回一个包含自循环节点的迭代器。

属性

is_weighted(G[, edge, weight])

如果G包含带权重的边则返回True。

is_negatively_weighted(G[, edge, weight])

如果G包含负权边则返回True。

冻结图结构

freeze(G)

修改图以防止通过添加或删除节点或边进行进一步更改。

is_frozen(G)

如果图被冻结则返回True。