Code encapsulation for connectivity matrix