Professional Documents
Culture Documents
G RAPHS
Notation. G = (V, E)
・V = nodes (or vertices).
・E = edges (or arcs) between pairs of nodes.
・Captures pairwise relationship between objects.
・Graph size parameters: n = | V |, m = | E |.
V = { 1, 2, 3, 4, 5, 6, 7, 8 }
E = { 1–2, 1–3, 2–3, 2–4, 2–5, 3–5, 3–7, 3–8, 4–5, 5–6, 7–8 }
m = 11, n = 8
3
One week of Enron emails
4
The evolution of FCC lobbying coalitions
“The Evolution of FCC Lobbying Coalitions” by Pierre de Vries in JoSS Visualization Symposium 2010 5
key variable of interest was an alter’s obesity at t + 1 to the foregoing models. We also analyzed
time t + 1. A significant coefficient for this vari- the role of geographic distance between egos
Framingham heart study
able would suggest either that an alter’s weight
affected an ego’s weight or that an ego and an
and alters by adding such a variable.
We calculated 95% confidence intervals by sim-
alter experienced contemporaneous events affect- ulating the first difference in the alter’s contem-
Figure 1. Largest Connected Subcomponent of the Social Network in the Framingham Heart Study in the Year 2000.
Each circle (node) represents one person in the data set. There are 2200 persons in this subcomponent of the social
network. Circles with red borders denote women, and circles with blue borders denote men. The size of each circle
is proportional to the person’s body-mass index. The interior color of the circles indicates the person’s obesity status:
yellow denotes an obese person (body-mass index, ≥30) and green denotes a nonobese person. The colors of the
ties between the nodes indicate the relationship between them: purple denotes a friendship or marital tie and orange
denotes a familial tie.
“The Spread of Obesity in a Large Social Network over 32 Years” by Christakis and Fowler in New England Journal of Medicine, 2007 6
Some graph applications
7
Graph representation: adjacency matrix
1 2 3 4 5 6 7 8
1 0 1 1 0 0 0 0 0
2 1 0 1 1 1 0 0 0
3 1 1 0 0 1 0 1 1
4 0 1 0 0 1 0 0 0
5 0 1 1 1 0 1 0 0
6 0 0 0 0 1 0 0 0
7 0 0 1 0 0 0 0 1
8 0 0 1 0 0 0 1 0
8
Graph representation: adjacency lists
1 3 2
2 1 3 4 5
3 2 1 5 7 8
4 2 5
5 2 3 4 6
6 5
7 3 8
8 3 7
9
Paths and connectivity
10
Cycles
Def. A cycle is a path v1, v2, …, vk in which v1 = vk, k > 2, and the first k – 1
nodes are all distinct.
cycle C = 1-2-4-5-3-1
11
Trees
12
Rooted trees
Given a tree T, choose a root node r and orient each edge away from r.
root r
the parent of v
a child of v
13
Phylogeny trees
14
GUI containment hierarchy
http://java.sun.com/docs/books/tutorial/uiswing/overview/anatomy.html 15
3. G RAPHS
s-t connectivity problem. Given two nodes s and t, is there a path between
s and t ?
s-t shortest path problem. Given two nodes s and t, what is the length of
a shortest path between s and t ?
Applications.
・Friendster.
・Maze traversal.
・Kevin Bacon number.
・Fewest hops in a communication network.
17
Breadth-first search
s L1 L2 Ln–1
BFS algorithm.
・L0 = { s }.
・L1 = all neighbors of L0.
・L2 = all nodes that do not belong to L0 or L1, and that have an edge to a
node in L1.
・Li+1 = all nodes that do not belong to an earlier layer, and that have an
edge to a node in Li.
18
Breadth-first search
Property. Let T be a BFS tree of G = (V, E), and let (x, y) be an edge of G.
Then, the levels of x and y differ by at most 1.
L0
L1
L2
L3
19
Breadth-first search: analysis
Pf.
・Easy to prove O(n2) running time:
- at most n lists L[i]
- each node occurs on at most one list; for loop runs ≤ n times
- when we consider node u, there are ≤ n incident edges (u, v),
and we spend O(1) processing each edge
20
Connected component
21
Flood fill
Flood fill. Given lime green pixel in an image, change color of entire blob of
neighboring lime pixels to blue.
・Node: pixel.
・Edge: two neighboring lime pixels.
・Blob: connected component of lime pixels.
recolor lime green blob to blue
22
Flood fill
Flood fill. Given lime green pixel in an image, change color of entire blob of
neighboring lime pixels to blue.
・Node: pixel.
・Edge: two neighboring lime pixels.
・Blob: connected component of lime pixels.
recolor lime green blob to blue
23
Connected component
R
s
u v
24
3. G RAPHS
Applications.
・Stable matching: med-school residents = blue, hospitals = white.
・Scheduling: machines = blue, jobs = white.
a bipartite graph
26
Testing bipartiteness
v2
v2 v3
v1
v4
v6 v5 v4 v3
v5
v6
v7 v1
v7
27
An obstruction to bipartiteness
28
Bipartite graphs
Lemma. Let G be a connected graph, and let L0, …, Lk be the layers produced
by BFS starting at node s. Exactly one of the following holds.
(i) No edge of G joins two nodes of the same layer, and G is bipartite.
(ii) An edge of G joins two nodes of the same layer, and G contains an
odd-length cycle (and hence is not bipartite).
L1 L2 L3 L1 L2 L3
Lemma. Let G be a connected graph, and let L0, …, Lk be the layers produced
by BFS starting at node s. Exactly one of the following holds.
(i) No edge of G joins two nodes of the same layer, and G is bipartite.
(ii) An edge of G joins two nodes of the same layer, and G contains an
odd-length cycle (and hence is not bipartite).
Pf. (i)
・Suppose no edge joins two nodes in same layer.
・By BFS property, each edge joins two nodes in adjacent levels.
・Bipartition: white = nodes on odd levels, blue = nodes on even levels.
L1 L2 L3
Case (i)
30
Bipartite graphs
Lemma. Let G be a connected graph, and let L0, …, Lk be the layers produced
by BFS starting at node s. Exactly one of the following holds.
(i) No edge of G joins two nodes of the same layer, and G is bipartite.
(ii) An edge of G joins two nodes of the same layer, and G contains an
odd-length cycle (and hence is not bipartite).
Pf. (ii)
・Suppose (x, y) is an edge with x, y in same level Lj.
・Let z = lca(x, y) = lowest common ancestor. z = lca(x, y)
31
The only obstruction to bipartiteness
5-cycle C
32
3. G RAPHS
Ex. Web graph: hyperlink points from one web page to another.
・Orientation of edges is crucial.
・Modern web search engines exploit hyperlink structure to rank web
pages by importance.
34
World wide web
Web graph.
・Node: web page.
・Edge: hyperlink from one page to another (orientation is crucial).
・Modern search engines exploit hyperlink structure to rank web pages
by importance.
cnn.com
hbo.com
gameofthrones.com
35
Road network
To see all the details that are visible on the screen,use the
Address Holland Tunnel "Print" link next to the map.
New York, NY 10013
Node = intersection; edge = one-way street.
36
Political blogosphere graph
The Political Blogosphere and the 2004 U.S. Election: Divided They Blog, Adamic and Glance, 2005
Figure 1: Community structure of political blogs (expanded set), shown using utilizing a GEM
layout [11] in the GUESS[3] visualization and analysis tool. The colors reflect political orientation, 37
Ecological food web
Reference: http://www.twingroves.district96.k12.il.us/Wetlands/Salamander/SalGraphics/salfoodweb.giff
38
Some directed graph applications
Directed s–t shortest path problem. Given two nodes s and t,
what is the length of a shortest path from s to t ?
Web crawler. Start from web page s. Find all web pages linked from s,
either directly or indirectly.
40
Strong connectivity
Def. Nodes u and v are mutually reachable if there is both a path from u to v
and also a path from v to u.
ok if paths overlap
s u
41
Strong connectivity: algorithm
42
Strong components
SIAM J. COMPUT.
Vol. 1, No. 2, June 1972
v2 v3
v6 v5 v4 v1 v2 v3 v4 v5 v6 v7
v7 v1
45
Precedence constraints
Precedence constraints. Edge (vi, vj) means task vi must occur before vj.
Applications.
・Course prerequisite graph: course vi must be taken before vj.
・Compilation: module vi must be compiled before vj.
・Pipeline of computing jobs: output of job vi needed to determine input
of job vj.
46
Directed acyclic graphs
v1 vi vj vn
47
Directed acyclic graphs
48
Directed acyclic graphs
w x u v
49
Directed acyclic graphs
DAG
50
Topological sorting algorithm: running time
51