Book Image

Network Science with Python and NetworkX Quick Start Guide

By : Edward L. Platt
Book Image

Network Science with Python and NetworkX Quick Start Guide

By: Edward L. Platt

Overview of this book

NetworkX is a leading free and open source package used for network science with the Python programming language. NetworkX can track properties of individuals and relationships, find communities, analyze resilience, detect key network locations, and perform a wide range of important tasks. With the recent release of version 2, NetworkX has been updated to be more powerful and easy to use. If you’re a data scientist, engineer, or computational social scientist, this book will guide you in using the Python programming language to gain insights into real-world networks. Starting with the fundamentals, you’ll be introduced to the core concepts of network science, along with examples that use real-world data and Python code. This book will introduce you to theoretical concepts such as scale-free and small-world networks, centrality measures, and agent-based modeling. You’ll also be able to look for scale-free networks in real data and visualize a network using circular, directed, and shell layouts. By the end of this book, you’ll be able to choose appropriate network representations, use NetworkX to build and characterize networks, and uncover insights while working with real-world systems.
Table of Contents (15 chapters)

Network science

The origins of network science trace back to many different fields. For the most part, researchers in these fields developed the tools and methods of network science without much knowledge of how it was being applied in other fields. It may seem astonishing that scientists working independently in very different fields could develop tools and techniques similar enough to now be considered a single field.

How did this happen? The answer lies in one insight: sometimes, it is useful to study the relationships between things without worrying about the specifics of what those things are. Network scientists didn't study networks for their own sake* – they studied networks in order to better understand people, animal species, atoms, and so on. (* Except for mathematicians. We like to think about weird abstract concepts such as networks just for fun.)

When the specifics of the people/species/atoms being studied were abstracted away, seemingly different problems suddenly became very similar. And that's the power of network science; it provides a general language to talk about relationships and connections, allowing discoveries about one thing to be translated into useful information about many other types of things.

The history of network science

The earliest work recognizable as network science came from the branch of mathematics known as graph theory. Graph theory originated with Leonhard Euler's 1736 solution (Euler, 1953) to the seven bridges problem. At the time, the city of Königsberg, Prussia (now Kaliningrad, Russia) had seven bridges connecting the banks of the Pregel River to two islands (pictured as follows). It was not known whether it was possible to find a path through the city that crossed every bridge exactly once. Euler showed that it was impossible, and he did so using new methods that became the basis for graph theory, and later for network science.

Leonhard Euler was a prolific 18th century mathematician. His surname is pronounced "oiler" (and his work does indeed lubricate the gears of modern mathematics). He is perhaps best remembered by his namesake: Euler's number, e 2.7 (which, confusingly, was discovered by Jacob Bernoulli):
Seventeenth-century Königsberg and its seven bridges

The study of networks also has a rich history in sociology. The sociologists, Jacob L. Moreno and Helen Hall Jennings proposed tools for the quantitative study of interpersonal relationships, which they called sociometry (Moreno & Jennings, 1934). These tools included the sociogram, a graphical representation of social networks very similar to the type of network diagrams currently in use.

When Moreno was hired by Fannie French Morse, superintendent of the New York Training School for Girls, to investigate a wave of runaways, it was sociograms that allowed him to visualize and communicate the nature of the social forces driving the runaways. Many of the tools used in modern network science—centrality, affiliation networks, community detection, and others—come from sociology. Over the past several decades, sociometry has branched into social network analysis, a rich and active subfield within network science.

Sociology is the science concerned with how individuals and their interactions produce institutions and societies. Networks are used in sociology to represent and quantify the relationships between individuals.

Various other fields have found it useful to study network structure, and have shared their tools and findings with each other as part of the interdisciplinary complex systems community. Ecologists study food webs—relationships between predator and prey species. Biologists study networks of interactions between genes. Physicists study magnetic interactions between neighboring atoms in crystals. All of these fields are doing exciting work with network science.

Complex systems are those that arise from the interactions of simpler components, for example, traffic from cars, stock markets from stock trades, and ecologies from species. Networks are used to analyze and study the interrelationships between components.

And then, of course, there's the internet. The internet itself is literally a network—computers and routers connected to each other by copper wire, fiber optic cables, and so on. But, on top of that, the content on the internet is also networked. Links between web pages form networks, and online social networks allow people to interact by friending or following each other. The Google search engine was founded on the PageRank algorithm (Page et al., 1999), a network-science-based approach to identifying popular websites. Online social networks typically make money by selling advertising space, and using network science to show ads to the people most likely to click on them. If you see a picture of a cute cat online, you can use network science to understand how the picture got to your computer screen, how the picture connects you with your friends, and what the picture tells you about other sites you might like to visit.

Online activity leaves digital trace data—records of activity stored in logs and databases. Digital trace data can often be used to construct networks of relationships between individuals. From these networks, it is surprisingly easy to predict many things, such as purchasing preferences (Zhang & Pennacchiotti, 2013), political ideology (Cohen & Ruths, 2013), and even sexual orientation (Jernigan & Mistree, 2009). The powerful techniques available for such data raises both exciting possibilities and complex ethical considerations.

Network science today

With its interdisciplinary nature, network science draws practitioners from a wide variety of backgrounds. At the time of writing this book, only a handful of universities offer programs dedicated to network science, so network scientists tend to be self-taught, or trained as sociologists, physicists, ecologists, and so on. My own path to network science was similarly convoluted. Once an aspiring physicist, I came to realize I cared more about people than atoms, and left grad school to work on technology for civic organizing. When I eventually came across network science, I was excited to find that it was a powerful tool for understanding group behavior, and that the skills I'd learned from physics transferred directly to network science. Since then, I have been using network science to better understand how groups can organize and collaborate more effectively. Whatever your background, network science is a place where everyone fits in because no one fits in.

Network science has experienced rapid growth in recent years, in part due to the popularity of online social networks, digital trace data, and tools such as NetworkX. Once scattered across many different fields, universities are now creating research centers and Ph.D. programs specifically dedicated to network science. Companies have rushed to hire data scientists, including network scientists. There has never been a better time to explore the delightful world of network data.