Types of graphs

Introduction to Network Analysis in Python

Eric Ma

Data Carpentry instructor and author of nxviz package

Undirected graphs

  • Facebook social graph

Graph with two nodes connected by an edge

Introduction to Network Analysis in Python

Undirected graphs

import networkx as nx
G = nx.Graph()
type(G)
networkx.classes.graph.Graph
Introduction to Network Analysis in Python

Directed graphs

  • Directed: Twitter social graph

Graph with two nodes connected by a directed edge, with direction indicated by an arrow

Introduction to Network Analysis in Python

Directed graphs

D = nx.DiGraph()
type(D)
networkx.classes.digraph.DiGraph
Introduction to Network Analysis in Python

Types of graphs

  • Multi(Di)Graph: Trip records between bike sharing stations

Graph with two nodes connected by three directed edges

Introduction to Network Analysis in Python

Multi-edge (Directed) graphs

M = nx.MultiGraph()

type(M)
networkx.classes.multigraph.MultiGraph
MD = nx.MultiDiGraph()
type(MD)
networkx.classes.multidigraph.MultiDiGraph
Introduction to Network Analysis in Python

Weights on graphs

  • Edges can contain weights

ch1-2.022.png

Introduction to Network Analysis in Python

Weights on graphs

  • Edges can contain weights

Graph with two nodes connected by a directed edge

Introduction to Network Analysis in Python

Weights on graphs

  • Edges can contain weights

Graph with two nodes connected by a weighted, directed edge, with weight indicated by a number

Introduction to Network Analysis in Python

Self-loops

  • Nodes that are connected to themselves

Graph with one node connected to itself via a looped edge

Introduction to Network Analysis in Python

Let's practice!

Introduction to Network Analysis in Python

Preparing Video For Download...