Comm u nities & cliq u es IN TR OD U C TION TO N E TW OR K AN - - PowerPoint PPT Presentation

comm u nities cliq u es
SMART_READER_LITE
LIVE PREVIEW

Comm u nities & cliq u es IN TR OD U C TION TO N E TW OR K AN - - PowerPoint PPT Presentation

Comm u nities & cliq u es IN TR OD U C TION TO N E TW OR K AN ALYSIS IN P YTH ON Eric Ma Data Carpentr y instr u ctor and a u thor of n xv i z package Cliq u es Social cliq u es : tightl y- knit gro u ps Net w ork cliq u es : completel y


slide-1
SLIDE 1

Communities & cliques

IN TR OD U C TION TO N E TW OR K AN ALYSIS IN P YTH ON

Eric Ma

Data Carpentry instructor and author of nxviz package

slide-2
SLIDE 2

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Cliques

Social cliques: tightly-knit groups Network cliques: completely connected graphs

slide-3
SLIDE 3

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Cliques

Simplest complex clique: a triangle

slide-4
SLIDE 4

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Triangle Applications

Friend recommendation systems

slide-5
SLIDE 5

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Clique Code

G <networkx.classes.graph.Graph at 0x10c99ecf8> from itertools import combinations for n1, n2 in combinations(G.nodes(), 2): print(n1, n2) 0 1 0 2 0 3 0 4 0 5 ...

slide-6
SLIDE 6

Let's practice!

IN TR OD U C TION TO N E TW OR K AN ALYSIS IN P YTH ON

slide-7
SLIDE 7

Maximal cliques

IN TR OD U C TION TO N E TW OR K AN ALYSIS IN P YTH ON

Eric Ma

Data Carpentry instructor and author of nxviz package

slide-8
SLIDE 8

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Maximal cliques

Denition: a clique that, when extended by one node is no longer a clique

slide-9
SLIDE 9

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Maximal cliques

Denition: a clique that, when extended by one node is no longer a clique

slide-10
SLIDE 10

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Maximal cliques

Applications: community nding

slide-11
SLIDE 11

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Communities

Find cliques Find unions of cliques

slide-12
SLIDE 12

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

NetworkX API

find_cliques nds all maximal cliques

slide-13
SLIDE 13

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Maximal cliques

import networkx as nx G = nx.barbell_graph(m1=5, m2=1) nx.find_cliques(G) <generator object find_cliques at 0x1043f1f68> list(nx.find_cliques(G)) [[4, 0, 1, 2, 3], [4, 5], [6, 8, 9, 10, 7], [6, 5]]

slide-14
SLIDE 14

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Maximal cliques

import networkx as nx G = nx.barbell_graph(m1=5, m2=1) nx.find_cliques(G) <generator object find_cliques at 0x1043f1f68> list(nx.find_cliques(G)) [[4, 0, 1, 2, 3], [4, 5], [6, 8, 9, 10, 7], [6, 5]]

slide-15
SLIDE 15

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Maximal cliques

import networkx as nx G = nx.barbell_graph(m1=5, m2=1) nx.find_cliques(G) <generator object find_cliques at 0x1043f1f68> list(nx.find_cliques(G)) [[4, 0, 1, 2, 3], [4, 5], [6, 8, 9, 10, 7], [6, 5]]

slide-16
SLIDE 16

Let's practice!

IN TR OD U C TION TO N E TW OR K AN ALYSIS IN P YTH ON

slide-17
SLIDE 17

Subgraphs

IN TR OD U C TION TO N E TW OR K AN ALYSIS IN P YTH ON

Eric Ma

Data Carpentry instructor and author of nxviz package

slide-18
SLIDE 18

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Subgraphs

Visualize portions of a large graph Paths Communities/cliques Degrees of separation from a node

slide-19
SLIDE 19

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Subgraphs

import networkx as nx G = nx.erdos_renyi_graph(n=20, p=0.2) G.nodes() [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] nodes = G.neighbors(8) nodes [2, 3, 4, 10] nodes.append(8)

slide-20
SLIDE 20

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Subgraphs

G_eight = G.subgraph(nodes) G_eight.edges() [(8, 2), (8, 3), (8, 4), (8, 10), (2, 10)] G_eight <networkx.classes.graph.Graph at 0x10cae39e8> G <networkx.classes.graph.Graph at 0x10cad1f60>

slide-21
SLIDE 21

INTRODUCTION TO NETWORK ANALYSIS IN PYTHON

Subgraphs

nx.draw(G_eight, with_labels=True)

slide-22
SLIDE 22

Let's practice!

IN TR OD U C TION TO N E TW OR K AN ALYSIS IN P YTH ON