功能#

图形方法和各种实用程序的功能接口。

#

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)

返回true G 没有边。

add_star(G_to_add_to, nodes_for_star, **attr)

在图G中添加一个星,在图G中添加一个星。

add_path(G_to_add_to, nodes_for_path, **attr)

将路径添加到图g_to_add_to。

add_cycle(G_to_add_to, nodes_for_cycle, **attr)

将循环添加到图g_to_add_to。

subgraph(G, nbunch)

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

subgraph_view(G[, filter_node, filter_edge])

G 对节点和边应用筛选器。

induced_subgraph(G, nbunch)

返回的子图视图 G 仅在nbunch中显示节点。

restricted_view(G, nodes, edges)

返回的视图 G 具有隐藏的节点和边。

reverse_view(G)

G 边缘方向相反

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])

返回true G 有加权边缘。

is_negatively_weighted(G[, edge, weight])

返回true G 边缘负权重。

set_node_attributes(G, values[, name])

从给定值或值字典设置节点属性。

get_node_attributes(G, name)

从图中获取节点属性

set_edge_attributes(G, values[, name])

从给定值或值字典设置边缘属性。

get_edge_attributes(G, name)

从图中获取边缘属性

路径#

is_path(G, path)

返回指定路径是否存在

path_weight(G, path, weight)

返回与指定路径和权重相关联的总成本

冻结图结构#

freeze(G)

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

is_frozen(G)

如果图形被冻结,则返回true。