Implementing network topology by multiplication of vector and matrix