Statistical mechanics of networks