You are on page 1of 61

Social (complex)

Networks
Analysis
Complex
Networks Basics

Rushed Kanawati
kanawati@sorbonne-paris-nord.fr
https://www.kanawati.fr
Plan

INTERACTION BACKGROUND: TOPOLOGICAL (RANDOM) COMPLEX NETWORKS


NETWORKS GRAPH THEORY FEATURES OF NETWORKS MODELS ANALYSIS TASKS
COMPLEX NETWORKS

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 2


Interaction
Networks

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 3


Interaction networks

Graphs modelling direct/indirect interactions among actors.

Direct interactions: Indirect interactions:


• Friendship • Affiliation share
• Proximity • Preference share
• Message exchange • Similarity
•… •…

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 4


Similarity graphs

𝜺- neighbourhood graph : {𝑢, 𝑣} are linked if 𝑠𝑖𝑚 𝑢, 𝑣 ≥ 𝜖


𝐶𝑜𝑚𝑝𝑙𝑒𝑥𝑖𝑡𝑦 𝒪(𝑛!)
KNN-graph : Each item is connected to the K most similar items
𝐶𝑜𝑚𝑝𝑙𝑒𝑥𝑖𝑡𝑦 𝒪(𝑛!)
Relative neighbourhood graph (RNG) :
𝐶𝑜𝑚𝑝𝑙𝑒𝑥𝑖𝑡𝑦 𝒪(𝑛")

𝑢, 𝑣 𝑎𝑟𝑒 𝑙𝑖𝑛𝑘𝑒𝑑 𝑖𝑓 𝑠𝑖𝑚𝑖𝑙𝑎𝑟𝑖𝑡𝑦 𝑢, 𝑣 ≥ max{𝑠𝑖𝑚 𝑢, 𝑥 , 𝑠𝑖𝑚(𝑣, 𝑥)} ∀𝑥 ≠ 𝑢, 𝑣


#

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 5


Similarity graphs: illustration

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 6


RNG graph example

Iris dataset :

Node’s colors code the class

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 7


Direct interaction
Social networks

Zachary Karate Club is a friendship-based


network observed in the context of a Karate
Club that have been split into two clubs after a
disputer between the manger and the coach.

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 8


Direct interaction
Social networks

Florentine families network : Marriage


network among 16 Florentine families (values
reflect wealth).
.

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 9


Direct interaction
Social networks

Social network of tribes of the Gahuku–Gama


alliance structure of the Eastern Central
Highlands of New Guinea, from Kenneth Read
(1954). The dataset contains a list of all of links,
where a link represents signed friendships
between tribes.

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 10


Direct interaction
Social networks

Advogato is a social community platform


where users can explicitly express weighted
trust relationships among themselves. The
dataset contains a list of all of the user-to-user
links.

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 11


Direct interaction
Social networks

Twitter Higgs Boson This dataset is used to


study the spreading processes on Twitter
before, during and after the announcement of
the discovery of a new particle with the
features of the elusive Higgs boson on 4th July
2012.

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 12


indirect interaction
Social networks

DBLP co-authorship network (1980-1984) -


authors are active for more than 10 years.

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 13


indirect interaction
Social networks

MovieLens co-rating network : users that co-


rate by rate 1 at least one movie

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 14


Other types of similar networks
http://networkrepository.com

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 15


Graph theory

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 16


Graph: Definitions

!
A graph G = < 𝑉 𝐺 , 𝐸 𝐺 ⊆ 𝑉 𝐺 >
V(G) : set of Vertices (actors, nodes, sites, …)
nG = | V(G) | is the order of G
E(G) : set of Edges (links, ties, arcs, bonds …)
E(G) = { 𝑥" , 𝑥# : 𝑥" , 𝑥# ∈ 𝑉 𝐺 ∧ 𝑥" ≠ 𝑥# } No loops, neither multi-edges

mG = | E(G) | is the size of G


G is sparse if mG ~ nG for nG >> 1
08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 17
Graph: Illustration

𝑉 𝐺 = 1,2,3,4,5

𝑛! = 5

𝐸 𝐺 = { 1,2 , 1,3 , 1,3 , 2,4 , {3,4}}

𝑚! = 5
08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 18
Graph: igraph code

>library(igraph)
>g <- graph(edges=c(1,2,2,3,1,3,3,4,2,4), n=5,
directed=FALSE)
>vcount(g) ## length(V(g))
[1] 5
>ecount(g) ## length(E(g))
[1] 4
>plot(g, vertex.color="gold", edge.curved=TRUE,
layout= layout_in_circle)

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 19


Graph: some other types

Directed Weighted Bipartite K-partite

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 20


Graph: some other types

https://en.wikipedia.org/wiki/Hyper
graph

Throught this course we generally consider undirected binary graphs unless otherwise explicitly cited

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 21


Neighbourhood: definitions

Γ 𝑣 = {𝑥! ∈ 𝑉 𝐺 : 𝑣, 𝑥! ∈ 𝐸 𝐺 } Open neighbourhood

Γ(𝑣) = Γ 𝑣 ∪ {𝑣} Closed neighbourhood

Degree of vertex 𝑣
𝑑" = |Γ 𝑣 |
∑!∈# $ &! ()$
𝛿#"$ 𝐺 = = Average degree of G
'$ '$

Exercise: Demonstrate that ∑!∈# $ 𝑑! = 2𝑚$

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 22


Neighbourhood: Illustration

Γ 2 = {1,3,4}

Γ(2) = {1,3,4} ∪ {2} = {1,2,3,4}

𝑑( = Γ 2 =3

∑!∈# $ &! ()$ (∗+


𝛿#"$ 𝐺 = = = =2
'$ '$ +

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 23


Neighbourhood: igraph code

> neighbors(g,2)
+ 3/5 vertices, from 18848b1:
[1] 1 3 4
> degree(g,2)
[1] 3
> degree(g)
[1] 2 3 3 2 0
> average.path.length(g)
[1] 1.166667

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 24


Degree distribution

|{𝑣8 ∈ 𝑉 𝐺 : 𝑑9! = 𝑘|
𝑃 𝑘 =
𝑛!
Regular graph Random graph Scale-Free graph

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 25


Degree distribution: igraph code

> g <- graph.famous("zachary") # Karate club


> plot(g, vertex.label=NA, vertex.color="gold",
layout=layout_as_star)
> degree.distribution(g)
[1] 0.00000000 0.02941176 0.32352941 0.17647059
0.17647059 0.08823529 0.05882353 0.00000000 0.00000000
[10] 0.02941176 0.02941176 0.00000000 0.02941176
0.00000000 0.00000000 0.00000000 0.02941176 0.02941176
>plot(degree.distribution(g), type="l")
> degree(g) %>% table() %>% plot(type="l")
08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 26
Graph Density

Density = Probability of having a link between two


randomly selected nodes

2 𝑚!
𝜌(𝐺) =
𝑛! (𝑛! − 1)
> g <- graph(edges=c(1,2,2,3,1,3,3,4,2,4), n=5, directed=FALSE)
> graph.density(g) 𝜌(𝐺) = 0.5
[1] 0.5

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 27


Paths: definitions

𝜎 ! (𝑢, 𝑣) = { [𝑥0, 𝑥1, … , 𝑥𝑘]: 𝑥0 = 𝑢 ∧ 𝑥𝑘 = 𝑣 ∧ Set of elementary paths of length k


linking u and v
∀𝑖, 𝑗 𝑥" , 𝑥# ∈ 𝑉 𝐺 ∧ 𝑥" ≠ 𝑥# ∧
{𝑥" , 𝑥"$% } ∈ E(G)}

𝑆𝑃 𝑢, 𝑣 = min 𝜎 ! (𝑢, 𝑣) ≠ 𝜙 Set of shortest paths linking u and v


!
𝑑 𝑢, 𝑣 = |𝛿 ∈ 𝑆𝑃 𝑢, 𝑣 | Geodesic distance between u and v
∑&,(∈*(,) 𝑑(𝑢, 𝑣)
𝛿 𝐺 = . Average distance
/

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 28


Paths: Illustration

𝜎 " 1,4 = { 1,2,3,4 , [1,3,2,4]}

SP 1,4 = 𝜎 !(1,4) = { 1,3,4 , [1,2,4]}

𝑑 1,4 = 2

1212! 2 121 21 4
𝛿 𝐺 = = = 1.166667
3 3

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 29


Paths: igraph code

>paths<-all_simple_paths(g,1,4)
> paths[lapply(paths,length)==4] #𝜎 % 1,4
[[1]]
+ 4/5 vertices, from 86325cf:
[1] 1 2 3 4

[[2]]
+ 4/5 vertices, from 86325cf:
[1] 1 3 2 4

Exercise : What is the complexity of computing all simple paths ?

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 30


Paths: igraph code
> all_shortest_paths(g,1,4)

$res

$res[[1]]

+ 3/5 vertices, from 86325cf:

[1] 1 3 4

$res[[2]]

+ 3/5 vertices, from 86325cf:

[1] 1 2 4

$nrgeo #shortest path length between source and each node


[1] 1 1 1 2 0

> > shortest.paths(g,1,4)# Geodesic distance

[,1]

[1,] 2

> average.path.length(g,directed = FALSE,unconnected = TRUE)


[1] 1.166667

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 31


Paths: Algorithms

Single source shortest paths Breadth First Search (BFS)

Graph type Algorithm Time complexity


1
Binary Breadth First 𝒪(𝑛$ + 𝑚$ )
Search
Positive weighted undirected Dijkstra (1959) 𝒪(𝑛$& ) 2 3
Positive weighted undirected Fredman & Tarjan 𝒪(𝑚$ + 𝑛$ log 𝑛$ )
(Fibonacci heap)
ℕ weighted undirected Thorup (1999) 𝒪(𝑚$ ) 4

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 32


Paths: Algorithms

All pairs shortest paths

Graph type Algorithm Time complexity

Binary Breadth First Search 𝒪(𝑛$ (𝑛$ + 𝑚$ ))

Positive weighted undirected Floyed-Warshall (1962) 𝒪(𝑛$% )

ℕ weighted undirected Thorup (1999) 𝒪(𝑛$ 𝑚$ )

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 33


Eccentricity, Diameter & Radius

𝐸𝐶𝐶(𝑣 ∈ 𝑉(𝐺)) = max 𝑑(𝑥, 𝑣)


#∈A B

𝐷𝑖𝑎𝑚(𝐺) = max 𝐸𝐶𝐶(𝑣)


C∈A B

𝑅𝑎𝑑𝑖𝑢𝑠 𝐺 = min 𝐸𝐶𝐶(𝑣)


C∈A B

𝑅𝑎𝑑𝑖𝑢𝑠 𝐺 ≤ 𝐷𝑖𝑎𝑚 𝐺 ≤ 2 𝑅𝑎𝑑𝑖𝑢𝑠 𝐺


08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 34
Eccentricity, Diameter & Radius: code igraph

> eccentricity(g)
[1] 2 1 1 2 0
> diameter(g) # Attention g is unconnected!
[1] 2
> radius(g)
[1] 0

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 35


Connectedness

G is Connected iif ∀𝑣8 , 𝑣: ∈ 𝑉 𝐺 ∃𝑘 > 1; 𝜎 ; 𝑣8 , 𝑣: ≠𝜙


A graph may be composed of several connected components.
Giant component : a component with most of the vertices of the
network.

Algorithm: BFS 𝒪(𝑛! + 𝑚! )

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 36


Connectedness: igraph code

> is_connected(g)
[1] FALSE
> clusters(g)
$membership
[1] 1 1 1 1 2
$csize
[1] 4 1
$no
[1] 2

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 37


Clustering coefficient

Probability of having a link between two nodes that share a common neighbour

What is the probability that two friends of a given person are friends themselves ?

Global version Local version

3 ×#Δ #𝑙𝑖𝑛𝑘𝑠 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 𝑛𝑒𝑖𝑔ℎ𝑏𝑜𝑢𝑟𝑠 𝑜𝑓 𝑣


𝐶𝐶 𝐺 = 𝐶𝐶 𝐺, 𝑣 =
#∧ #𝑝𝑜𝑡𝑒𝑛𝑡𝑖𝑎𝑙 𝑙𝑖𝑛𝑘𝑠 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 𝑛𝑒𝑖𝑔ℎ𝑏𝑜𝑟𝑠 𝑜𝑓 𝑣

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 38


Clustering coefficient: illustration

> transitivity(g). # global version


[1] 0.75
> transitivity(g,type="local")
[1] 1.0000000 0.6666667 0.6666667 1.0000000
NaN

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 39


Graph representation: Adjacency Matrix

𝑎DE = 1 𝑖𝑓 {𝑉D , 𝑉E } ∈ 𝐸 𝐺 ; 0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒

01100
10110
𝐴, = 11010
01100
00000

What are the basic proprieties of 𝐴$ ?


What can you say about 𝐴'$ ?

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 40


Graph representation: Incidence Matrix

𝑏DE = 1 𝑖𝑓 𝑉D 𝑖𝑠 𝑖𝑛𝑐𝑖𝑑𝑒𝑛𝑡 𝑡𝑜 𝑒𝑑𝑔𝑒 𝑘;


0 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒

11000
10110
𝐵, = 01100
00011
00000

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 41


Graph representation: Edge List

The IJ-form of 𝐴$

1,2
1,3
2,3
2,4
3,4

Suitable for sparse graphs

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 42


Complex
Networks
Topological
Features
08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 43
Small-World experiment
(1967)

- Goal: delivering letters to a Broker at Boston

- Source : Random selected persons from Boston area


and also from Nebraska

- 217 letters have been sent : 64 has been received.

- Average path length : 5.2

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 44


Paul Erdös collaboration network

- A very productive Hungarian


Mathematician who has published
over 1500 scientific paper

- Erdös Number : distance from


Erdös in co-authorship network

- https://www.oakland.edu/enp/

- Diameter of 2-Erdös is 5

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 45


Basic topological features

Density Diameter

Clustering Degree
coefficient Distribution

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 46


Social networks
Advogato

𝜌B 𝐷𝑖𝑎𝑚 𝐺

2 10H" 11

CC

9 10H!

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 47


Social networks Direct interaction

Twitter Higgs Boson

𝜌B 𝐷𝑖𝑎𝑚 𝐺

10H" 7

CC

3 10H!

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 48


Social networks
indirect interaction

DBLP co-authorship network (1980-1984)

𝜌% 𝐷𝑖𝑎𝑚 𝐺

10&' 24

CC

0.67

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 49


Social networks Direct interaction

Tribes of the Gahuku–Gama

𝜌(𝐺)
𝐷𝑖𝑎𝑚 𝐺

0.54
3

CC

0.65

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 50


Wikipedia network
Direct interaction

𝜌(𝐺)
𝐷𝑖𝑎𝑚 𝐺

2H"
28

CC

0.47

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 51


Similarity network

𝜌(𝐺) 𝐷𝑖𝑎𝑚 𝐺

0.052 7

CC

0.97
Public sites accessibility in Bourget District, Paris Area
08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 52
(Random)
Networks
Models

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 53


Erdös-Rényi model

𝐺 I,J 𝐺 I,X

𝑛 : number of nodes 𝑛 : number of nodes


𝑝 ∶ 𝑝𝑟𝑜𝑏𝑎𝑏𝑖𝑙𝑖𝑡𝑦 𝑜𝑓 𝑎𝑛 𝑒𝑑𝑔𝑒 m 𝑟𝑎𝑛𝑑𝑜𝑚𝑙𝑦 𝑐ℎ𝑜𝑠𝑒𝑛 𝑒𝑑𝑔𝑒𝑠

Complexity : 𝒪(𝑛& ) Complexity : 𝒪(𝑚)

Generated graphs properties (see lab 1)

- Low diameter
- Sparse
- Homogeneous degree distribution
- Low clustering coefficient

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 54


Molloy & Reed Model

Generated graphs properties (see lab 1)

- Low diameter
- Sparse
- Heterogenous degree distribution
Force a heterogenous degree distribution,
- Low clustering coefficient
with random linking

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 55


http://www.stevenstrogatz.com

Strogatz-Watts model
https://en.wikipedia.org/wiki/Duncan_J._Watts

0 𝑝
1
08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 56
Strogatz-Watts model

Generated graphs properties (see lab 1)

- Low diameter
- Sparse
- Homogeneous degree distribution
- High clustering coefficient

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 57


Preferential Attachment model
Albert Barbasi

Preferential attachment law


Nodes are joining the network one by one.
The probability of node 𝑣( to connect to a new comer is proportional to 𝑑(𝑣( )

Generated graphs properties (see lab 1)

- Low diameter
- Sparse
- Heterogenous degree distribution
- Very low clustering coefficient

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 58


Complex
Networks
Analysis
Tasks
08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 59
Complex Networks Analysis

Networks dynamics

Dynamics on networks

Community oriented tasks

Link oriented tasks

Node oriented tasks

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 60


Take home notes

Complex networks:

• are everywhere
• are not random
• are not captured by a simple mathematical model
• share a set of untrivial topological features :
• sparsity
• low diameter
• heterogeneous degree distribution
• high clustering coefficient
• community structure
• analysis can allow gaining insights in a wide range of domains.

08/01/2021 SNA - Chapter 1 Complex Networks Basics (R. Kanawati) 61

You might also like