MultiDiGraph.in_degree#
- property MultiDiGraph.in_degree#
(node, in_degree) 的 DegreeView 或单个节点的 in_degree。
节点的入度是指向该节点的边的数量。加权节点度是与该节点关联的边的权重的总和。
此对象为 (节点, 度) 提供一个迭代器,也提供单个节点的度查询。
- 参数:
- nbunch单个节点、容器或所有节点(默认=所有节点)
此视图仅报告与这些节点关联的边。
- weight字符串或 None,可选(默认=None)
用于作为权重的数值的边属性。如果为 None,则每条边权重为 1。度是与节点相邻的边权重的总和。
- 返回:
- 如果请求单个节点
- degint
节点的度
- 或如果请求多个节点
- nd_iteriterator
迭代器返回 (节点, 入度) 的双元组。
另请参阅
示例
>>> G = nx.MultiDiGraph() >>> nx.add_path(G, [0, 1, 2, 3]) >>> G.in_degree(0) # node 0 with degree 0 0 >>> list(G.in_degree([0, 1, 2])) [(0, 0), (1, 1), (2, 1)] >>> G.add_edge(0, 1) # parallel edge 1 >>> list(G.in_degree([0, 1, 2])) # parallel edges counted [(0, 0), (1, 2), (2, 1)]