Optimal path for a quantum teleportation protocol in entangled networks