3. Informally, a graph is a set of points and lines joining these
points
Definition: Graph G =(V, E) consists set of vertices denoted by
V, or by V(G) and set of edges E, or E(G)
Graphs present a key concept of discrete mathematics.
http://www.npr.org/2016/04/16/474396452/how-math-
determines-the-game-of-thrones-protagonist
4. Basic notation
• An edge between vertices u and v is denoted by {v1, v2}, or shortly v1v2.
• The vertices joined by an edge are adjacent or neighbors.
• The vertex set of a graph G is referred to as V(G), the edge set as E(G).
How can we describe a graph?
Either by listing the vertices and edges, or with a nice picture. . .
V={1,2,3,4}, E=n{1,2},{1,3},{3,4}
Which one do you like more?
1
3
2 4
5. Edge Type
Directed: Ordered pair of vertices. Represented as (v1, v2) directed
from vertex u to v.
Undirected: Unordered pair of vertices. Represented as {v1, v2}.
v1 v2
v1 v2
6. Edge Type
• Loop: A loop is an edge e of G whose endvertices are the
same vertex such as e6
v1
v5
v3
v2
v4
e1
e2
e4
e3
e5
e6
V2 and v3 are adjacent.
e2 is incident with v2.
7. Graph Type
Undirected Graph consists of V, a nonempty set of vertices, and E, a set
of unordered pairs of distinct elements of V called edges, G1
Directed Graph is set of vertices V, and set of Edges E, that are ordered
pair of elements of V , G2
G1(V, E), V = {v1, v2, v3}, E = {(v1, v2), (v2, v3), (v3, v1)}
G2(V, E), V = {v1, v2, v3}, E = {{v1, v3}, {v3, v2}, {v2, v1}}
v1 v3
v2
v1
v2
v3
8. Basic graph classes
• The cycle of length n Cn has n ≥ 3 vertices joined in a
cyclic fashion with n edges:
• The path of length n Pn has n + 1 vertices joined
consecutively with n edges:
C3 C4 C5
9. Basic graph classes
• The complete graph on n ≥ 1 vertices has n vertices, all pairs forming
edges:
• The complete bipartite graph on m ≥ 1 plus n ≥ 1 vertices has m + n
vertices in two parts, and the edges join all the m.n pairs coming from
different parts:
K2 K3
K2,3
K3,3
K4
10. Basic graph classes
• Wheels Wn, is a graph formed by connecting a new single vertex to all
vertices of a cycle ,Cn
• N-cubes Qn, is the graph whose vertices are the 2n binary string and
two vertices are adjacent iff the string differ in exactly one coordinate.
W3
W4
11. Vertex degrees in a graph
• The degree of a vertex v in a graph G, denoted by d (v), equals the number of
edges of G incident with v.
• For directed graph:
• In-degree (d- (v)) is number of edges for which u is terminal vertex
• out-degree (d+ (v)) is the number of edges for which v is initial vertex
• A graph is d-regular if all its vertices have the same degree d.
2
1
3
3
3
2
4
The degrees are written at the vertices
12. The degree sequence
The degree sequence ( the score) of a graph G is the collection of degrees
of the vertices of G, written in a sequence of natural numbers which is
(usually) sorted as non-decreasing or non-increasing.
Theorem (The Handshaking theorem):
Vv
ve )deg(2
13. Example of Handshaking Theorem
• Draw a graph with 4 edges and 4 vertices , having degrees 1,2,3,4.
Solution:
No such graph exists.
(1+2+3+4)/2 = 5, 5 =/= 4.
The sum of the degrees of all the vertices should be equal to twice the number of
edges. Half of the sum of the degrees is 5, which is not equal to four.
15. Subgraphs
• A subgraph of a graph G is any graph H on a subset of vertices V (H) ⊆ V
(G), such that the edges of H form a subset of the edges of G and have both
ends in V (H).
• We write H ⊆ G as for the set inclusion.
An induced subgraph is a subgraph H ⊆ G such that all edges of G between pairs
of vertices from V (H) are included in H.
v1
v2 v3
v3v1
v3v2 v2
H1
H2G
16. Graph Representation
• Adjacency Matrix: Most useful when information about the vertices
is more desirable than information about the edges.
• Incidence Matrix: Most useful when information about edges is more
desirable than information about vertices.
17. Adjacency Matrix
Binary n x n matrix, where n = # of vertices
A(i,j) = 1 iff (i,j) is an edge
V1
v1 v2 v3 v4 v5
v1
v2
v3
v4
v5
0 1 0 1 0
1 0 0 0 1
0 0 0 0 1
1 0 0 0 1
0 1 1 1 0
This makes it easier to find subgraphs, and to reverse graphs if
needed.
v2
v3
v4
v5
18. Adjacency Matrix
2
3
1
4
5
1 2 3 4 5
1
2
3
4
5
0 1 0 1 0
1 0 0 0 1
0 0 0 0 1
1 0 0 0 1
0 1 1 1 0
•Adjacency matrix of an undirected graph is symmetric.
A(i,j) = A(j,i) for all i and j.
No
Loop
19. Adjacency Matrix (Directed
graph)
2
3
1
4
5
1 2 3 4 5
1
2
3
4
5
0 0 0 1 0
1 0 0 0 1
0 0 0 0 0
0 0 0 0 1
0 1 1 0 0
•Adjacency matrix of a directed graph does not need to
be symmetric.
20. Adjacency Matrix properties
Adjacency is chosen on the ordering of vertices. Hence, there as are as
many as n! such matrices.
When there are relatively few edges in the graph the adjacency matrix
is a sparse matrix
24. Graph Morphisms
The two graphs below look different.
Are they from a graph theoretic point of view structurally the
‘same’?
d
c
b
a
3
5
2
1
e
4
25. Graph Morphisms
The two graphs below look different but are structurally the ‘same’.
d
c
b
a
3(e)
5(d)
2(c)
1(a)
e
4(b)
They are the ‘same’ up to the renaming of the vertices. These graphs are
isomorphic.
f.a
f.b
f.c
f.d
f.e
26. Graph Isomorphism
G1 = (V1, E2) and G2 = (V2, E2) are isomorphic if there is a one-to-one
and onto function f from V1 to V2 with the property that a and b are
adjacent in G1 if and only if f (a) and f (b) are adjacent in G2, for all a and
b in V1
Function f is called isomorphism
An isomorphism f “preserves edges” thus preserving properties of graphs
that depend on edges e.g. cycles and degrees are preserved.
27. Graph Isomorphism
Sometimes it is easy to check whether two graphs are not isomorphic.
The orange graph has two vertices of degree 3 while the blue graph has
none.
• It is much harder to prove that two graphs are isomorphic.
• The computation is time is O(cn) exponential wrt. the number of vertices .
31. v
b
cd
e
f
gh
s t
w x
z y
a
u
If the two graphs are isomorphic, then, a must correspond to either
t, u, x, or y.
t, u, x, y all have a neighbor with degree =2. Not true for a.
32. Are they isomorphic?
Why should we want to know whether two graphs are isomorphic?
What sort of problems can be solved?
34. Path
A Path is a sequence of edges that begins at a vertex of a graph and travels along edges
of the graph, always connecting pairs of adjacent vertices.
Path P from v1 to vn : {{v1, 1}, {1, 4}, {4, 5}, {5, vn}}
1
v1
3
4 5
2
vn
38. Example Of No Path
No path between 2 and 9.
2
3
8
101
4
5
9
11
6
7
39. v1 vn
path: no vertex can be repeated
a-b-c-d-e
trail: no edge can be repeat
a-b-c-d-e-b-d
walk: no restriction
a-b-d-a-b-c
closed if v1=vn
closed trail: circuit (a-b-c-d-b-e-d-a)
closed path: cycle (a-b-c-d-a)
a
b
c
d
e
length: number of edges in
this (path,trail,walk)
Basic Idea: In a Graph Reachability among vertices by
traversing the edges
40. Connectedness
An undirected graph is connected if there is a path between every
pair of vertices
• A directed graph is strongly connected if there is a path from a to b and
from b to a whenever a and b are vertices in the graph ( G1)
• A directed graph is weakly connected if there is a (undirected) path
between every two vertices in the underlying undirected path ( G2)
G2G1
43. Connected Component
• A maximal subgraph that is connected.
Cannot add vertices and edges from original graph
and retain connectedness.
• A connected graph has exactly 1 component.
48. The Seven Bridges of Königsberg, Germany
• The residents of Königsberg,
Germany, wondered if it was possible
to take a walking tour of the town
that crossed each of the seven bridges
over the Presel river exactly once. Is
it possible to start at some node and
take a walk that uses each edge
exactly once, and ends at the starting
node?
AA
R
L
D
49. R
A
L
D
A
R
A
L
D
What Euler realized was that most of the information on the maps had
no impact on the answers to the two questions.
By thinking of each bank and island as a vertex and each bridge
as an edge joining them Euler was able to model the situation
using the graph on the right.
50. The Seven Bridges of Königsberg, Germany
• Has no tour that uses each edge exactly once.
• (Even if we allow the walk to start and finish in different places.)
• Can you see why?
Euler:
51. Euler Cycle(EC)
• Graph G has EC if and only if every vertex of G has even degree.
– Necessary Condition If G has EC, then every vertex of G has
even degree.
– Sufficient Condition If every vertex of G has even degree, then G
has EC.
• A connected graph G is has an Euler trail from node a to some other
node b if and only if G is connected and a≠b are the only two nodes of
odd degree
53. Trees
A tree is a loop-free connected graph that contains no cycles.
Each pair of vertices of a tree is connected by a unique simple
path.
A tree with at least two vertices has at least two vertices of
degree 1.
For every tree <V,E>, #V = 1 + #E.
A Tree Not a tree
54. Trees alternative definitions :
Let G=<V,E> be a loop free graph, then the following are equivalent
statements:
G is a tree
G is connected and the removal of any edge yields two trees
G contains no cycles and #V = 1 + #E
G is connected and #V = 1 + #E
G has no cycles and adding one edge introduces one cycle
55. Trees properties:
Any connected subgraph is a tree.
There is a unique simple path between every pair of vertices.
If it has at least two vertices, then it has at least two leaves.
The number of vertices is one larger than the number of edges.
Adding an edge between two vertices creates a cycle.
Removing any edge disconnects the graph.
56. A spanning tree of a graph contains the minimum
number of edges to keep the graph connected.
Spanning Tree is the subgraph that includes all vertices of the original
graph and subgraph is a tree.
If original graph has n vertices, the spanning tree has n vertices and n-1
edges.
Spanning Tree
Spanning tree Original graph Spanning tree
57. A spanning tree of a graph contains the minimum number of edges to keep the
graph connected.
An algorithm used to construct a spanning tree is non-deterministic in two ways:
1. the choice of vertex u is arbitrary
2. the choice of the edge incident on u to add to the tree is arbitrary
Spanning Tree
62. How to characterize a large network?
Large graph comparison is computationally hard due to NP-completeness of
the underlying subgraph isomorphism problem. Thus, graph comparisons rely
on easily computable heuristics (approximate solutions), called “graph
properties”.
Graph properties will give an overall view of the network, but might not be
detailed enough to capture complex topological characteristics of large
networks
62
63. Properties of graphs
Degree distribution
Average clustering coefficient
Average Diameter
Shortest path lengths
Centralities
Graph Spectra
Network Motif
63
64. Degree Distribution
• Degree of a node is the number of edges incident to the node.
• Average degree of a network: average of the degrees over all nodes in
the network. However, it might not be representative, since the
distribution of degrees might be skewed.
• Degree distribution: Let P(k) be the percentage of nodes of degree k
in the network. The degree distribution is the distribution of P(k) over
all k.
64
65. Degree Distribution
However degree distribution are weak predictors of network structure.
G1 and G2 are of the same size and same degree distribution, but G1 and G2
have very different topologies (graph structure).
65
G1
G2
66. Average Clustering Coefficient
The clustering coefficient of a node is the number of actual connections across the neighbors
of a particular node, as a percentage of possible connections.
Formally Clustering coefficient Cv of a node v:
Cv = |E(N(v))|/(max possible number of edges in N(v)) Where N(v) the neighborhood of v,
i.e., all nodes adjacent to v
By definition for vertex v of degree 0 or 1, Cv=0.
The clustering coefficient for the entire system is Average of clustering coefficient of all
nodes in network.
Cv can be viewed as the probability that two neighbors of v are connected. Thus 0 ≤ Cv ≤ 1.
66
67. A Very Simple Example
V1 V2 V3 V4
V1 1 0 1
V2 1 1 0
V3 0 1 0
V4 1 0 0
The possible number of connections in
this matrix is 6.
The clustering coefficient for V1 and
V2 is 2/3 .
Node V3 and V4 each have a clustering
coefficient of 1/3.
The average of those four clustering
coefficients is 0.5.
68. Average Diameter
The distance between two nodes is the smallest number of links that
have to be traversed to get from one node to the other.
The shortest path is the path that achieves that distance.
The average network diameter is the average of shortest path lengths
over all pairs of nodes in a network.
68
70. Node Centralities
Centrality quantifies the topological importance of a node (edge) in a network.
Three standard centrality measures capture a wide range of “importance” in a
network:
Degree
Closeness
Betweenness
71. Degree centrality
The most intuitive notion of centrality focuses on degree:
Degree centrality, Cd(v): nodes with a large number of neighbors
(i.e., edges) have high centrality. Therefore, we have Cd(v)=deg(v).
Degree centrality, however, can be deceiving, because it is a purely
local measure.
71
72. Closeness centrality
A second measure of centrality is closeness centrality. A node is
considered important if it is relatively close to all other nodes.
Closeness centrality, Cc(v): nodes with short paths to all other nodes in
the network have high closeness centrality
Cc(v)=
Closeness is based on the inverse of the distance of each node to every
other node in the network.
1
dist(u,v)
uV
73. Betweenness centrality
• Model based on communication flow: A person who lies on communication paths
can control communication flow, and is thus important. Betweenness centrality
counts the number of shortest paths between i and k that node j resides on.
Betweenness centrality Cb(v): Nodes (or edges) which occur in many of the shortest
paths have high betweeness centrality.
Cb(v)=
σst = the number of shortest paths from s to t (they may or not pass through node v)
σst(v) = the number of shortest paths from s to t that pass through v.
The above summation means that there is a sum on the top and on the bottom of the fraction.
st(v)
stst
sv
vt
74. Simple Example
74
Degree Closeness Betweeness
From highest D F, G H
F, G D, H F, G
to A, B A, B I
C, E, H C, E D
lowest I I A, B
J J C, D, J
75. A is the Adjacency Matrix
V1 V2 V3 V4
is eigenvalue of A and v is its eigenvector if
Graph Spectrum
76. Graph Spectrum
• Graph Laplacian
The smallest eigenvalue of L is 0, the corresponding eigenvector is
the constant one vector .
L has n non-negative, real-valued eigenvalues
Spectrum of the graph is the set of graph eigenvalues of the
adjacency matrix or the eigenvalues of the Laplacian matrix of a
graph.
76
77. Cospectral Graphs
Two graphs are called cospectral if the adjacency matrices of the graphs
have equal multisets of eigenvalues.
Cospectral graphs need not be isomorphic, but isomorphic graphs are
always cospectral
78. 13 3-node circuits
Networks Motifs
rand
randreal NN
Z
Find n-node subgraphs in real graph.
Find all n-node subgraphs in a set of
randomized graphs with the same
distribution of incoming and outgoing
arrows.
Assign Z-score for each subgraph.
Subgraphs with high Z-scores are
denoted as Network Motifs.
79. Network Motifs
A network motif is a small over-represented partial subgraph of real
network. Here, over-represented means that it is over-represented when
compared to networks coming from a random graph model.
Problem: What is expected at random, i.e., which network “null model” to
use to identify motifs?
79
81. What is a network model?
• Informally, a network model is a process (randomized or deterministic)
for generating a graph
• Models of static graphs
– input: a set of parameters Π, and the size of the graph n
– output: a graph G(Π,n)
• Models of evolving graphs
– input: a set of parameters Π, and an initial graph G0
– output: a graph Gt for each time t
82. Families of random graphs
A deterministic model D defines a single graph for each value of n (or t)
A randomized model R defines a probability space ‹Gn,P› where Gn is the
set of all graphs of size n, and P a probability distribution over the set Gn
(similarly for t)
we call this a family of random graphs R, or a random graph R
83. Erdös-Renyi Random Graphs
• The Gn,p model
– input: the number of vertices n, and a parameter p, 0 ≤ p ≤ 1
– process: for each pair (i,j), generate the edge (i,j) independently
with probability p
• Related, but not identical: The Gn,m model
– process: select m edges uniformly at random
84. Random graphs degree distributions
• The degree distribution follows a binomial
• Assuming z=np is fixed, as n→∞, B(n,k,p) is approximated by a
Poisson distribution
• Highly concentrated around the mean, with a tail that drops
exponentially
• There will be no regions in the network that have large density of
edges. Why?
knk
p1p
k
n
p)k;B(n;p(k)
z
k
e
k!
z
z)P(k;p(k)
85. Random graphs and real life
• A beautiful and elegant theory studied exhaustively
• Random graphs had been used as idealized network
models
• Unfortunately, they don’t capture reality…
86. Real life Networks
Connectivity follows power-law: P(k) ~ kγ , γ = 2.1…4
very low connection numbers are possible
Actor collaboration
N=212e3, <k>=29, γ=2.3
WWW
N=325e3, <k>=5.5, γ=2.1
Power grid
N=5e3, <k>=2.7, γ=4
87. Departing from the Random Graph
model
We need models that better capture the characteristics of
real graphs
degree sequences
clustering coefficient
short paths
88. Each node is connected to at least one other; most are connected
to only one, while a few are connected to many.
This degree distribution is approximately a power-law
distribution.
The scale-free model focuses on the distance-reducing capacity
of high-degree nodes, as ‘hubs’ create shortcuts that carry
network flow.
Scale Free Networks
Failure : removal of random node
Attack : removal of highly-connected node
Robustness to random failure & Susceptibility to deliberate attack
89. How can we generate data with
power-law degree distributions?
90. Preferential Attachment in Networks
• First considered by Price in 1965 as a model for
citation networks
– each new paper is generated with m citations
(mean)
– new papers cite previous papers with probability
proportional to their indegree (citations)
– what about papers without any citations?
• each paper is considered to have a “default”
citation
• probability of citing a paper with degree k,
proportional to k+1
• Power law with exponent α = 2+1/m
91. Barabasi-Albert model
• The BA model (undirected graph)
– input: some initial subgraph G0, and m the number of edges per
new node
– the process:
• nodes arrive one at the time
• each node connects to m other nodes selecting them with
probability proportional to their degree
• if [d1,…,dt] is the degree sequence at time t, the node t+1 links
to node i with probability
• Results in power-law with exponent α = 3
2mt
d
d
d i
i i
i
92. BA Model
• Produces scale-free networks
– Scale-free distribution – time-invariant. Stays the same as more
nodes added
• Removal of either assumptions destroys scale-free property:
– Without node addition with time → fully connected network after
enough time
– Without preferential attachment → exponential connectivity
93. ER Vs. BA
• Graph diameter:
– the average length of shortest distance between any two vertices
• For same number of connections and nodes, ER has larger diameter
than scale-free networks
– No small-world in ER!
94. Small world Phenomena
• So far we focused on obtaining graphs with power-law distributions on
the degrees. What about other properties?
– Clustering coefficient: real-life networks tend to have high
clustering coefficient
– Short paths: real-life networks are “small worlds”
• this property is easy to generate
– Can we combine these two properties?
95. Small World Graphs
Based on Milgram’s (1967) famous work, the
substantive point is that networks are structured
such that even when most of our connections
are local, any pair of people can be connected
by a fairly small number of relational steps.
Works on 2 parameters:
1) The Clustering Coefficient (c)
2) The average distance (L)
96. Small-world Graphs
• According to Watts :
– Large networks (n >> 1)
– Sparse connectivity (avg degree z << n)
– No central node (kmax << n)
– Large clustering coefficient (larger than in random graphs of same
size)
– Short average paths (~log n, close to those of random graphs of the
same size)
97. Algorithm
• Start with a ring
• For i = 1 … n
– Select a vertex j with probability proportional to Rij and
generate an edge (i,j)
• Repeat until z edges are added to each vertex
Rij : Inspired by the work of Solmonoff and Rapoport
nodes that share neighbors should have higher probability to be connected
98. Mixing order with randomness
Resulting graph has properties, both of
regular and random graphs
High clustering and short path length
High probability that a node’s contacts
are connected to each other.
Small average distance between nodes
FreeNet has been shown to result in small
world graphs
98
small world graphs
99. 99
Comparing 3 models
Topology Average Path
Length (L)
Clustering
Coefficient (CC)
Degree Distribution
(P(k))
ER Graph Poisson Dist.:
Small World Lsw Lrand CCsw CCrand
Similar to random
graph
Scale-Free network LSF Lrand Power-law
Distribution:
P(k) ~ k-
k
N
Lrand
ln
ln
~
N
k
CCrand
!
)(
k
k
ekP
k
k
k : Average degree
101. Networks are found in biological systems of varying scales:
1. Evolutionary tree of life
2. Ecological networks
3. Expression networks
4. Regulatory networks
- genetic control networks of organisms
5. The protein interaction network in cells
6. The metabolic network in cells
… more biological networks
BIOLOGICAL NETWORK
102. Biological networks
In biological systems nodes and edges can represent different things
Node
Protein, peptide, or non-protein biomolecules.
Edges
Biological relationships, etc., interactions, regulations, reactions,
transformations, activation, inhibitions.
Can construct bipartite or tripartite networks:
e.g. genes and proteins
103. Biological Networks Properties
Power law degree distribution: Rich get richer
Small World: A small average path length
Mean shortest node-to-node path
Robustness: Resilient and have strong resistance to failure on random
attacks and vulnerable to targeted attacks
Hierarchical Modularity: A large clustering coefficient
How many of a node’s neighbors are connected to each other
central nodes : in biological networks, more central nodes cannot be done
without
104. Protein Interaction Network
The protein interaction network seems to reveal
some basic graph theoretic properties:
The frequency of proteins having interactions
with exactly k other proteins follows a power
law.
The network exhibits the small world
phenomena: can reach any node within small
number of hops, usually 4 or 5 hops
Robustness: Resilient and have strong
resistance to failure on random attacks and
vulnerable to targeted attacks.
105. Community discovery
• Biological networks are modular
– Metabolic pathways
– Protein complexes
– Transcriptional regulatory modules
• Provide a high-level overview of the networks
• Predict gene functions based on communities
110. Network complexity
Structural complexity: topology
Network evolution: change over time
Connection diversity: links can have directions, weights, or signs
Dynamical complexity: nodes can be complex nonlinear dynamical
systems
Node diversity: different kinds of nodes