graphscope.nx.classes.function.is_weighted¶
- graphscope.nx.classes.function.is_weighted(G, edge=None, weight='weight')[源代码]¶
如果G包含带权重的边则返回True。
- Parameters:
G (图) – 一个NetworkX图。
edge (tuple, optional) - 一个2元组,用于指定G中将被测试的唯一边。如果为None,则测试G中的每条边。
weight (string, optional) – 用于查询边权重的属性名称。
- Returns:
一个布尔值,表示G或指定的边是否具有权重。
- Return type:
布尔值
- Raises:
NetworkXError – 如果指定的边不存在。
示例
>>> G = nx.path_graph(4) >>> nx.is_weighted(G) False >>> nx.is_weighted(G, (2, 3)) False
>>> G = nx.DiGraph() >>> G.add_edge(1, 2, weight=1) >>> nx.is_weighted(G) True