primitives.py 文件源码

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

项目:ReGraph 作者: eugeniashurko 项目源码 文件源码
def add_nodes_from(graph, node_list):
    """Add nodes from a node list.

    Parameters
    ----------
    graph : networkx.(Di)Graph
    node_list : iterable
        Iterable containing a collection of nodes, optionally,
        with their attributes


    Examples
    --------
    >>> import networkx as nx
    >>> from regraph.primitives import add_nodes_from
    >>> G = nx.Graph()
    >>> add_nodes_from(G, [1, (2, {"a": 1}), 3])
    """
    for n in node_list:
        try:
            node_id, node_attrs = n
            add_node(graph, node_id, node_attrs)
        except (TypeError, ValueError) as e:
            add_node(graph, n)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号