Network Science with Python and NetworkX Quick Start Guide - Edward L. Platt - E-Book

Network Science with Python and NetworkX Quick Start Guide E-Book

Edward L. Platt

0,0
28,14 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Manipulate and analyze network data with the power of Python and NetworkX




Key Features



  • Understand the terminology and basic concepts of network science


  • Leverage the power of Python and NetworkX to represent data as a network


  • Apply common techniques for working with network data of varying sizes





Book Description



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.





What you will learn



  • Use Python and NetworkX to analyze the properties of individuals and relationships


  • Encode data in network nodes and edges using NetworkX


  • Manipulate, store, and summarize data in network nodes and edges


  • Visualize a network using circular, directed and shell layouts


  • Find out how simulating behavior on networks can give insights into real-world problems


  • Understand the ongoing impact of network science on society, and its ethical considerations





Who this book is for



If you are a programmer or data scientist who wants to manipulate and analyze network data in Python, this book is perfect for you. Although prior knowledge of network science is not necessary, some Python programming experience will help you understand the concepts covered in the book easily.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 192

Veröffentlichungsjahr: 2019

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Network Science with Python and NetworkX Quick Start Guide

 

Explore and visualize network data effectively

 

 

 

 

 

 

 

 

 

 

 

Edward L. Platt

 

 

 

 

 

 

 

 

 

 

BIRMINGHAM - MUMBAI

Network Science with Python and NetworkX Quick Start Guide

Copyright © 2019 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

 

Commissioning Editor:Amey VarangaonkarAcquisition Editor:Sandeep MishraContent Development Editor: Smit CarvalhoTechnical Editor: Diksha WakodeCopy Editor: Safis EditingProject Coordinator:Kinjal BariProofreader: Safis EditingIndexer: Tejal Daruwale SoniGraphics: Alishon MendonsaProduction Coordinator:Jyoti Chauhan

First published: April 2019

Production reference: 1250419

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.

ISBN 978-1-78995-531-6

www.packtpub.com

To Mr. G. and Chiz, and to all teachers who support students in following unusual paths.
 
mapt.io

Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.

Why subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content

Packt.com

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.

At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks. 

Contributors

About the author

Edward L. Platt creates technology for communities and communities for technology. He is currently a researcher at the University of Michigan School of Information and the Center for the Study of Complex Systems. He has published research on large-scale collective action, social networks, and online communities. He was formerly a staff researcher at the MIT Center for Civic Media. He contributes to many free/open source software projects, including tools for media analysis, network science, and cooperative organizations. He has also done research on quantum computing and fault tolerance. He has an M.Math in Applied Mathematics from the University of Waterloo, as well as B.S degrees in both Computer Science and Physics from MIT.

Many thanks to Andy Brosius for sharing their life and family with me, and for their incredible understanding and support while writing this book. Thanks to Persephone Hernandez-Vogt for their companionship and encouragement. Thanks to my editors at Packt, in particular Sandeep Mishra, for helping make this book a reality. Thanks to my Ph.D. advisor, Daniel Romero, for his mentorship and patience. And thanks to all of the NetworkX contributors.

About the reviewer

Nathan George is a data science professor at Regis University, with experience in manufacturing, neural networks, and Python and R for data science.

 

 

 

Packt is searching for authors like you

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

Table of Contents

Title Page

Copyright and Credits

Network Science with Python and NetworkX Quick Start Guide

Dedication

About Packt

Why subscribe?

Packt.com

Contributors

About the author

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Conventions used

Get in touch

Reviews

What is a Network?

Network science

The history of network science

Network science today

What is a network?

Nodes and edges

Visualizing networks

What is NetworkX?

Types of networks

Directed networks

Weighted networks

Understanding edges

Social networks

Flow networks

Similarity networks

Spatial networks

Your first network in NetworkX

Summary

References

Working with Networks in NetworkX

The Graph class – undirected networks

Adding attributes to nodes and edges

Adding edge weights

The DiGraph class – when direction matters

MultiGraph and MultiDiGraph – parallel edges

Summary

References

From Data to Networks

Modeling your data

Reading and writing network files

Creating a network with code

Summary

References

Affiliation Networks

Nodes and affiliations

Affiliation networks in NetworkX

Projections

Summary

References

The Small Scale - Nodes and Centrality

Centrality – finding key nodes

Bridges, brokers, and bottlenecks – betweenness centrality

Hubs – eigenvector centrality

Closeness centrality

Local clustering

Summary

References

The Big Picture - Describing Networks

The global structure of networks

Datasets

Diameter and mean shortest path

Global clustering

Measuring resilience

Minimum cuts

Connectivity

Centralization and inequality

Summary

References

In-Between - Communities

Communities – networks within networks

Community detection in NetworkX

Modularity maximization

Visualizing

An online social network

Girvan-Newman – betweenness-based communities

Cliques

K-cores

Summary

References

Social Networks and Going Viral

Social networks

Strong and weak ties

Tie strength

Bridge span

Comparing strength and span

The small world problem

Ring networks

A real social network

Random networks

Watts-Strogatz networks

Contagion – how things spread

Simple contagion

Complex contagion

Summary

References

Simulation and Analysis

Watts-Strogatz and small worlds

Preferential attachment and heavy-tailed networks

Configuration models

Agent-based models

Summary

References

Networks in Space and Time

Locations and events

Networks in space

Gravity models

Working with spatial data

Gravity model for air travel

Residual network

Network properties

Networks in time

Layered networks

Working with time data

The evolution of network properties

Summary

References

Visualization

Beyond the hairball

The circular layout

The shell layout

The force-directed layout

Null models

Summary

Conclusion

The practice of network science

Learning more

Advances in network science

The impact of network science

Appendix

Adjacency matrices

Biadjacency matrices

Modularity

Other Books You May Enjoy

Leave a review - let other readers know what you think

Preface

Network science is becoming an increasingly valuable skill for both researchers and data scientists. Tools originally developed by sociologists and other researchers working with pen and paper have seen a resurgence as online platforms and social networks create huge datasets and advances in computer hardware make it feasible to analyze those data sets.

NetworkX is a free, open source Python package for network science. Python has become a popular choice for data scientists, with packages such as NumPy and pandas, making  NetworkX a natural choice for augmenting data analysis with network-based techniques. Because NetworkX is written entirely in Python, it is easy to install across many different platforms. Other packages written in lower-level languages can sometimes provide better performance on very large networks, but can be difficult to install on some systems, and might not run at all on others. NetworkX is a great tool for learning network science and writing code that you can share with anyone.

Because NetworkX is free software, distributed under the Modified BSD License, anyone is free to use it, to look at the code, and to make improvements. As a result, NetworkX has a large and ever-growing set of features. And if it's missing something, you can always add it yourself rather than waiting for someone else to do it.

Who this book is for

I have tried to write this book for aspiring network scientists, managers who work with network scientists, and students from high school to Ph.D. level; anyone who wants to learn the basics of network science from the ground up. The only previous knowledge you will need is some familiarity with the Python programming language, or programming in general. I will avoid the mathematical details, instead focusing on the programming and applications. For the truly adventurous reader, the basic mathematics of networks are described in Appendix.

What this book covers

Chapter 1, What is a Network?, gives an overview of the history of network science and social network analysis, as well as introducing common types of networks and walking you through writing your first program with NetworkX.

Chapter 2, Working with Networks in NetworkX, describes simple, directed, and weighted networks, and how to work with them in NetworkX.

Chapter 3, From Data to Networks, describes functions for loading network data and for creating networks from scratch.

Chapter 4, Affiliation Networks, focuses on networks with two types of nodes (such as groups and group members) and shows how to work with these networks in NetworkX, as well as how to convert them to co-affiliation networks with just a single type of node.

Chapter 5, The Small Scale—Nodes and Centrality, shows how to use NetworkX to analyze network structure by looking at the properties of individual nodes and their connections.

Chapter 6, The Big Picture—Describing Networks, introduces several measures used to classify the structure of entire networks, and shows how these measures can differentiate between different types of real-world networks.

Chapter 7, In-Between—Communities, discusses medium-scale network structure, including community detection, clique detection, and k-cores.

Chapter 8, Social Networks and Going Viral, focuses on the special considerations that arise when network science is applied to social networks, as well as how the properties of social networks influence the spread of contagions such as disease or innovation.

Chapter 9, Simulation and Analysis, introduces several models used to generate networks based on underlying assumptions, as well as how to use agent-based models to simulate the evolution of a networked system.

Chapter 10, Networks in Space and Time, covers special considerations for network data associated with geographic locations and data that changes over time.

Chapter 11, Visualization, describes several visualization functions provided by NetworkX, as well as how to use them to visualize network information effectively.

Chapter 12, Conclusion, summarizes the lessons learned throughout this book, and provides resources for pursuing more advanced topics in network science.

To get the most out of this book

This book assumes very little previous knowledge—only a familiarity with the fundamentals of programming. Knowledge of the Python programming language is helpful for understanding the examples, but for readers only familiar with other programming languages, the code comments and descriptions should not be too difficult to understand.

The examples in this book can be run in any Python environment with access to the required libraries, but Jupyter Lab is recommended and offers several benefits. Jupyter Lab is an interactive programming environment for Python and other languages. Jupyter Lab runs in a web browser and makes it possible to visualize outputs along with the code, as well as to easily modify and re-run chunks of code.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

Log in or register at

www.packt.com

.

Select the

SUPPORT

tab.

Click on

Code Downloads & Errata

.

Enter the name of the book in the

Search

box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR/7-Zip for Windows

Zipeg/iZip/UnRarX for Mac

7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Network-Science-with-Python-and-NetworkX-Quick-Start-Guide. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

 

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at customercare@packtpub.com. 

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

What is a Network?

In 1736, a Swiss mathematician pondered routes for a sightseeing trip along the Pregel River in Königsberg. In 1880, an Italian painter turned zoologist sought to settle a hotly-contested controversy: whether or not birds protect crops by reducing insect populations. In 1932, the superintendent of a girls' reformatory school in Hudson, New York, hired a sociologist to investigate the cause of a recent wave of runaways. In 1955, a U.S. Army General and a mathematician developed a technique for identifying bottlenecks in the Soviet railway system. And, in 1998, two mathematicians in Ithaca, New York tried to figure out (among other things) why exactly all movie stars seem to be connected by Kevin Bacon.

These puzzles, taking place at different times and different places, might, at first glance, appear unrelated. But they have one thing in common: they all revolve around relationships – between people, between places, or between species – and they were all solved using the science of relationships, which has come to be known as network science. Interest in network science has grown considerably in recent years, as online social network platforms, such as Facebook, Twitter, WeChat, and Mastodon, have become increasingly popular.

This book covers the fundamental concepts of network science, as well as how to put them into practice using the Python-based NetworkX package. Part I (Chapter 1, What is a Network?, to Chapter 4, Affiliation Networks) introduces the concept of a network, as well as how to build, manipulate, and visualize networks in NetworkX. Part II (Chapter 5, The Small Scale – Nodes and Centrality, to Chapter 7, In-Between – Communities) demonstrates how to analyze network structure at various scales. Part III (Chapter 8, Social Networks and Going Viral, to Chapter 11, Visualization) applies network science to understanding complex systems using modeling, simulation, and visualization. In this introductory chapter, you'll learn some of the history of network science and the differences between common types of networks. You'll also see examples of different ways that relationships in a network can be interpreted. Finally, you'll get to build and visualize your first network using NetworkX!

In this chapter, we will cover the following topics:

Network science

: Learn the history of the study of networks.

What is a network?

: Understand the fundamental concepts of network science.

What is NetworkX?

: Getting familiar with the NetworkX Python package.

Types of networks

: Meet common variants of networks, and understand their applications.

Your first network in NetworkX

: Try a simple example.

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 calledsociometry(Moreno & Jennings, 1934). These tools included thesociogram, 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. 



Tausende von E-Books und Hörbücher

Ihre Zahl wächst ständig und Sie haben eine Fixpreisgarantie.