Created
April 16, 2018 05:59
-
-
Save marquisthunder/09aa45c38a4f2fad170baa0e5a2305f7 to your computer and use it in GitHub Desktop.
[graph_tool] rand_neightbor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import graph_tool | |
| from graph_tool.spectral import adjacency | |
| import numpy as np | |
| g = graph_tool.Graph() | |
| g.add_vertex(100) | |
| edges = np.random.randint(0, 100, (500,2)) | |
| g.add_edge_list(edges) | |
| mat = adjacency(g).tolil() | |
| rows = mat.rows.copy() # mat.rows = in-neighbours for each vertex | |
| map(np.random.shuffle, rows) | |
| rnd_neighbours = { i:row[0] for i, row in enumerate(rows) if row } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment