Randomly switch nodes in layers using adjacency matrix