def nnsed(population, neighbors, probability): g = nx.newman_watts_strogatz_graph(population, neighbors, probability) model = NNSED() model.fit(g) embedding = model.get_embedding() #print(embedding) memberships = model.get_memberships() #print(memberships) return [memberships]
def test_nnsed(): """ Test the NNSED procedure. """ graph = nx.newman_watts_strogatz_graph(100, 5, 0.3) model = NNSED() model.fit(graph) memberships = model.get_memberships() indices = [k for k, v in memberships.items()].sort() nodes = [node for node in graph.nodes()].sort() assert graph.number_of_nodes() == len(memberships) assert indices == nodes embedding = model.get_embedding() assert embedding.shape[0] == graph.number_of_nodes() assert embedding.shape[1] == model.dimensions
model.fit(g) embedding = model.get_embedding() #------------------- # GraphWave example #------------------- g = nx.newman_watts_strogatz_graph(100, 10, 0.02) model = GraphWave() model.fit(g) embedding = model.get_embedding() #--------------- # NNSED example #--------------- g = nx.newman_watts_strogatz_graph(100, 10, 0.02) model = NNSED() model.fit(g) embedding = model.get_embedding() memberships = model.get_memberships()