1. A computer implemented method for controlling legacy switch routing in one or more hybrid networks of interconnected computers and switches, comprising: generating a network underlay for the one or more hybrid networks by generating a minimum spanning tree (MST) and a forwarding graph (FWG) over a physical network topology of the one or more hybrid networks; determining an optimal path between hosts on the FWG by optimizing an initial path with a minimum cost mapping; and adjusting the initial path to enforce the optimal path by generating and installing special packets in one or more programmable switches to trigger installation of forwarding rules in one or more legacy switches.