02 GraphTheory
02 GraphTheory
OUTLINES
• Graph Theory & Metrics
• Basics
• Node degree
• Paths & distance
• Components
Introduction
Graphs: Nodes and Edges.
• A graph is a way of specifying relationships among a
collection of items.
• A graph consists of a set of objects, called nodes, with
certain pairs of these objects connected by links called
edges.
• We say that two nodes are neighbors if they are connected
by an edge.
• with little circles representing the nodes, and a line
connecting each pair of nodes that are linked by an edge.
GRAPH THEORY BASICS
o Graph,
o Node
o Edge
o Adjacency Matrix
o Directed, Undirected and Weighted graph
***CS7280 / www.networksciencebook.com
Undirected, directed, weighted
graphs
Graph adjacency matrix
http://sourcecodemania.com/wp-content/uploads/2012/06/adjacency-matrix-of-graph.jpg
Graph adjacency matrix
(cont’)
• Many network properties can be
formulated as properties of the
adjacency matrix
– See “algebraic graph theory”
• For instance:
– A directed network is acyclic if and only
if all eigenvalues of the adjacency
matrix are equal to 0
• Proof?
Review: Undirected/Directed
A A
E B E B
D C D C
E B I G
0.2 0.2
0.4 0.2 0.4 0.2
D C J H
NODE DEGREE
Review: Node Degree
• Dfn: The node degree is the
number of neighbors a node has.
|N(v)| deg=3
A
adjacency A B C D E D C
matrix value
A 0 1 0 0 1
k v av , u B 1
C 0
0
1
1
0
0
0
0
1
u V D 0 0 0 0 1
pick
row v E 1 0 1 1 0
Directed: In- & Out-Degree
A
• Out-degree: kv av ,u E B
u V
D C
• In-degree: kv au ,v
u V
column v, not row
A B C D E
A 0 1 0 0 1
B 0 0 0 0 0
C 0 1 0 0 1
D 0 0 0 0 0
E 0 0 0 1 0
Degree Distribution
E B
D C
More Degree Metrics
# edges
• Average node degree: k 2 E
~
V # vertices
~
• Connectance: k scale by
V-1 network size
E B
Paths? Cycles? D C
Review: Distance
• Dfn: The distance dv,u between 2 nodes
in a graph = length of the shortest path
linking the 2 nodes
• Note: Need to find shortest path!
E B
D C
How would you calculate the
average distance from a node?
Breadth-First Search (BFS)
• Explore first-neighbors
• Explore neighbors’ neighbors
• Keep track of:
– nodes to explore (queue)
A
– visited nodes (set)
E B
D C
Small-world Phenomenon
• For 2 random people: path
distance?
• Millgram 1967 & following:
– 296 “starters” forward a letter to a
person through friends
– 64 completed chains
“six degrees”
Reasonable, unproven
Distance-based Metrics
• The characteristic path length is
the average shortest path length
(average distance).
1 distance from v to u
L
V(V 1)
d
v ,u V ,v u
v ,u
COMPONENTS
Review: Connectedness
Not edge!
• Dfn: A graph (or subgraph) is
connected if there is a path between
each pair of nodes.
• If no path, this is disconnected.
Components
• Dfn: a connected component is a
subset S of nodes where:
1. Every node in S has a path to every
other
S comp {v S | u S , path (u , v)}
2. S is not part of a larger subset S’
where property #1 holds
Giant Components
• A giant component: “connected
component that contains a
significant fraction of all the nodes”
• Ex: Real-world
• Ex: Random graphs (Erdos-Renyi
model – more later)
INDIVIDUAL EXERCISE:
E B
D C