def test_grarep(): """ Testing the GraRep class. """ model = GraRep() graph = nx.watts_strogatz_graph(100, 10, 0.5) model.fit(graph) embedding = model.get_embedding() assert embedding.shape[0] == graph.number_of_nodes() assert embedding.shape[1] == model.dimensions*model.order assert type(embedding) == np.ndarray model = GraRep(dimensions=16) graph = nx.watts_strogatz_graph(150, 10, 0.5) model.fit(graph) embedding = model.get_embedding() assert embedding.shape[0] == graph.number_of_nodes() assert embedding.shape[1] == model.dimensions*model.order assert type(embedding) == np.ndarray
def karate_factory(algo, dim, nwalks, workers): if algo == "walklets": karate_obj = Walklets(dimensions=int(dim / 4), walk_number=nwalks, workers=workers) elif algo == "role2vec": karate_obj = Role2Vec(dimensions=dim, walk_number=nwalks, workers=workers) elif algo == "diff2vec": karate_obj = Diff2Vec(dimensions=dim, diffusion_number=nwalks, workers=workers) elif algo == "deepwalk": karate_obj = DeepWalk(dimensions=dim, walk_number=nwalks, workers=workers) elif algo == "boostne": karate_obj = BoostNE(dimensions=int(dim / 17) + 1) elif algo == "nodesketch": karate_obj = NodeSketch(dimensions=dim) elif algo == "netmf": karate_obj = NetMF(dimensions=dim) elif algo == "hope": karate_obj = HOPE(dimensions=dim) elif algo == "grarep": karate_obj = GraRep(dimensions=int(dim / 5) + 1) elif algo == "nmfadmm": karate_obj = NMFADMM(dimensions=int(dim / 2)) elif algo == "graphwave": karate_obj = GraphWave() elif algo == "laplacian": karate_obj = LaplacianEigenmaps(dimensions=dim) else: raise RuntimeError("Invalid model type: %s" % algo) return karate_obj