2010-03-29 851-0585-04l – modelling and simulating social systems with matlab lesson 6 – graphs...
TRANSCRIPT
![Page 1: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/1.jpg)
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 |
![Page 2: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/2.jpg)
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
![Page 3: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/3.jpg)
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
![Page 4: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/4.jpg)
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?
![Page 5: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/5.jpg)
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
![Page 6: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/6.jpg)
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
![Page 7: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/7.jpg)
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.
![Page 8: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/8.jpg)
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.
![Page 9: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/9.jpg)
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
![Page 10: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/10.jpg)
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.
![Page 11: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/11.jpg)
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.
![Page 12: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/12.jpg)
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;
…
![Page 13: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/13.jpg)
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
![Page 14: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/14.jpg)
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
![Page 15: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/15.jpg)
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
![Page 16: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/16.jpg)
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
![Page 17: 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](https://reader035.vdocuments.site/reader035/viewer/2022062722/56649f345503460f94c50ea5/html5/thumbnails/17.jpg)
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.