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

10/14/2008

(c) Devika Subramanian, 2008

2

History of research 

Karinthy (1929) 

Hungarian novelist: “Chains” (5 degrees of separation)



Solomonoff and Rapoport (1951) 



Erdos and Renyi (1960) 



Theoretical biology: random graphs, phase transition in connectedness Pure mathematics: founders of random graph theory (giant components)

Milgram and Travers (1967): 

Sociology and Psychology: acquaintance network, six degrees of separaration

Leskovec 10/14/2008 

and Horvitz (2008) (c) Devika Subramanian, 2008

3

Models for small world? 

Erdos-Renyi model 

n nodes, each node has a probability p of being connected. k = average degree

10/14/2008

(c) Devika Subramanian, 2008

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 (c) Devika Subramanian, 2008

10/14/2008

5

Erdos-Renyi model

10/14/2008

(c) Devika Subramanian, 2008

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

10/14/2008

(c) Devika Subramanian, 2008

7

Power law 

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

10/14/2008

(c) Devika Subramanian, 2008

8

Degree distributions of real-world networks

10/14/2008

(c) Devika Subramanian, 2008

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/14/2008

(c) Devika Subramanian, 2008

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

10/14/2008

(c) Devika Subramanian, 2008

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.

10/14/2008

(c) Devika Subramanian, 2008

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. 10/14/2008 (c) Devika Subramanian, 2008 

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.

10/14/2008

(c) Devika Subramanian, 2008

15

Graph representations 0 1

2

3

0

1

2

3

4

0

0

1

0

1

0

1

1

0

1

1

0

2

0

1

0

1

1

3

1

1

1

0

0

4

0

0

1

0

0

4

10/14/2008

(c) Devika Subramanian, 2008

16

Graph representations 0 1

2

0

[1,3]

1

[0,2,3]

2

[1,3,4]

3

[0,1,2]

4

[2]

3 4

10/14/2008

(c) Devika Subramanian, 2008

17

Weighted graph representation 0

210 1 203

440

314 2

270

260 3

4

10/14/2008

0

1

2

3

0

0

210

0

440 0

1

210

0

203

314

2

0

203

0

260 270

3

440

314

260

0

0

4

0

0

270

0

0

(c) Devika Subramanian, 2008

4

0

18

Weighted graph representations 0

210 1 203

314

440

2 270

260

0

[(1,210),(3,440)]

1

[(0,210),(2,203),(3.314)]

2

[(1,203),(3,260),(4,270)]

3

[(0,440),(1,314),(2,260)]

4

[(2,270)]

3 4

10/14/2008

(c) Devika Subramanian, 2008

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.

10/14/2008

(c) Devika Subramanian, 2008

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) 10/14/2008 (c) Devika Subramanian, 2008

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

10/14/2008

instance

(c) Devika Subramanian, 2008

22

networkx graph class 



Constructor

https://networkx.lanl.gov/reference/ networkx/ 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

10/14/2008

(c) Devika Subramanian, 2008

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.

10/14/2008

(c) Devika Subramanian, 2008

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/ 10/14/2008

(c) Devika Subramanian, 2008

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()

10/14/2008

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

(c) Devika Subramanian, 2008

26

Dictionary of dictionaries 1

None

0

3

None

1

0

None

2

None

3

None

1

None

3

None

4

None

0 1

2 2

3 4 3

4

2

10/14/2008

None

(c) Devika Subramanian, 2008

0

None

1

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

10/14/2008

(c) Devika Subramanian, 2008

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()

10/14/2008

(c) Devika Subramanian, 2008

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

10/14/2008

(c) Devika Subramanian, 2008

30

Graph representations

Models for small world? ▫ Erdos-Renyi model. ▫ n nodes, each node has a probability p of ... Barabasi-Albert model. ▫ Graph not static, but grows with time.

550KB Sizes 0 Downloads 319 Views

Recommend Documents

Shotgun Version Representations v6
... flexible enough to handle clients who may use some but not all of ... Screening Room adds support for multiple ... on Versions even if a client doesn't use Tank.

Selecting different protein representations and ...
Apr 7, 2010 - selects the best type of protein representation in a data-driven manner, ..... lection seems similar to the well-known idea of feature selection in data mining ..... Figure 3: Analysis of relative protein representation importance on th

Compact Part-Based Image Representations - UChicago Stat
P(I |µ) where the global template µ(x) = γ(µ1(x),...,µK(x)) is a composition of part templates .... drawn from a symmetric Bernoulli distribution (w.p.. 1. 2. ). For a fair.

Designing Numerical Representations for Young Children
Institute of Education ... Digital technology presents opportunities to design novel forms of numerical ... children to explore the meaning behind these ideas or.

Highest weight representations of the Virasoro algebra
Oct 8, 2003 - Definition 2 (Antilinear anti-involution). An antilinear anti-involution ω on a com- plex algebra A is a map A → A such that ω(λx + µy) = λω(x) + ...

Knowledge Graph Identification
The web is a vast repository of knowledge, but automatically extracting that ... Early work on the problem of jointly identifying a best latent KB from a collec- ... limitations, and we build on and improve the model of Jiang et al. by including ....

Graph Theory.PDF
(c) Find the chromatic number of the Graph 4. given below. If the chromatic number is k, ... MMTE-001 3. Page 3 of 5. Main menu. Displaying Graph Theory.PDF.

Graph Algorithms
DOWNLOAD in @PDF Algorithms in C++ Part 5: Graph Algorithms: Graph Algorithms Pt.5 By #A#. Download EBOOK EPUB KINDLE. Book detail.

Robust Graph Mode Seeking by Graph Shift
ample, in World Wide Web, dense subgraphs might be communities or link spam; in telephone call graph, dense subgraphs might be groups of friends or families. In these situations, the graphs are usually very sparse in global, but have many dense subgr

Graph Coloring.pdf
Sign in. Loading… Whoops! There was a problem loading more pages. Retrying... Whoops! There was a problem previewing this document. Retrying.

Graph Theory Notes - CiteSeerX
To prove the minimality of the set MFIS(X), we will show that for any set N ..... Prove that for a non-empty regular bipartite graph the number of vertices in both.

Graph Theory Notes - CiteSeerX
Let us define A = {v1,...,vm} and B = V (G)−A. We split the sum m. ∑ i=1 di into two parts m. ∑ i=1 di = C + D, where C is the contribution of the edges with both ...

Graph Theory.pdf
Page. 1. /. 2. Loading… Page 1 of 2. Page 1 of 2. Page 2 of 2. Page 2 of 2. Main menu. Displaying Graph Theory.pdf. Page 1 of 2.

graph-contraction.pdf
... loading more pages. Retrying... graph-contraction.pdf. graph-contraction.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying graph-contraction.pdf.

Graph Theory.pdf
Define proper coloring and determine chromatic number of the graph given below. (02). b. State Hall's matching condition. (02). c. For the bipartite graph given ...

graph-search.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. graph-search.

Graph Algorithms
Read Algorithms in C++ Part 5: Graph Algorithms: Graph Algorithms Pt.5 - Online. Book detail. Title : Read Algorithms in C++ Part 5: Graph q. Algorithms: Graph ...

Mapping Interlingua Representations to Feature ...
The IF-to-Arabic FS mapper is implemented in SICStus Prolog. Examples of Arabic .... the source text, and the target lexical items. We differentiate between ...

WEIL REPRESENTATIONS Introduction This exposition ...
local field other than the complex numbers, then the Weil representation does not come from ... It is easy to see that the center Z(H) of of the Heisenberg group is .... G fitting into the following short exact sequence, which we call the fundamental

Representations of Orthogonal Polynomials
classical orthogonal polynomials if it is the solution of a di erence equation of the ... in the discrete case, in terms of the coe cients a; b; c; d and e of the given di ...

Invariant Representations for Content Based ... - Semantic Scholar
sustained development in content based image retrieval. We start with the .... Definition 1 (Receptive Field Measurement). ..... Network: computation in neural.

Designing Numerical Representations for Young Children
Institute of Education. 23-29 Emerald Street. London, UK. WC1N 3QS. +44 (0)20 7763 2137 [email protected]. ABSTRACT. Digital technology presents ...