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 connected graphs INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Cliq u es Simplest comple x cliq u e : a triangle INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Triangle Applications Friend recommendation s y stems INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Cliq u e 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 ... INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Let ' s practice ! IN TR OD U C TION TO N E TW OR K AN ALYSIS IN P YTH ON
Ma x imal 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
Ma x imal cliq u es De � nition : a cliq u e that , w hen e x tended b y one node is no longer a cliq u e INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Ma x imal cliq u es De � nition : a cliq u e that , w hen e x tended b y one node is no longer a cliq u e INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Ma x imal cliq u es Applications : comm u nit y � nding INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Comm u nities Find cliq u es Find u nions of cliq u es INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Net w orkX API find_cliques � nds all ma x imal cliq u es INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Ma x imal cliq u es 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]] INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Ma x imal cliq u es 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]] INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Ma x imal cliq u es 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]] INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Let ' s practice ! IN TR OD U C TION TO N E TW OR K AN ALYSIS IN P YTH ON
S u bgraphs 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
S u bgraphs Vis u ali z e portions of a large graph Paths Comm u nities / cliq u es Degrees of separation from a node INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
S u bgraphs 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) INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
S u bgraphs 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> INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
S u bgraphs nx.draw(G_eight, with_labels=True) INTRODUCTION TO NETWORK ANALYSIS IN PYTHON
Let ' s practice ! IN TR OD U C TION TO N E TW OR K AN ALYSIS IN P YTH ON
Recommend
More recommend