brainconn.reference.randomize_graph_partial_und

randomize_graph_partial_und(A, B, maxswap)[source]

A = RANDOMIZE_GRAPH_PARTIAL_UND(A,B,MAXSWAP) takes adjacency matrices A and B and attempts to randomize matrix A by performing MAXSWAP rewirings. The rewirings will avoid any spots where matrix B is nonzero.

Parameters:
  • A (NxN numpy.ndarray) – undirected adjacency matrix to randomize
  • B (NxN numpy.ndarray) – mask; edges to avoid
  • maxswap (int) – number of rewirings
Returns:

A – randomized matrix

Return type:

NxN numpy.ndarray

Notes

  1. Graph may become disconnected as a result of rewiring. Always
important to check.
  1. A can be weighted, though the weighted degree sequence will not be
preserved.
  1. A must be undirected.