cycle_variable.py 文件源码

python
阅读 21 收藏 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, samples = 0, 0
        max_cycle = sp.binom(G.order(), self.cycle_length)

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

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

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


问题


面经


文章

微信
公众号

扫码关注公众号