def test_netlsd(): """ Test the NetLSD embedding. """ graphs = [nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(100)] model = NetLSD() model.fit(graphs) embedding = model.get_embedding() assert embedding.shape[0] == len(graphs) assert embedding.shape[1] == model.scale_steps assert type(embedding) == np.ndarray graphs = [nx.newman_watts_strogatz_graph(500, 5, 0.3) for _ in range(100)] model = NetLSD() model.fit(graphs) embedding = model.get_embedding() assert embedding.shape[0] == len(graphs) assert embedding.shape[1] == model.scale_steps assert type(embedding) == np.ndarray
g = nx.newman_watts_strogatz_graph(1000, 20, 0.05) model = NetMF() meta_model = NEU() meta_model.fit(g, model) #----------------------------------- # NetLSD example #----------------------------------- graphs = [nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(100)] model = NetLSD() model.fit(graphs) model.get_embedding() #------------------------------------ # MUSAE 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)
"""NetLSD illustrative example.""" import networkx as nx from karateclub.graph_embedding import NetLSD graphs = [nx.newman_watts_strogatz_graph(50, 5, 0.3) for _ in range(100)] model = NetLSD() model.fit(graphs) model.get_embedding()