MultiDiGraph.in_degree#

property MultiDiGraph.in_degree#

节点入度的DegreeView,或单个节点的入度。

节点的入度是指指向该节点的边的数量。 加权节点度是与该节点相邻的边的权重之和。

该对象提供了一个(节点, 度)的迭代器,以及对单个节点度的查询。

Parameters:
nbunch单个节点、容器或所有节点(默认=所有节点)

视图将仅报告与这些节点相邻的边。

weight字符串或None,可选(默认=None)

存储用作权重的数值的边属性。如果为None,则每条边的权重为1。 度是与节点相邻的边的权重之和。

Returns:
如果请求单个节点
degint

节点的度

如果请求多个节点
nd_iteriterator

迭代器返回(节点, 入度)的二元组。

See also

degree, out_degree

Examples

>>> G = nx.MultiDiGraph()
>>> nx.add_path(G, [0, 1, 2, 3])
>>> G.in_degree(0)  # 节点0的度为0
0
>>> list(G.in_degree([0, 1, 2]))
[(0, 0), (1, 1), (2, 1)]
>>> G.add_edge(0, 1)  # 平行边
1
>>> list(G.in_degree([0, 1, 2]))  # 平行边被计数
[(0, 0), (1, 2), (2, 1)]