aspects of the invention pertain to routing packets in a computer system while avoiding deadlock . a turn rule is set according to unique identifiers associated with switches in the system . numeric values of switches in possible turns are compared to determine whether a turn is permissible . the rule applies to all nodes in the system . the rule may be violated when using virtual channels . here , a violation is permissible when using monotonically increasing virtual channel numbers or monotonically decreasing virtual channel numbers . alternatively , the violations of the turn rule may be allowed if they force a packet to change to a later virtual channel in some fixed ordering of virtual channels . deadlock can thus be avoided in many different types of architectures , including mesh , torus , butterfly and flattened butterfly configurations .