The document discusses networks and graph concepts. It provides examples of social networks and the internet. It defines nodes, edges, and how networks can be represented using adjacency lists and edge lists. It discusses computing properties of networks like degrees, connected components, distances, and performing breadth-first search.
16. Adjacency list edge list
(weighted) directed network
Input
Adjacency list
Output
Edge list
17. Adjacency list edge list
(weighted) directed network
Map
input: u {w1, …, wk}
foreach wi:
output (u, wi)
Reduce
pass
18. Edge list adjacency list
(weighted) undirected network
Input
Edge list
Output
Adjacency list
19. Edge list adjacency list
(weighted) undirected network
Map
input: (u, w)
output: (u, w), key := u
output: (w, u), key := w
Reduce
input: u, {w1, …, wk}
identity
20. 3
1 2
5
4
7
6
Degree of node u
# of edges incident on u
21. Edge list node degrees
undirected network
Input
Edge list
Output
Node degrees
22. Edge list node degrees
undirected network
Map
input: (u, w)
output: (u, w), key := u
output: (w, u), key := w
Reduce
input: u, {w1, …, wk}
output: u, k
23. Edge list degree distribution
undirected network
Input
Edge list
Output
Degree distribution
24. Edge list degree distribution
undirected network
Map
input: (u, w)
output: (u, w), key := u
output: (w, u), key := w
Reduce
input: u, {w1, …, wk}
output: u, k
25. Edge list degree distribution
undirected network
Map
input: u, k
identity, key := k
Reduce
input: k, {u1, …, um}
output: k, m
26. 3
1 2
5
4
7
6
Path
Sequence of nodes with each
consecutive pair connected by an edge
27. 3
1 2
5
4
7
6
Cycle
Path with at least three edges with first and last
nodes the same and all other nodes distinct
34. # initialize distances
dist = {}
for u in G:
dist[u] = NA
dist [u1] = 0
d=0
periphery = { u1 }
while len(periphery) > 0:
# find nodes one step away from the periphery
next_level = {}
for u in periphery:
next_level += { w for w in neighbors[u] if dist[w] == NA }
# update distances
d += 1
for u in next_level:
dist[u] = d
# update periphery
periphery = next_level
35. BFS @ scale
undirected network
Input
edge list, starting node u0
Output
Distance to all nodes from u0
36. BFS @ scale
undirected network
Input: distances (u, d)
1. join distances with edge list
2. foreach (u, d, w) output (w, d+1)
[ also output (u0, 0) ]
3. group by w, and output min d