Graph theoretic concepts. Devika Subramanian Comp 140 Fall 2008

Similar documents
Complex networks Phys 682 / CIS 629: Computational Methods for Nonlinear Systems

Case Studies in Complex Networks

Lesson 4. Random graphs. Sergio Barbarossa. UPC - Barcelona - July 2008

- relationships (edges) among entities (nodes) - technology: Internet, World Wide Web - biology: genomics, gene expression, proteinprotein

Objects. say something to express one's disapproval of or disagreement with something.

CSCI5070 Advanced Topics in Social Computing

CS249: SPECIAL TOPICS MINING INFORMATION/SOCIAL NETWORKS

(Social) Networks Analysis III. Prof. Dr. Daning Hu Department of Informatics University of Zurich

Models of Network Formation. Networked Life NETS 112 Fall 2017 Prof. Michael Kearns

Chapter 1. Social Media and Social Computing. October 2012 Youn-Hee Han

Complex Networks. Structure and Dynamics

CAIM: Cerca i Anàlisi d Informació Massiva

RANDOM-REAL NETWORKS

Network Mathematics - Why is it a Small World? Oskar Sandberg

Social, Information, and Routing Networks: Models, Algorithms, and Strategic Behavior

Erdős-Rényi Model for network formation

Graph-theoretic Properties of Networks

1 Random Graph Models for Networks

Decentralized Search

Networks and Discrete Mathematics

Machine Learning and Modeling for Social Networks

A Generating Function Approach to Analyze Random Graphs

Signal Processing for Big Data

Response Network Emerging from Simple Perturbation

Extracting Information from Complex Networks

How Do Real Networks Look? Networked Life NETS 112 Fall 2014 Prof. Michael Kearns

CS224W: Analysis of Networks Jure Leskovec, Stanford University

GUENIN CARLUT Avel - TD2 Complex Networks

M.E.J. Newman: Models of the Small World

Introduction to Networks and Business Intelligence

The Establishment Game. Motivation

Graph Model Selection using Maximum Likelihood

Properties of Biological Networks

Breadth-First. Graphs in Python

CS-E5740. Complex Networks. Scale-free networks

Constructing a G(N, p) Network

Data Abstraction. UW CSE 160 Spring 2015

Constructing a G(N, p) Network

Data Abstraction. UW CSE 140 Winter 2013

Exercise set #2 (29 pts)

CSC148 Recipe for Designing Classes

Analysis of Large-Scale Networks: NetworkX

MAE 298, Lecture 9 April 30, Web search and decentralized search on small-worlds

ECS 253 / MAE 253, Lecture 8 April 21, Web search and decentralized search on small-world networks

Introduction. We've seen Python useful for. This lecture discusses Object Oriented Programming. Simple scripts Module design

An Exploratory Journey Into Network Analysis A Gentle Introduction to Network Science and Graph Visualization

Random Generation of the Social Network with Several Communities

Summary: What We Have Learned So Far

GUENIN CARLUT Avel - TD3 Complex Networks

UNIVERSITA DEGLI STUDI DI CATANIA FACOLTA DI INGEGNERIA

Graph Theory Review. January 30, Network Science Analytics Graph Theory Review 1

Distances in power-law random graphs

Overlay (and P2P) Networks

Math 443/543 Graph Theory Notes 10: Small world phenomenon and decentralized search

An Evolving Network Model With Local-World Structure

Graph Mining and Social Network Analysis

Algorithms and Applications in Social Networks. 2017/2018, Semester B Slava Novgorodov

MIDTERM EXAMINATION Networked Life (NETS 112) November 21, 2013 Prof. Michael Kearns

Basics of Network Analysis

CSE 255 Lecture 13. Data Mining and Predictive Analytics. Triadic closure; strong & weak ties

CSE 158 Lecture 13. Web Mining and Recommender Systems. Triadic closure; strong & weak ties

CSE 258 Lecture 12. Web Mining and Recommender Systems. Social networks

Introduction to network metrics

CSE 158 Lecture 11. Web Mining and Recommender Systems. Triadic closure; strong & weak ties

COMP6237 Data Mining and Networks. Markus Brede. Lecture slides available here:

Section 2.7 BIPARTITE NETWORKS

CSE 158 Lecture 11. Web Mining and Recommender Systems. Social networks

Online Social Networks 2

Distribution-Free Models of Social and Information Networks

Graph Types. Peter M. Kogge. Graphs Types. Types of Graphs. Graphs: Sets (V,E) where E= {(u,v)}

Example for calculation of clustering coefficient Node N 1 has 8 neighbors (red arrows) There are 12 connectivities among neighbors (blue arrows)

CS224W: Social and Information Network Analysis Jure Leskovec, Stanford University

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

Web 2.0 Social Data Analysis

Critical Phenomena in Complex Networks

Internet as a Complex Network. Guanrong Chen City University of Hong Kong

6.207/14.15: Networks Lecture 5: Generalized Random Graphs and Small-World Model

Graphs and their representations. EECS 214, Fall 2018

Advanced Algorithms and Models for Computational Biology -- a machine learning approach

NetworkX. Exploring network structure, dynamics, and function. Aric Hagberg 1 Daniel Schult 2 Pieter Swart 1. 5 March 2009

Data Structures (list, dictionary, tuples, sets, strings)

NetworkXBasics. March 31, 2017

V 2 Clusters, Dijkstra, and Graph Layout

Graph Theory. Graph Theory. COURSE: Introduction to Biological Networks. Euler s Solution LECTURE 1: INTRODUCTION TO NETWORKS.

Rumour spreading in the spatial preferential attachment model

The Mathematical Description of Networks

Higher order clustering coecients in Barabasi Albert networks

CS224W: Analysis of Network Jure Leskovec, Stanford University

Epidemic spreading on networks

Topic II: Graph Mining

Resilient Networking. Thorsten Strufe. Module 3: Graph Analysis. Disclaimer. Dresden, SS 15

User Defined Types. Babes-Bolyai University Lecture 06. Lect Phd. Arthur Molnar. User defined types. Python scope and namespace

The Structure of Information Networks. Jon Kleinberg. Cornell University

Random graphs and complex networks

Object Oriented Programming in Python. Richard P. Muller Materials and Process Simulations Center California Institute of Technology June 1, 2000

An introduction to the physics of complex networks

Intro to Random Graphs and Exponential Random Graph Models

The application of network theory in official statistics

Ma/CS 6b Class 10: Ramsey Theory

1 More configuration model

Transcription:

Graph theoretic concepts Devika Subramanian Comp 140 Fall 2008

The small world phenomenon The phenomenon is surprising because Size of graph is very large (> 6 billion for the planet). Graph is sparse in the sense that each person is connected to at most k other people (k about a 1000). Graph is decentralized; there is no dominant central vertex to which other vertices are directly connected. Graph is highly clustered, in that most friendship circles are strongly overlapping 2

History of research Karinthy (1929) Hungarian novelist: Chains (5 degrees of separation) Solomonoff and Rapoport (1951) Theoretical biology: random graphs, phase transition in connectedness Erdos and Renyi (1960) Pure mathematics: founders of random graph theory (giant components) Milgram and Travers (1967): Sociology and Psychology: acquaintance network, six degrees of separaration Leskovec and Horvitz (2008) 3

Models for small world? Erdos-Renyi model n nodes, each node has a probability p of being connected. k = average degree 4

Erdos-Renyi model Average degree k < 1 in ER(n,p) graph Small, isolated clusters Small diameters Average degree k = 1 in ER(n,p) graph A giant component appears Diameter peaks Average degree k > 1 in ER(n,p) graph Almost all nodes connected Diameter shrinks 5

Erdos-Renyi model 6

Giant component property In many real-world networks, we see Small diameter Few connected components: often just one giant component that emerges at a threshold probability Tipping points of Malcolm Gladwell Degree distribution follows a power law 7

Power law Power law: y = f(x) = x^{-a} 8

Degree distributions of real-world networks 9

Barabasi-Albert model Graph not static, but grows with time. Preferential attachment: The probability that a new vertex will be connected to vertex i depends proportionally on its degree ki over the sum of all degrees in the graph 10

BA graph generation Start with a small fully connected graph Add vertex one by one, attaching m edges from new vertex to other vertices probabilistically in proportion to number of edges that vertex already has 11

Properties of BA model Small diameters Threshold phenomena Degree distribution follows power law Explains formation of many graphs in the real world: WWW, collaboration networks, power networks, protein networks, citation networks, etc. networkx has a barabasi_albert() function to generate such graphs. 12

Graph representations Devika Subramanian Comp 140 Fall 2008

Adjacency matrix representation For a graph with n vertices, represent edges by n x n array If there is an edge between vertex i and vertex j, position (i,j) in array is a 1, otherwise it is a 0. Can extend this representation to weighted graphs by replacing 1s and 0s by other numbers. 14

Adjacency list representation For each vertex in a graph, associate a list of adjacent vertices. For weighted graphs, associate a list of tuples (vertex,weight) representing adjacent vertices and their edge weights/costs. 15

Graph representations 0 0 1 2 3 4 1 0 0 1 0 1 0 1 1 0 1 1 0 2 2 0 1 0 1 1 4 3 3 1 1 1 0 0 4 0 0 1 0 0 16

Graph representations 0 0 [1,3] 1 2 1 2 3 4 [0,2,3] [1,3,4] [0,1,2] [2] 4 3 17

Weighted graph representation 210 0 0 1 2 3 4 1 0 0 210 0 440 0 203 314 440 1 210 0 203 314 0 2 2 0 203 0 260 270 270 4 260 3 3 440 314 260 0 0 4 0 0 270 0 0 18

Weighted graph representations 210 0 0 [(1,210),(3,440)] 1 203 314 440 2 1 2 3 [(0,210),(2,203),(3.314)] [(1,203),(3,260),(4,270)] [(0,440),(1,314),(2,260)] 270 4 260 3 4 [(2,270)] 19

networkx graph representation Graphs packaged as objects An object is some data together with a set of methods for accessing and manipulating the data. Noun-oriented programming (Guzdial), ask, don t touch philosophy(kay) An abstraction that hides implementation details and exposes a clean interface to you. 20

networkx Interface import networkx as nx G = nx.graph() G is an instance of a Graph for i in range(10): G.add_edge(i,i+1) nx.diameter(g) nx.connected_component_subgraphs(g) G = nx.binomial_graph(100,0.05) 21

Python classes A class is a blueprint for an object Defines how to create an object Defines the interface to interact with the object class instance 22

networkx graph class https://networkx.lanl.gov/reference/ networkx/ Constructor Class Graph(object): def init (self,data=none,name= ): self.adj={} if data is not None: convert.from_whatever(data.create_using=self) self.name=name def nodes(self): return self.adj.keys() Accessor self refers to the object itself 23

Graph class Defines variables adj and name which are local to the graph object Instead of passing adjacency lists, node lists, we encapsulate the data in an object and pass the object; much cleaner! Can change underlying representation of graph object, without having package users change their code. 24

networkx graph constructor def init (self,data=none,name= ): self.adj = {} if data is not None: convert.from_whatever(data.create_using=self) self.name = name https://networkx.lanl.gov/reference/networkx/ 25

networkx graph representation def add_node(self,n): if n not in self.adj: self.adj[n] = {} def nodes(self): return self.adj.keys() def neighbors(self,n): return self.adj[n].keys() def add_edge(self,u,v=none): if v is None: (u,v) = u if u not in self.adj: self.adj[u] = {} if v not in self.adj: self.adj[v] = {} if u == v: return self.adj[u][v] = None self.adj[v][u] = None 26

Dictionary of dictionaries 0 0 1 3 None None 1 2 1 2 3 0 2 3 1 None None None None 4 3 None 4 3 2 4 None None 0 1 None None 2 None 27

Special graphs: digraphs https://networkx.lanl.gov/reference/ networkx/ Inheritance Basic functions are inherited New methods specific to digraphs are added Some functions are over-ridden. Advantage: code reuse 28

Public and private data G = nx.graph() G.adj can be set to anything we like Convention: anything with two leading underscores is private. Encapsulation or data hiding, so people access data via functions, rather than directly manipulate the internal structures. G.add_node() G.add_edge() G.nodes() G.edges() 29

Advantages of encapsulation By defining a specific interface you can keep other modules from doing anything incorrect to your data By limiting the functions you are going to support, you leave yourself free to change the internal data without messing up your users Makes code more modular, since you can change large parts of your classes without affecting other parts of the program, so long as they only use your public functions 30