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")
评论列表
文章目录