本文簡要介紹
networkx.Graph.get_edge_data
的用法。用法:
Graph.get_edge_data(u, v, default=None)
返回與邊 (u, v) 關聯的屬性字典。
這與
G[u][v]
相同,但如果邊不存在則返回默認值而不是異常。- u, v:節點
- default: any Python object (default=None):
如果未找到邊 (u, v) 則返回的值。
- edge_dict:字典
邊屬性字典。
參數:
返回:
例子:
>>> G = nx.path_graph(4) # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G[0][1] {}
警告:不允許分配給
G[u][v]
。但是分配屬性G[u][v]['foo']
是安全的>>> G[0][1]["weight"] = 7 >>> G[0][1]["weight"] 7 >>> G[1][0]["weight"] 7
>>> G = nx.path_graph(4) # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G.get_edge_data(0, 1) # default edge data is {} {} >>> e = (0, 1) >>> G.get_edge_data(*e) # tuple form {} >>> G.get_edge_data("a", "b", default=0) # edge not in graph, return 0 0
相關用法
- Python NetworkX Graph.size用法及代碼示例
- Python NetworkX Graph.to_undirected用法及代碼示例
- Python NetworkX Graph.degree用法及代碼示例
- Python NetworkX Graph.number_of_edges用法及代碼示例
- Python NetworkX Graph.add_weighted_edges_from用法及代碼示例
- Python NetworkX Graph.subgraph用法及代碼示例
- Python NetworkX Graph.__contains__用法及代碼示例
- Python NetworkX Graph.nodes用法及代碼示例
- Python NetworkX Graph.number_of_nodes用法及代碼示例
- Python NetworkX Graph.clear用法及代碼示例
- Python NetworkX Graph.add_edge用法及代碼示例
- Python NetworkX Graph.has_node用法及代碼示例
- Python NetworkX Graph.add_node用法及代碼示例
- Python NetworkX Graph.edges用法及代碼示例
- Python NetworkX Graph.__len__用法及代碼示例
- Python NetworkX Graph.remove_nodes_from用法及代碼示例
- Python NetworkX Graph.remove_edge用法及代碼示例
- Python NetworkX Graph.__init__用法及代碼示例
- Python NetworkX Graph.remove_node用法及代碼示例
- Python NetworkX Graph.edge_subgraph用法及代碼示例
- Python NetworkX Graph.__iter__用法及代碼示例
- Python NetworkX Graph.to_directed用法及代碼示例
- Python NetworkX Graph.order用法及代碼示例
- Python NetworkX Graph.add_edges_from用法及代碼示例
- Python NetworkX Graph.update用法及代碼示例
注:本文由純淨天空篩選整理自networkx.org大神的英文原創作品 networkx.Graph.get_edge_data。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。