def get_label_from_edge(g, edge, attribute_name='label'):
edge_attributes = g.get_edge_data(edge[0], edge[1])
if edge_attributes is None and nx.is_directed(g):
edge_attributes = g.get_edge_data(edge[1], edge[0])
labels = []
if type(g) == nx.MultiDiGraph or type(g) == nx.MultiGraph:
for index in edge_attributes:
if attribute_name in edge_attributes[index]:
labels.append(edge_attributes[index][attribute_name])
else:
if attribute_name in edge_attributes:
labels.append(edge_attributes[attribute_name])
return labels
parsemis_wrapper.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录