Skip to Content
Think Complexity, 2nd Edition
book

Think Complexity, 2nd Edition

by Allen B. Downey
July 2018
Beginner
198 pages
4h 33m
English
O'Reilly Media, Inc.
Content preview from Think Complexity, 2nd Edition

Chapter 2. Graphs

The next three chapters are about systems made up of components and connections between components. For example, in a social network, the components are people and connections represent friendships, business relationships, etc. In an ecological food web, the components are species and the connections represent predator-prey relationships.

In this chapter, I introduce NetworkX, a Python package for building models of these systems. We start with the Erdős-Rényi model, which has interesting mathematical properties. In the next chapter we move on to models that are more useful for explaining real-world systems.

What Is a Graph?

To most people a “graph” is a visual representation of data, like a bar chart or a plot of stock prices over time. That’s not what this chapter is about.

In this chapter, a graph is a representation of a system that contains discrete, interconnected elements. The elements are represented by nodes—also called vertices—and the interconnections are represented by edges.

For example, you could represent a road map with a node for each city and an edge for each road between cities. Or you could represent a social network using a node for each person, with an edge between two people if they are friends.

In some graphs, edges have attributes like length, cost, or weight. For example, in a road map, the length of an edge might represent distance between cities or travel time. In a social network there might be different kinds of edges to represent different ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Essential Algorithms, 2nd Edition

Essential Algorithms, 2nd Edition

Rod Stephens
Think Data Structures

Think Data Structures

Allen B. Downey
Just Enough Math

Just Enough Math

Paco Nathan

Publisher Resources

ISBN: 9781492040194Errata Page