primitives.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:ReGraph 作者: eugeniashurko 项目源码 文件源码
def filter_edges_by_attributes(graph, attr_key, attr_cond):
    """Filter graph edges by attributes.

    Removes all the edges of the graph (inplace) that do not
    satisfy `attr_cond`.

    Parameters
    ----------
    graph : networkx.(Di)Graph
    attrs_key : attribute key
    attrs_cond : callable
        Condition for an attribute to satisfy: callable that returns
        `True` if condition is satisfied, `False` otherwise.

    """
    for (s, t) in graph.edges():
        if (attr_key not in graph.edge[s][t].keys() or
                not attr_cond(graph.edge[s][t][attr_key])):
            graph.remove_edge(s, t)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号