processes.py 文件源码

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

项目:Dallinger 作者: Dallinger 项目源码 文件源码
def moran_cultural(network):
    """Generalized cultural Moran process.

    At eachtime step, an individual is chosen to receive information from
    another individual. Nobody dies, but perhaps their ideas do.
    """
    if not network.transmissions():  # first step, replacer is a source
        replacer = random.choice(network.nodes(type=Source))
        replacer.transmit()
    else:
        replacer = random.choice(network.nodes(type=Agent))
        replaced = random.choice(
            replacer.neighbors(direction="to", type=Agent))

        from operator import attrgetter

        replacer.transmit(
            what=max(replacer.infos(), key=attrgetter('creation_time')),
            to_whom=replaced)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号