当前位置: 首页>>代码示例>>Python>>正文


Python Graph.vs["type"]方法代码示例

本文整理汇总了Python中igraph.Graph.vs["type"]方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.vs["type"]方法的具体用法?Python Graph.vs["type"]怎么用?Python Graph.vs["type"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在igraph.Graph的用法示例。


在下文中一共展示了Graph.vs["type"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_cost_matrix

# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import vs["type"] [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)
开发者ID:dksr,项目名称:graph_utils,代码行数:33,代码来源:graph_match.py


注:本文中的igraph.Graph.vs["type"]方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。