An apparatus , comprising: a network interface , configured to communicate with a network that comprises a plurality of switches interconnected in a Cartesian topology having multiple dimensions; and a processor , configured to: predefine an order among the dimensions of the Cartesian topology; search for a preferred route via the network from a source switch to a destination switch, by evaluating candidate routes based at least on respective numbers of switches along the candidate routes for which traversal to a next-hop switch changes from one of the dimensions to another of the dimensions opposite to the predefined order; and configure one or more of the switches in the network to route packets from the source switch to the destination switch along the preferred route, wherein, at a given stage of searching for the preferred route, the source switch has multiple visited neighboring switches for which preferred routes to the destination switch were already determined, and wherein the processor is configured to select for the source switch a next-hop switch from among the visited neighboring switches based on a predefined criterion, wherein the predefined criterion specifies selecting the next-hop switch for which a dimension traversed from the source switch is maximal in the order of topology dimensions among the visited neighboring switches. a network interface , configured to communicate with a network that comprises a plurality of switches interconnected in a Cartesian topology having multiple dimensions; and a processor , configured to: predefine an order among the dimensions of the Cartesian topology; search for a preferred route via the network from a source switch to a destination switch, by evaluating candidate routes based at least on respective numbers of switches along the candidate routes for which traversal to a next-hop switch changes from one of the dimensions to another of the dimensions opposite to the predefined order; and configure one or more of the switches in the network to route packets from the source switch to the destination switch along the preferred route, wherein, at a given stage of searching for the preferred route, the source switch has multiple visited neighboring switches for which preferred routes to the destination switch were already determined, and wherein the processor is configured to select for the source switch a next-hop switch from among the visited neighboring switches based on a predefined criterion, wherein the predefined criterion specifies selecting the next-hop switch for which a dimension traversed from the source switch is maximal in the order of topology dimensions among the visited neighboring switches. predefine an order among the dimensions of the Cartesian topology; search for a preferred route via the network from a source switch to a destination switch, by evaluating candidate routes based at least on respective numbers of switches along the candidate routes for which traversal to a next-hop switch changes from one of the dimensions to another of the dimensions opposite to the predefined order; and configure one or more of the switches in the network to route packets from the source switch to the destination switch along the preferred route, wherein, at a given stage of searching for the preferred route, the source switch has multiple visited neighboring switches for which preferred routes to the destination switch were already determined, and wherein the processor is configured to select for the source switch a next-hop switch from among the visited neighboring switches based on a predefined criterion, wherein the predefined criterion specifies selecting the next-hop switch for which a dimension traversed from the source switch is maximal in the order of topology dimensions among the visited neighboring switches. <EOS>