cycle_fixed.py 文件源码

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

项目:gym-kidney 作者: camoy 项目源码 文件源码
def embed(self, G, rng):
        if G.order() < self.cycle_length:
            return np.array([0.0], dtype = "f")

        succ = 0
        max_cycle = sp.binom(G.order(), self.cycle_length)

        for _ in range(self.sample_size):
            us = rng.choice(G.nodes(), self.cycle_length)
            H = G.subgraph(us.tolist())

            for c in nx.simple_cycles(H):
                if len(c) == self.cycle_length:
                    succ += 1
                    break

        val = [max_cycle * (succ / self.sample_size)]
        return np.array(val, dtype = "f")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号