There is a presumption that the leader of the largest party should be PM but there is nothing requiring it. True the outgoing PM gets first dibs on forming a government and the outgoing government stays in place until another one is formed. If the outgoing PM can’t form one then the leader of the opposition has the next go, however if they can’t then it is possible especially if the LibDems had won the largest number of votes (which I doubt at the moment will be the case) that the Queen might ask Nick Clegg to try and form a government. Labour might be very tempted into agreeing to this, and if they were willing to jump in that direction then so too might the Tories. Fact is that the Conservatives served under a Labour PM in the 30s, of course that was the Great Depression.
To get Nick Clegg as PM does not require the LibDems be the largest party, it merely requires that he could assemble a majority in parliament. It could even be an agreed short term government of 2 years with a platform of reform of the electoral system while cutting public spending, rising some taxes while reducing others that might get the UK economy moving again.