Introduction to networks Network Analysis in Python I Networks! - - PowerPoint PPT Presentation

introduction to networks
SMART_READER_LITE
LIVE PREVIEW

Introduction to networks Network Analysis in Python I Networks! - - PowerPoint PPT Presentation

NETWORK ANALYSIS IN PYTHON I Introduction to networks Network Analysis in Python I Networks! Examples: Social Transportation Model relationships between entities Network Analysis in Python I Networks! Insights:


slide-1
SLIDE 1

NETWORK ANALYSIS IN PYTHON I

Introduction to networks

slide-2
SLIDE 2

Network Analysis in Python I

Networks!

  • Examples:
  • Social
  • Transportation
  • Model relationships between entities
slide-3
SLIDE 3

Network Analysis in Python I

Networks!

  • Insights:
  • Important entities: influencers in social network
  • Pathfinding: most efficient transport path
  • Clustering: finding communities
slide-4
SLIDE 4

Network Analysis in Python I

Network structure

Node Node Edge Graph

slide-5
SLIDE 5

Network Analysis in Python I

Network structure

Hugo: id: 1, age: 34 Friendship: date: 2016-05-21 Social Graph Eric: id: 2, age: 29

slide-6
SLIDE 6

Network Analysis in Python I

NetworkX API basics

In [1]: import networkx as nx In [2]: G = nx.Graph() In [4]: G.add_nodes_from([1, 2, 3]) In [5]: G.nodes() Out[5]: [1, 2, 3] In [6]: G.add_edge(1, 2) In [7]: G.edges() Out[7]: [(1, 2)]

slide-7
SLIDE 7

Network Analysis in Python I

NetworkX API basics

In [8]: G.node[1]['label'] = 'blue' In [9]: G.nodes(data=True) Out[9]: [(1, {'label': 'blue'}), (2, {}), (3, {})]

slide-8
SLIDE 8

Network Analysis in Python I

NetworkX API basics

In [10]: nx.draw(G) In [11]: import matplotlib.pyplot as plt In [12]: plt.show()

slide-9
SLIDE 9

NETWORK ANALYSIS IN PYTHON I

Let’s practice!

slide-10
SLIDE 10

NETWORK ANALYSIS IN PYTHON

Types of graphs

slide-11
SLIDE 11

Network Analysis in Python I

  • Facebook social graph

Undirected graphs

slide-12
SLIDE 12

Network Analysis in Python I

Undirected graphs

In [1]: import networkx as nx In [2]: G = nx.Graph() In [3]: type(G) Out[3]: networkx.classes.graph.Graph

slide-13
SLIDE 13

Network Analysis in Python I

  • Directed: Twier social graph

Directed graphs

slide-14
SLIDE 14

Network Analysis in Python I

Directed graphs

In [4]: D = nx.DiGraph() In [5]: type(D) Out[5]: networkx.classes.digraph.DiGraph

slide-15
SLIDE 15

Network Analysis in Python I

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

Types of graphs

slide-16
SLIDE 16

Network Analysis in Python I

Multi-edge (Directed) graphs

In [6]: M = nx.MultiGraph() In [7]: type(M) Out[7]: networkx.classes.multigraph.MultiGraph In [8]: MD = nx.MultiDiGraph() In [9]: type(MD) Out[9]: networkx.classes.multidigraph.MultiDiGraph

slide-17
SLIDE 17

Network Analysis in Python I

  • Edges can contain weights

Weights on graphs

3

slide-18
SLIDE 18

Network Analysis in Python I

  • Nodes that are connected to themselves

Self-loops

slide-19
SLIDE 19

NETWORK ANALYSIS IN PYTHON I

Let’s practice!

slide-20
SLIDE 20

NETWORK ANALYSIS IN PYTHON I

Network visualization

slide-21
SLIDE 21

Network Analysis in Python I

Irrational vs. Rational visualizations

slide-22
SLIDE 22

Network Analysis in Python I

Visualizing networks

  • Matrix plots
  • Arc plots
  • Circos plots
slide-23
SLIDE 23

Network Analysis in Python I

Visualizing networks

  • Matrix plots
  • Arc plots
  • Circos plots
slide-24
SLIDE 24

Network Analysis in Python I

Matrix plot

A B C A B C

A B C

slide-25
SLIDE 25

Network Analysis in Python I

Matrix plot

A B C A B C

A B C

slide-26
SLIDE 26

Network Analysis in Python I

Matrix plot

A B C A B C

A B C

slide-27
SLIDE 27

Network Analysis in Python I

Matrix plot

A B C A B C

A B C

slide-28
SLIDE 28

Network Analysis in Python I

Directed matrices

A B C A B C

A B C

slide-29
SLIDE 29

Network Analysis in Python I

Visualizing networks

  • Matrix Plots
  • Arc Plots
  • Circos Plots
slide-30
SLIDE 30

Network Analysis in Python I

Arc plot

A B C A B C

  • rdered axis
slide-31
SLIDE 31

Network Analysis in Python I

Visualizing networks

  • Matrix Plots
  • Arc Plots
  • Circos Plots
slide-32
SLIDE 32

Network Analysis in Python I

Circos plot

A C B D E F A C B D E F

slide-33
SLIDE 33

Network Analysis in Python I

nxviz API

In [1]: import nxviz as nv In [2]: import matplotlib.pyplot as plt In [3]: ap = nv.ArcPlot(G) In [4]: ap.draw() In [5]: plt.show()

slide-34
SLIDE 34

NETWORK ANALYSIS IN PYTHON I

Let’s practice!