This book addresses the emerging body of literature on the study of rare events in random graphs and networks. For example, what does a random graph look like if by chance it has far more triangles than expected? Until recently, probability theory offered no tools to help answer such questions. Important advances have been made in the last few years, employing tools from the newly developed theory of graph limits. This work represents the first book-length treatment of this area, while also exploring the related area of exponential random graphs. All required results from analysis, combinatorics, graph theory and classical large deviations theory are developed from scratch, making the text self-contained and doing away with the need to look up external references. Further, the book is written in a format and style that are accessible for beginning graduate students in mathematics and statistics.