本文整理汇总了Python中igraph.Graph.vs["hist"]方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.vs["hist"]方法的具体用法?Python Graph.vs["hist"]怎么用?Python Graph.vs["hist"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类igraph.Graph
的用法示例。
在下文中一共展示了Graph.vs["hist"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_cost_matrix
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import vs["hist"] [as 别名]
score_matrix = simm
max_score = np.max(score_matrix) * 2
# Apply the Hungarian algorithm to the score matrix
# First compute the cost matrix from score matrix
# Cost is opposite of score, so we use cost = (max_score * 2 - score) to compute cost.
# Scores are sometimes very less, so using sys.maxint instead of max_score sometimes makes all scores equal
cost_matrix = make_cost_matrix(score_matrix,
lambda cost: max_score - cost)
indexes = hungarian_alg.compute(cost_matrix)
return score_matrix, indexes
if __name__ == "__main__":
from igraph import Graph
node_labels = ["before", "after", "s", "d", "c"]
g1 = Graph([(0,1), (0,2), (2,3), (3,4), (4,2), (2,5), (5,0), (6,3), (5,6)],directed=True)
g1.vs["name"] = ["before", "after", "s", "d", "c", "s", "d"]
g1.vs["type"] = ["temporal", "temporal", "spatial", "spatial", "spatial", "spatial", "spatial"]
compute_node_label_hist(g1,node_labels)
g1.vs["hist"] = [[1,2,4],[1,2,4],[1,2,4],[1,2,4],[1,2,4],[1,2,4],[1,2,4]]
g2 = Graph([(0,1), (0,2), (2,3), (3,4), (4,2), (2,5), (5,0), (6,3), (5,6)],directed=True)
g2.vs["name"] = ["before", "after", "s", "d", "s", "s", "d"]
g2.vs["type"] = ["temporal", "temporal", "spatial", "spatial", "spatial", "spatial", "spatial"]
g2.vs["hist"] = [[1,2,4],[1,2,4],[1,2,4],[1,2,4],[1,2,4],[1,2,4],[1,2,4]]
g1 = compute_node_label_hist(g1, node_labels)
g2 = compute_node_label_hist(g2, node_labels)
print compute_similarity_score_from_node_label_hists(g1, g2)
print compute_graph_similarity_score(g1, g2)