2010-03-29 851-0585-04L – Modelling and Simulating Social Systems with MATLAB Lesson 6 – Graphs...
-
Upload
doreen-booth -
Category
Documents
-
view
218 -
download
3
Transcript of 2010-03-29 851-0585-04L – Modelling and Simulating Social Systems with MATLAB Lesson 6 – Graphs...
2010-03-29
851-0585-04L – Modelling and Simulating Social Systems with MATLAB
Lesson 6 – Graphs (Networks)
Anders Johansson and Wenjian Yu
(with S. Lozano and S. Wehrli)
© ETH Zürich |
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 2
Lesson 6 – Contents
History: Seven Bridges of Königsberg
Definition of graph
Properties of graphs
Examples of graphs
MATLAB implementation of graphs
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 3
Space
There are different ways to model the space in
which social interaction takes place, e.g.:
No space, e.g. Dynamical Systems
Discrete space, e.g. Cellular Automata
Continuous space (Next week)
Graphs
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 4
Seven Bridges of Königsberg
Graph Theory was born in 1736, when Euler
posted the following problem: Is it possible to
have a walk in the city of Königsberg, that
crosses each of the seven bridges only once?
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 5
Seven Bridges of Königsberg (II)
In order to approach the problem, Euler
represented the important information as a
graph:
Source: wikipedia.org
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 6
Definition of GraphA graph (sometimes called: Network) consists of two entities:
Node N (or: vertex)
Link L: Edge: Undirected link Arc: Directed link
The graph is defined as
G = (N, L)
Source: Batagelj
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 7
Properties of Links and Nodes
A link can either be a Boolean property (connection vs. no connection), or encoded as a strength (distance, traveling time, etc.)
A node can also contain information.
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 8
Properties of Graphs
A node can be characterized by: Degree k: Number of connections. Importance: Degree, Betweenness centrality (number
of paths through the node), Closeness, Eigenvector centrality (e.g. PageRank).
A graph can be characterized by: Degree distribution P(k): Fraction of nodes with k
connections. Diameter: The longest of the shortest paths between
all nodes in the graph.
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 9
Degree Distribution
Graphs can be classified by their topology, by
measuring the degree-distribution function P(k),
of the number of connections k per node: Random graph: P(k) = binomial distribution Scale-free graph: P(k) = k-γ
Source: www.computerworld.com
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 10
The Small World Experiment
Graphs are useful for modeling social networks,
disease spreading, transportation, and so on …
One of the most famous graph studies is the Small
World Experiment (S. Milgram), which shows that
the minimum
distance between any two
persons in the world is
almost never longer than
through 5 friends.
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 11
Oracle of Bacon
There is a web page http://oracleofbacon.org/
finding the path from any
actor at any time to the
Hollywood actor Kevin
Bacon.
It can also be used
to find the shortest path
between any two actors.
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 12
MATLAB Implementation
A graph can be implemented in MATLAB via its
adjacency matrix, i.e. an N x N matrix, defining
how N nodes are connected to the other N-1
nodes:
N = 10;
A = zeros(N, N);
A(1,2) = 1;
A(10,4) = 1;
…
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 13
Graphs
If the nodes are cities and the links define
connections and travel times for the SBB
network it looks like this:
1
3
2
4
Geneva
Basel
Bern
Zurich
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 14
Graphs
If the nodes are cities and the links define connections
and travel times for the SBB network it looks like this:
A = [0 1 1 0; 1 0 1 0; 1 1 0 1; 0 0 1 0];
1
3
2
4
Geneva
Basel
0 1 1 0
1 0 1 0
1 1 0 1
0 0 1 0
A =
Bern
Zurich
1 2 3 4
1
2
3
4
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 15
Graphs
If the nodes are cities and the links define
connections and travel times for the SBB
network it looks like this:
1
3
2
4
Geneva
Bern
Basel
Zurich0:57
0:540:55
1:41
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 16
Graphs
If the nodes are cities and the links define
connections and travel times for the SBB
network it looks like this:
1
3
2
4
Geneva
Bern
Basel
Zurich
0 54 57 -
54 0 55 -
57 55 0 101
- - 101 0
A =
1 2 3 4
1
2
3
40:57
0:540:55
1:41
2010-03-29 A. Johansson & W. Yu / [email protected] [email protected] 17
Projects
From next week, Wenjian Yu will take over the course. Therefore, address all future communication only to:[email protected]
Today, there are no exercises. Instead, you can work on your projects and we will supervise you.