def test_edmot(): """ Test the EdMot procedure. """ graph = nx.newman_watts_strogatz_graph(50, 5, 0.3) model = EdMot() 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 assert type(memberships) == dict graph = nx.newman_watts_strogatz_graph(150, 5, 0.3) model = EdMot() 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 assert type(memberships) == dict
def edmot(population, neighbors, probability): g = nx.newman_watts_strogatz_graph(population, neighbors, probability) model = EdMot(3, 0.5) model.fit(g) #print(model.get_memberships()) return [model.get_memberships()]
g = nx.newman_watts_strogatz_graph(100, 10, 0.2) X = {i: random.sample(range(150), 50) for i in range(100)} row = np.array([k for k, v in X.items() for val in v]) col = np.array([val for k, v in X.items() for val in v]) data = np.ones(100 * 50) shape = (100, 150) X = coo_matrix((data, (row, col)), shape=shape) model = MUSAE() model.fit(g, X) model.get_memberships() #------------------------------------ # SINE example #------------------------------------ g = nx.newman_watts_strogatz_graph(100, 10, 0.2) X = {i: random.sample(range(150), 50) for i in range(100)} row = np.array([k for k, v in X.items() for val in v]) col = np.array([val for k, v in X.items() for val in v]) data = np.ones(100 * 50) shape = (100, 150) X = coo_matrix((data, (row, col)), shape=shape)