Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf ·...

50
Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Transcript of Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf ·...

Page 1: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Algorithms and Applications in Social Networks

2019/2020, Semester B

Slava Novgorodov 1

Page 2: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Lesson #3

• Bipartite graph (recap)

• Networks with Signed Edges– Single edge

– Theory of Balance

– Examples

2

Page 3: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Bipartite Graph

3

Page 4: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Bipartite Graph

• A graph whose vertices can be divided into two disjoint sets U and V such that every edge connects a vertex in U to one in V

• A bipartite graph does not contain any odd-length cycles

• A bipartite graph can be vertex colored wtih 2 colors

4

Page 5: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Testing Bipartiteness

• Triangle – not bipatite

• Graph contains an odd cycle – not bipartite

5

Page 6: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Testing Bipartiteness

• Is given graph bipartite?

• Algorithm:– Select and node and perform BFS, color each layer

alternate colors

– Scan all the edges, see if any edge has nodes with the same color (one layer nodes)

6

Page 7: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Usage of Bipartite Graph

• Different types of nodes:– Users/Items ranking

– Papers/Authors

– Courses/Students

Folded network 🡪

7

Page 8: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Networks with Signed Edges

8

Page 9: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Networks with Signed Edges

• Sometimes just “Signed Network”

• Can be directed or undirected

9

Page 10: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Motivation

• Trying to model behavior of people in (online) social networks

• Relationships between people in the network can be positive or negative

• People express opinion that can be positive or negative

10

Page 11: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Opinions of People in the Network

People can express opinion:• By action:– Pressing “Like”/“Dislike” button– Giving rating to a product/person

• By writing text:– Comments, review, etc

Applications:• Recommendation systems• Crowdsourcing

11

Page 12: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Types of Opinions

People can express opinion about:• Items:– Movies, hotels, purchases rating/reviews

• Other people:– GetTaxi drivers, AirBnB, Wikipedia

• Content generated by other people:– StackOverflow, Facebook

12

Page 13: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Evaluation

• Factors:– What drives people to give particular evaluation?

• Types: Direct/Indirect

13

Page 14: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Datasets

Where it exists on the Web?

• Wikipedia moderators elections– Positive/Neagtive vote (120K votes in English)

• StackOverflow Community– Upvotes/Downvotes (7.5M votes)

• Epinions product review– Ratings of product review (13M ratings)

– 5 – positive, 1-4 – negative

14

Page 15: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Evaluation – two ways to analyze

Two ways to look on it:

• Single evaluation (without network context)

• Evaluations in the context of the network

15From: Effects of User Similarity in Social Media. A. Anderson, D. Huttenlocher, J. Kleinberg, J. Leskovec (WSDM 2012)

Page 16: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Evaluation – without context

Two ways to look on it:

• Single evaluation (without network context)

• Evaluations in the context of the network

16

Page 17: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Human Evaluation

• What drives human evaluation?

• Which (and whose) properties are important?– Properties of A?

– Properties of B?

– Which properties?

17

Page 18: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Important Properties

• Status:– Level of recognition, achievements, reputation in

the community• Wikipedia: # of edits, # of new articles written

• StackOverflow: # of answers

• Similarity:– Overlapping interests between A and B

• Wikipedia: similarity of edited articles

• StackOverflow: similarity of users evaluated

18

Page 19: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Relative vs. Absolute evaluation

Two hypothesis:

• B receives a positive evaluation depends primarily on the characteristics of B– There is some objective criteria for user B to

receive a positive evaluation

• B receives a positive evaluation depends on relationship between the characteristics of A and B– A compares herself to B

19

Page 20: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Effect of Status

• How does status of B affects A’s evaluation?

• Status Δ = SA – S

B

• Observations:– P(+) doesn’t depends

on B’s status

– Different Δ implies

different behavior

20(Wikipedia dataset)

Page 21: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Effect of Similarity

Two hypothesis:• People are more supportive to other people in

their domain of knowledge/area– “The more similar you are, the more I like you”

• People know the domain, hence know the weak point and are more harsh– “The more similar you are, the better I can

understand your weaknesses”

21

Page 22: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Effect of Similarity

22

Page 23: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Similarity and Status

23

Page 24: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Summary so far

• Online Social Networks and Social Media websites support (sometimes implicitly) user evaluations (e.g. Wikipedia has transparent mechanism of elections)

• Two important characteristics:– Status: importance of relative assessments

– Similarity: importance of prior interactions

24More info: https://cs.stanford.edu/people/jure/talks/evals-recsys-sep12.pdf

Page 25: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Evaluation – with context

Two ways to look on it:

• Single evaluation (without network context)

• Evaluations in the context of the network

25

Page 26: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Networks with Signed Edges

• Also called: “Signed Network”

• Basic unit of investigation: Signed triangles

• Can be undirected or directed:

26

Page 27: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Signed Networks

• Network with positive or negative relationships

• Consider a complete signed undirected graph– Positive edges:

• Friendship, positive sentiment, …– Negative edges:

• Enemy, negative sentiment

• Let’s focus on three connected nodes A, B, C

27

Page 28: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Theory of Structural Balance

• Intuition (theory by Fritz Heider 1946): – Friend of a friend is a friend

– Enemy of an enemy is a friend

– Enemy of a friend is an enemy

• Let’s have a look on a triangle in a graph

28

Page 29: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Balanced/Unbalanced Triangles

29

Page 30: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Balanced/Unbalanced Triangles

30

Balanced Unbalanced

Page 31: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Balanced/Unbalanced Network

• Network is balanced if every triangle in the network is balanced.

• Balanced triangle – 1 or 3 “+” edges

31

Page 32: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Balanced/Unbalanced Network

• Network is balanced if every triangle in the network is balanced.

Unbalanced Balanced

32

+– +

– +

+

Page 33: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Balance and Coalitions

• If the network is balanced, then either:– All edges are positive, or

– We can split the network into two parts (L and R),• All edges inside R are positive

• All edges inside L are positive

• All edges between R and L are negative

33

Page 34: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Analysis of Balance: Coalitions

34

Page 35: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Example: International relations

Independence of Bangladesh from Pakistan in 1971

USA supported Pakistan. Why?

35

Page 36: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Example: International relations

36

Page 37: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Example: International relations

37

USSR is an enemy of China

Page 38: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Example: International relations

38

China is an enemy of India

Page 39: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Example: International relations

39

India is an enemy of Pakistan

Page 40: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Example: International relations

40

USA is a friend of China

Page 41: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Example: International relations

41

Derived: China is a friend of Pakistan

Page 42: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Example: International relations

42

Derived: China is vetoed of Bangaladesh

Page 43: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Example: International relations

43

Derived: USA supported Pakistan

Page 44: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Balance in General Network

• The (general) network is balanced if:– We can fill all missing edges to achieve balance

– We can divide the network into two coalitions

44

Page 45: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Check if Network is Balanced

• Graph is balanced if and only if it contains no cycle with an odd number of negative edges

• Find connected components on +edges – If we find a component of

nodes on +edges that contains a –edge

🡪 Unbalanced

• For each component create a super-node

• Connect components A and B if there is

a negative edge between the members

• Assign super-nodes to sides using BFS

45

Page 46: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Check if Network is Balanced

46

Page 47: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Check if Network is Balanced

47

Page 48: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Check if Network is Balanced

48

Page 49: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Check if Network is Balanced

• Using BFS – assign each node to a side

• Graph is unbalanced if any two connected super-nodes are assigned the same side

49

Page 50: Algorithms and Applications in Social Networksslavanov.com/teaching/sn1920b/Lesson3.pdf · Algorithms and Applications in Social Networks 2019/2020, Semester B Slava Novgorodov 1

Thank you!Questions?

50