Social network analysis

Social network analysis studies social relations using network theory. Nodes represent participants in a network. Lines between nodes represent relationships. Formally, this is called a graph. Due to the constraints of this book, we will only have a quick look at a simple graph that comes with the popular NetworkX Python library. matplotlib will help with the visualization of the graph.

Install NetworkX with the following commands:

$ pip install networkx
$ pip freeze|grep networkx
networkx==1.9

The import convention for NetworkX is as follows:

import networkx as nx

NetworkX provides a number of sample graphs, which can be listed as follows:

print [s for s in dir(nx) if s.endswith('graph')]

Load the Davis Southern women graph ...

Get Python Data Analysis now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.