logo

Social Network Analysis: Functions for Friendships and Groups in Python

2 Pages711 Words128 Views
   

Added on  2019-09-18

About This Document

This text describes two representations of a social network: one as a set of pairs of friends, and the other as a dictionary where keys are names and values are sets of friends. It also lists several functions that can be implemented to analyze the network, such as finding the number of friends each person has, suggesting new friendships, checking if a group of people are all friends, finding the pair with the most mutual friends, checking if a group contains strangers, checking if a group covers the entire network, counting the number of triangles (triplets of people who know each other), and finding the smallest set of names that cover the network.

Social Network Analysis: Functions for Friendships and Groups in Python

   Added on 2019-09-18

ShareRelated Documents
pairs = {("Ana", "Berta"), ("Ana", "Greta"), ("Ana", "Helga"), ("Berta", "Cilka"), ("Berta", "Helga"), ("Cilka", "Dani"), ("Dani", "Ema"), ("Dani", "Greta"), ("Dani", "Helga"), ("Ema", "Fanči"), ("Ema", "Greta"), ("Ema", "Helga"), ("Fanči", "Iva"), ("Fanči", "Jana"), ("Fanči", "Klavdija"), ("Greta", "Helga")}For simplicity and efficiency, every pair is listed just once, in alphabetic order (e.g. ("Ana", "Berta") and not also ("Berta", "Ana").The other representation is a dictionary, where keys contain names and the corresponding values are sets of friends.network = {"Ana": {"Berta", "Greta", "Helga"}, "Berta": {"Ana", "Helga", "Cilka"}, "Cilka": {"Berta", "Dani"}, "Dani": {"Cilka", "Ema", "Greta", "Helga"}, "Ema": {"Dani", "Fanči", "Greta", "Helga"}, "Fanči": {"Ema", "Iva", "Jana", "Klavdija"}, "Greta": {"Ana", "Dani", "Ema", "Helga"}, "Helga": {"Ana", "Berta", "Dani", "Ema", "Greta"}, "Iva": {"Fanči"}, "Jana": {"Fanči"}, "Klavdija": {"Fanči"} }
Social Network Analysis: Functions for Friendships and Groups in Python_1

End of preview

Want to access all the pages? Upload your documents or become a member.