An efficient representation of Benes networks and its applications