SlideShare uma empresa Scribd logo
1 de 83
Baixar para ler offline
Kyunghoon Kim
Network Analysis with networkX
Fundamentals of network theory-1
2014. 05. 14.
UNIST Mathematical Sciences
Kyunghoon Kim ( Kyunghoon@unist.ac.kr )
5/14/2014 Fundamentals of network theory-1 1
Kyunghoon Kim
● A NETWORK is, in its simplest form, a collection
of points joined together in pairs by lines.
What is a Network?
Newman, Mark. Networks: an introduction. OUP Oxford, 2009.
5/14/2014 Fundamentals of network theory-1 2
Kyunghoon Kim
● A NETWORK is, in its simplest form, a collection
of points joined together in pairs by lines.
● Network is general, but powerful means of
representing patterns of connections or
interactions between the parts of a system.
What is a Network?
Newman, Mark. Networks: an introduction. OUP Oxford, 2009.
5/14/2014 Fundamentals of network theory-1 3
Kyunghoon Kim
What is a Network?
Shipping (sea) networksTelecommunications networks
Air traffic networkData networks
Source: Britain From Above (http://www.bbc.co.uk/britainfromabove)
5/14/2014 Fundamentals of network theory-1 4
Kyunghoon Kim
● Network thinking can be applied almost
anywhere!
What is a Network?
5/14/2014 Fundamentals of network theory-1 5
Kyunghoon Kim
● Network thinking can be applied almost
anywhere!
Example of Network Thinking
http://journals.uic.edu/ojs/index.php/fm/article/view/941/863
My data sources were publicly released information reported in major
newspapers such as the New York Times, Wall Street Journal, Washington
Post, and the Los Angeles Times. As I monitored the investigation, it was apparent
that the investigators would not be releasing all pertinent
network/relationship information and actually may be releasing misinformation to
fool the enemy. I soon realized that the data was not going to be as complete and
accurate as I had grown accustomed to in mapping and measuring organizational
networks.
5/14/2014 Fundamentals of network theory-1 6
Kyunghoon Kim
Example of Network Thinking
http://www.orgnet.com/hijackers.html
5/14/2014 Fundamentals of network theory-1 7
Kyunghoon Kim
Example of Network Thinking
5/14/2014 Fundamentals of network theory-1 8
Kyunghoon Kim
Example of Network Thinking
Six (6) shortcuts were added to the
network temporarily in order to
collaborate and coordinate.
These shortcuts reduced the average
path length in the network by over 40%
thus improving the information flow in
the network - see Table 1.
When the network is brought closer
together by these shortcuts, all of the
pilots ended up in a small clique - the
perfect structure to efficiently coordinate
tasks and activities.
There is a constant dynamic
between keeping the network hidden
and actively using it to accomplish
objectives (Baker and Faulkner, 1993).
5/14/2014 Fundamentals of network theory-1 9
Kyunghoon Kim
Example of Network Thinking
5/14/2014 Fundamentals of network theory-1 10
Kyunghoon Kim
Example of Network Thinking
5/14/2014 Fundamentals of network theory-1 11
Kyunghoon Kim
Example of Network Thinking
Saddam Hussein
5/14/2014 Fundamentals of network theory-1 12
Kyunghoon Kim
Example of Network Thinking
5/14/2014 Fundamentals of network theory-1 13
Kyunghoon Kim
Example of Network Thinking
5/14/2014 Fundamentals of network theory-1 14
An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 15
Where’s it applied?
Epidemiology (i.e. spread of diseases)
e.g. spread of foot & mouth disease in the UK in 2001 over 75 days
URL: http://www.youtube.com/watch?v=PufTeIBNRJ4
An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 16
Physics
e.g. particle interactions, the structure of the universe
Where’s it applied?
URL: http://www.youtube.com/watch?v=8C_dnP2fvxk
An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 17
Engineering
e.g. creation of robust infrastructure (e.g. electricity, telecoms), rust formation (natural
growth processes similar to diffusion limited aggregation)
Where’s it applied?
URL: http://www.youtube.com/watch?v=lRZ2iEHFgGo URL: http://www.youtube.com/watch?v=AEoP-XtJueo
An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 18
Technology
e.g. mapping the online world, making networks resilient in the face of cyber-terrorism,
optimising cellular networks, controlling air traffic
Where’s it applied?
URL: http://www.youtube.com/watch?v=l-RoDv7c5ok URL: http://www.youtube.com/watch?v=o4g930pm8Ms
Vid not working
An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 19
Where’s it applied?
Biology
e.g. fish swimming in schools, ant colonies, birds flying in formation, crickets chirping in
unison, giant honeybees shimmering
URL: http://www.youtube.com/watch?v=Sp8tLPDMUygURL: http://www.youtube.com/watch?v=YadP3w7vkJA
An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 20
Medicine
e.g. cell formation, nervous system, neural networks
Where’s it applied?
Source: The Human Brain Book by Rita Carter
An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 21
And, most interestingly…society
e.g. interactions between people (e.g. Facebook; group behaviour)
Where’s it applied?
URL: http://www.youtube.com/watch?v=9n9irapdON4 URL: http://www.youtube.com/watch?v=sD2yosZ9qDw
Kyunghoon Kim
● A network – also called a graph in the
mathematical literature – is, as we have said, a
collection of vertices joined by edges.
Networks and their Representation
Area Object Relation
Graph Theory Vertices Edges
Computer Science Nodes Links
Physics Sites Bonds
Sociology Actors Ties
5/14/2014 Fundamentals of network theory-1 22
Kyunghoon Kim
Networks and their Representation
Figure 6.1: Two small networks. (a) A simple graph, i.e., one having no multiedges or self-edges.
(b) A network with both multiedges and self-edges.
Newman, Mark. Networks: an introduction. OUP Oxford, 2009.
5/14/2014 Fundamentals of network theory-1 23
Kyunghoon Kim
Networks and their Representation
𝐴𝐴𝑖𝑖𝑖𝑖 = �
1
0
𝑖𝑖𝑖𝑖 𝑡𝑡 𝑡𝑡𝑡𝑡𝑡𝑡𝑡 𝑖𝑖𝑖𝑖 𝑎𝑎𝑎𝑎 𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏 𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣 𝑖𝑖 𝑎𝑎𝑎𝑎𝑎𝑎 𝑗𝑗,
𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜.
5/14/2014 Fundamentals of network theory-1 24
Kyunghoon Kim
● import networkx as nx
G = nx.Graph()
G.add_node(1)
G.add_nodes_from([1,2,3,4,5])
G.nodes()
● >>> [1, 2, 3, 4, 5]
Networks and their Representation
5/14/2014 Fundamentals of network theory-1 25
Kyunghoon Kim
● G.add_edge(1,2)
G.add_edges_from([(1,2),(2,4),(2,5),(3,4)])
G.edges()
● >>> [(1, 2), (2, 4), (2, 5), (3, 4)]
Networks and their Representation
5/14/2014 Fundamentals of network theory-1 26
Kyunghoon Kim
● nx.to_numpy_matrix(G)
● matrix([[ 0., 1., 0., 0., 0.],
[ 1., 0., 0., 1., 1.],
[ 0., 0., 0., 1., 0.],
[ 0., 1., 1., 0., 0.],
[ 0., 1., 0., 0., 0.]])
 nx.draw(G)
Networks and their Representation
5/14/2014 Fundamentals of network theory-1 27
Kyunghoon Kim
Networks and their Representation
5/14/2014 Fundamentals of network theory-1 28
Kyunghoon Kim
Networks and their Representation
= 𝐴𝐴 =
5/14/2014 Fundamentals of network theory-1 29
Kyunghoon Kim
Networks and their Representation
5/14/2014 Fundamentals of network theory-1 30
Kyunghoon Kim
Degree
5/14/2014 Fundamentals of network theory-1 31
Kyunghoon Kim
Degree
5/14/2014 Fundamentals of network theory-1 32
Kyunghoon Kim
Degree
𝑘𝑘𝑖𝑖 = �
𝑗𝑗=1
𝑛𝑛
𝐴𝐴𝑖𝑖𝑖𝑖
𝑘𝑘2 = �
𝑗𝑗=1
5
𝐴𝐴1𝑗𝑗 = 3
5/14/2014 Fundamentals of network theory-1 33
Kyunghoon Kim
Degree
5/14/2014 Fundamentals of network theory-1 34
Kyunghoon Kim
Degree
𝑘𝑘𝑖𝑖 = �
𝑗𝑗=1
𝑛𝑛
𝐴𝐴𝑖𝑖𝑖𝑖
2𝑚𝑚 = �
𝑖𝑖=1
𝑛𝑛
𝑘𝑘𝑖𝑖
5/14/2014 Fundamentals of network theory-1 35
Kyunghoon Kim
Total Degree m
𝑘𝑘𝑖𝑖 = �
𝑗𝑗=1
𝑛𝑛
𝐴𝐴𝑖𝑖𝑖𝑖
2𝑚𝑚 = �
𝑖𝑖=1
𝑛𝑛
𝑘𝑘𝑖𝑖
𝑚𝑚 =
1
2
�
𝑖𝑖=1
𝑛𝑛
𝑘𝑘𝑖𝑖 =
1
2
�
𝑖𝑖𝑖𝑖
𝐴𝐴𝑖𝑖𝑖𝑖
5/14/2014 Fundamentals of network theory-1 36
Kyunghoon Kim
Total Degree m
𝑘𝑘𝑖𝑖 = �
𝑗𝑗=1
𝑛𝑛
𝐴𝐴𝑖𝑖𝑖𝑖
2𝑚𝑚 = �
𝑖𝑖=1
𝑛𝑛
𝑘𝑘𝑖𝑖
𝑚𝑚 =
1
2
�
𝑖𝑖=1
𝑛𝑛
𝑘𝑘𝑖𝑖 =
1
2
�
𝑖𝑖𝑖𝑖
𝐴𝐴𝑖𝑖𝑖𝑖
𝑛𝑛
5/14/2014 Fundamentals of network theory-1 37
Kyunghoon Kim
Mean Degree c
𝑘𝑘𝑖𝑖 = �
𝑗𝑗=1
𝑛𝑛
𝐴𝐴𝑖𝑖𝑖𝑖
2𝑚𝑚 = �
𝑖𝑖=1
𝑛𝑛
𝑘𝑘𝑖𝑖
𝑐𝑐 =
1
𝑛𝑛
�
𝑖𝑖=1
𝑛𝑛
𝑘𝑘𝑖𝑖 =
2𝑚𝑚
𝑛𝑛
5/14/2014 Fundamentals of network theory-1 38
Kyunghoon Kim
Mean Degree c
𝑐𝑐 =
1
𝑛𝑛
�
𝑖𝑖=1
𝑛𝑛
𝑘𝑘𝑖𝑖 =
2𝑚𝑚
𝑛𝑛
>>> G.degree()
{1: 1, 2: 3, 3: 1, 4: 2, 5: 1}
>>> G.degree(2)
3
>>> Degree = G.degree().values()
[1, 3, 1, 2, 1]
>>> sum(Degree)/len(G.nodes())
1.6000000000000001
5/14/2014 Fundamentals of network theory-1 39
Kyunghoon Kim
Density or connectance of a graph
𝑛𝑛
2
=
1
2
𝑛𝑛(𝑛𝑛 − 1)
in a simple graph(i.e., one with no multiedges
or self-edges)
5/14/2014 Fundamentals of network theory-1 40
Kyunghoon Kim
Density or connectance of a graph
𝜌𝜌 =
𝑚𝑚
𝑛𝑛
2
=
2𝑚𝑚
𝑛𝑛(𝑛𝑛 − 1)
=
𝑐𝑐
𝑛𝑛 − 1
𝑛𝑛
2
=
1
2
𝑛𝑛(𝑛𝑛 − 1)
5/14/2014 Fundamentals of network theory-1 41
Kyunghoon Kim
Density or connectance of a graph
𝜌𝜌 =
𝑚𝑚
𝑛𝑛
2
=
2𝑚𝑚
𝑛𝑛(𝑛𝑛 − 1)
=
𝑐𝑐
𝑛𝑛 − 1
>>> total = 0.5*5*(5-1)
>>> 4/total
0.4
>>> nx.density(G)
0.4
5/14/2014 Fundamentals of network theory-1 42
Kyunghoon Kim
● The in-degree is the # of ingoing edges
connected to a vertex.
● The out-degree is the # of outgoing edges
connected to a vertex.
● 𝐴𝐴𝑖𝑖𝑖𝑖 = 1 if there is an edge from 𝑗𝑗 to 𝑖𝑖.
In-degree and out-degree
𝑘𝑘𝑖𝑖
𝑖𝑖 𝑖𝑖
= �
𝑗𝑗=1
𝑛𝑛
𝐴𝐴𝑖𝑖𝑖𝑖 𝑘𝑘𝑖𝑖
𝑜𝑜𝑜𝑜𝑜𝑜
= �
𝑖𝑖=1
𝑛𝑛
𝐴𝐴𝑖𝑖𝑖𝑖
5/14/2014 Fundamentals of network theory-1 43
Kyunghoon Kim
● A path in a network is any sequence of vertices
such that every consecutive pair of vertices in
the sequence is connected by an edge in the
network.
Paths
5/14/2014 Fundamentals of network theory-1 44
Kyunghoon Kim
● A path in a network is any sequence of vertices
such that every consecutive pair of vertices in
the sequence is connected by an edge in the
network.
● A path is a route across the network that runs
from vertex to vertex along the edges of the
network.
Paths
5/14/2014 Fundamentals of network theory-1 45
Kyunghoon Kim
● The length of a path in a network is the # of
edges traversed along the path (not the # of
vertices).
Length of Paths
5/14/2014 Fundamentals of network theory-1 46
Kyunghoon Kim
● The length of a path in a network is the # of
edges traversed along the path (not the # of
vertices).
● 𝐴𝐴𝑖𝑖𝑖𝑖 = 1 if there is an edge from 𝑗𝑗 to 𝑖𝑖,
and 0 otherwise.
Length of Paths
5/14/2014 Fundamentals of network theory-1 47
Kyunghoon Kim
● The length of a path in a network is the # of
edges traversed along the path (not the # of
vertices).
● 𝐴𝐴𝑖𝑖𝑖𝑖 = 1 if there is an edge from 𝑗𝑗 to 𝑖𝑖,
and 0 otherwise.
Length of Paths
𝑁𝑁𝑖𝑖𝑖𝑖
(2)
= �
𝑘𝑘=1
𝑛𝑛
𝐴𝐴𝑖𝑖 𝑖𝑖 𝐴𝐴𝑘𝑘𝑘𝑘 = 𝐀𝐀2
𝑖𝑖𝑖𝑖
5/14/2014 Fundamentals of network theory-1 48
Kyunghoon Kim
● The length of a path in a network is the # of
edges traversed along the path (not the # of
vertices).
● 𝐴𝐴𝑖𝑖𝑖𝑖 = 1 if there is an edge from 𝑗𝑗 to 𝑖𝑖,
and 0 otherwise.
i ← k , k ←j
Length of Paths
𝑁𝑁𝑖𝑖𝑖𝑖
(2)
= �
𝑘𝑘=1
𝑛𝑛
𝐴𝐴𝑖𝑖 𝑖𝑖 𝐴𝐴𝑘𝑘𝑘𝑘 = 𝐀𝐀2
𝑖𝑖𝑖𝑖
5/14/2014 Fundamentals of network theory-1 49
Kyunghoon Kim
● The length of a path in a network is the # of
edges traversed along the path (not the # of
vertices).
● 𝐴𝐴𝑖𝑖𝑖𝑖 = 1 if there is an edge from 𝑗𝑗 to 𝑖𝑖,
and 0 otherwise.
Length of Paths
𝑁𝑁𝑖𝑖𝑖𝑖
(2)
= �
𝑘𝑘=1
𝑛𝑛
𝐴𝐴𝑖𝑖 𝑖𝑖 𝐴𝐴𝑘𝑘𝑘𝑘 = 𝐀𝐀2
𝑖𝑖𝑖𝑖
𝑁𝑁𝑖𝑖𝑖𝑖
(3)
= �
𝑘𝑘,𝑙𝑙=1
𝐴𝐴𝑖𝑖 𝑖𝑖 𝐴𝐴𝑘𝑘𝑙𝑙 𝐴𝐴𝑙𝑙𝑗𝑗 = 𝐀𝐀3
𝑖𝑖𝑖𝑖
5/14/2014 Fundamentals of network theory-1 50
Kyunghoon Kim
● import numpy as np
matrix = nx.to_numpy_matrix(G)
matrix*np.transpose(matrix)
matrix([[ 1., 0., 0., 1., 1.],
[ 0., 3., 1., 0., 0.],
[ 0., 1., 1., 0., 0.],
[ 1., 0., 0., 2., 1.],
[ 1., 0., 0., 1., 1.]])
Length of Paths
𝑁𝑁𝑖𝑖𝑖𝑖
(2)
= �
𝑘𝑘=1
𝑛𝑛
𝐴𝐴𝑖𝑖 𝑖𝑖 𝐴𝐴𝑘𝑘𝑘𝑘 = 𝐀𝐀2
𝑖𝑖𝑖𝑖
5/14/2014 Fundamentals of network theory-1 51
Kyunghoon Kim
Loops
𝑁𝑁𝑖𝑖𝑖𝑖
(2)
=
5/14/2014 Fundamentals of network theory-1 52
Kyunghoon Kim
● A shortest path is a path between two vertices
such that no shorter path exists:
Shortest path (Geodesic path)
Newman, Mark. Networks: an introduction. OUP Oxford, 2009.
5/14/2014 Fundamentals of network theory-1 53
Kyunghoon Kim
● A shortest path is a path between two vertices
such that no shorter path exists:
● Shortest paths are necessarily self-avoiding.
● Shortest paths are not necessarily unique.
Shortest path (Geodesic path)
Newman, Mark. Networks: an introduction. OUP Oxford, 2009.
5/14/2014 Fundamentals of network theory-1 54
Kyunghoon Kim
● The shortest distance between vertices 𝑖𝑖 and 𝑗𝑗
is the smallest value of 𝑟𝑟 such that 𝐀𝐀𝑟𝑟
𝑖𝑖𝑖𝑖 > 0.
Shortest distance (Geodesic distance)
5/14/2014 Fundamentals of network theory-1 55
Kyunghoon Kim
● The shortest distance between vertices 𝑖𝑖 and 𝑗𝑗
is the smallest value of 𝑟𝑟 such that 𝐀𝐀𝑟𝑟
𝑖𝑖𝑖𝑖 > 0.
● However, in practical case we use Dijkstra’s
algorithm. We will study it later.
Shortest distance (Geodesic distance)
5/14/2014 Fundamentals of network theory-1 56
Kyunghoon Kim
● The diameter of a graph is the length of the
longest geodesic path between any pair of
vertices in the network for which a path
actually exists.
Diameter of a graph
5/14/2014 Fundamentals of network theory-1 57
Kyunghoon Kim
● Which are the most important
or central vertices in a network?
Measures and Metrics
5/14/2014 Fundamentals of network theory-1 58
Kyunghoon Kim
● Which are the most important
or central vertices in a network?
● Degree centrality,
Closeness centrality,
Betweenness centrality,
Eigenvector centrality,
Pagerank,
Similarity…
Measures and Metrics
5/14/2014 Fundamentals of network theory-1 59
Kyunghoon Kim
● Degree is sometimes called degree centrality in
the social networks literature.
● In directed networks, vertices have both an in-
degree and an out-degree, and both may be
useful as measures of centrality in the
appropriate circumstances.
Degree Centrality
5/14/2014 Fundamentals of network theory-1 60
Kyunghoon Kim
Degree Centrality
5/14/2014 Fundamentals of network theory-1 61
Kyunghoon Kim
Clustering Coefficient (local)
● For a vertex 𝑖𝑖, we define :
𝐶𝐶𝑖𝑖 =
(𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑜𝑜𝑜𝑜 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 𝑜𝑜𝑜𝑜 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑜𝑜𝑜𝑜 𝑖𝑖 𝑡𝑡 𝑡𝑡𝑡𝑡𝑡 𝑎𝑎𝑎𝑎𝑎𝑎 𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐)
(𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑜𝑜𝑜𝑜 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 𝑜𝑜𝑜𝑜 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑜𝑜𝑜𝑜 𝑖𝑖)
5/14/2014 Fundamentals of network theory-1 62
Kyunghoon Kim
Clustering Coefficient (local)
● >>> nx.clustering(G)
● {1: 0.0, 2: 0.3333, 3: 0.6666, 4: 1.0, 5: 1.0}
𝐶𝐶2 =
2
4
2
=
1
3
= 0.3333
5/14/2014 Fundamentals of network theory-1 63
Kyunghoon Kim
Clustering Coefficient (local)
5/14/2014 Fundamentals of network theory-1 64
“Unclustered” network “Clustered” network
None of Ego’s friends know each other* All of Ego’s friends know each other
An Introduction to Network Theory | Kyle Findlay | SAMRA 2010
Kyunghoon Kim
Clustering Coefficient (local)
5/14/2014 Fundamentals of network theory-1 65
– A real-world example: CEOs of Fortune 500 companies
• Which companies share directors? Clusters are colour-coded
An Introduction to Network Theory | Kyle Findlay | SAMRA 2010
Kyunghoon Kim
● This measures the mean distance from a vertex
to other vertices.
● Suppose 𝑑𝑑𝑖𝑖𝑖𝑖 is the length of a geodesic path
from 𝑖𝑖 to 𝑗𝑗, meaning the # of edges along the
path.
Closeness Centrality
5/14/2014 Fundamentals of network theory-1 66
Kyunghoon Kim
● This measures the mean distance from a vertex
to other vertices.
● Suppose 𝑑𝑑𝑖𝑖𝑖𝑖 is the length of a geodesic path
from 𝑖𝑖 to 𝑗𝑗, meaning the # of edges along the
path.
● The mean shortest distance from 𝑖𝑖 to 𝑗𝑗,
averaged over all vertices 𝑗𝑗 in the network, is
Closeness Centrality
𝑙𝑙𝑖𝑖 =
1
𝑛𝑛
�
𝑗𝑗
𝑑𝑑𝑖𝑖𝑖𝑖
5/14/2014 Fundamentals of network theory-1 67
Kyunghoon Kim
● Exclude for 𝑗𝑗 = 𝑖𝑖,
Closeness Centrality
𝑙𝑙𝑖𝑖 =
1
𝑛𝑛 − 1
�
𝑗𝑗(≠𝑖𝑖)
𝑑𝑑𝑖𝑖𝑖𝑖
𝑙𝑙𝑖𝑖 =
1
𝑛𝑛
�
𝑗𝑗
𝑑𝑑𝑖𝑖𝑖𝑖
5/14/2014 Fundamentals of network theory-1 68
Kyunghoon Kim
● This quantity takes low values for vertices that
are separated from others by only a short
shortest distance on average.
● which is the opposite of other measures.
● So commonly we take inverse :
Closeness Centrality
𝐶𝐶𝑖𝑖 =
1
𝑙𝑙𝑖𝑖
=
𝑛𝑛
∑𝑗𝑗 𝑑𝑑𝑖𝑖𝑖𝑖
5/14/2014 Fundamentals of network theory-1 69
Kyunghoon Kim
>>> nx.closeness_centrality(G)
{1: 0.5714, 2: 1.0, 3: 0.8, 4: 0.6666, 5: 0.6666}
Closeness Centrality
𝐶𝐶𝑖𝑖 =
1
𝑙𝑙𝑖𝑖
=
𝑛𝑛
∑𝑗𝑗 𝑑𝑑𝑖𝑖𝑖𝑖
𝐶𝐶1 =
4
∑𝑗𝑗 𝑑𝑑1𝑗𝑗
=
4
1 + 2 + 2 + 2
= 0.5714
5/14/2014 Fundamentals of network theory-1 70
Kyunghoon Kim
● This measures the extent to which a vertex lies
on paths between other vertices.
Betweenness Centrality
5/14/2014 Fundamentals of network theory-1 71
Kyunghoon Kim
● This measures the extent to which a vertex lies
on paths between other vertices.
● For example, assume that every pair of vertices
exchanges a message with equal probability
per unit time and that messages always take
the shortest path.
Betweenness Centrality
5/14/2014 Fundamentals of network theory-1 72
Kyunghoon Kim
● For example, assume that every pair of vertices
exchanges a message with equal probability
per unit time and that messages always take
the shortest path.
● Question : if we wait a suitably long time until
many messages have passed between each
pair of vertices, how many messages, on
average, will have passed through each vertex
en route to their destination?
Betweenness Centrality
5/14/2014 Fundamentals of network theory-1 73
Kyunghoon Kim
● Question : if we wait a suitably long time until
many messages have passed between each
pair of vertices, how many messages, on
average, will have passed through each vertex
en route to their destination?
● Answer : since messages are passing down
each shortest path at the same rate, the
number passing through each vertex is simply
proportional to the # of shortest paths the
vertex lies on.
Betweenness Centrality
5/14/2014 Fundamentals of network theory-1 74
Kyunghoon Kim
● Let 𝑛𝑛𝑠𝑠𝑠𝑠
𝑖𝑖
be 1 if vertex 𝑖𝑖 lies on the shortest path
from 𝑠𝑠 to 𝑡𝑡 and 0 if it does not or if there is no
such path.
● The betweenness centrality 𝑥𝑥𝑖𝑖 is given by
Betweenness Centrality
𝑥𝑥𝑖𝑖 = �
𝑠𝑠𝑡𝑡
𝑛𝑛𝑠𝑠𝑠𝑠
𝑖𝑖
5/14/2014 Fundamentals of network theory-1 75
Kyunghoon Kim
● Note that the shortest paths between a pair of
vertices need not be vertex independent,
meaning they may pass through some of the
same vertices.
● Define 𝑔𝑔𝑠𝑠𝑠𝑠 to be the total # of shortest paths
from 𝑠𝑠 to 𝑡𝑡 .
where
𝑛𝑛𝑠𝑠𝑠𝑠
𝑖𝑖
𝑔𝑔𝑠𝑠𝑠𝑠
= 0 if both 𝑛𝑛𝑠𝑠𝑠𝑠
𝑖𝑖
and 𝑔𝑔𝑠𝑠𝑠𝑠 are zero.
Betweenness Centrality
𝑥𝑥𝑖𝑖 = �
𝑠𝑠𝑡𝑡
𝑛𝑛𝑠𝑠𝑠𝑠
𝑖𝑖
𝑔𝑔𝑠𝑠𝑠𝑠
5/14/2014 Fundamentals of network theory-1 76
Kyunghoon Kim
>>> nx.betweenness_centrality(G)
{1: 0.0, 2: 0.5833, 3: 0.0833, 4: 0.0, 5: 0.0}
Betweenness Centrality
𝑥𝑥𝑖𝑖 = �
𝑠𝑠𝑡𝑡
𝑛𝑛𝑠𝑠𝑠𝑠
𝑖𝑖
𝑔𝑔𝑠𝑠𝑠𝑠
𝑥𝑥1 = �
𝑠𝑠𝑡𝑡
𝑛𝑛𝑠𝑠𝑠𝑠
1
𝑔𝑔𝑠𝑠𝑠𝑠
5/14/2014 Fundamentals of network theory-1 77
Kyunghoon Kim
>>> nx.betweenness_centrality(G)
{1: 0.0, 2: 0.5833, 3: 0.0833, 4: 0.0, 5: 0.0}
g = nx.Graph()
g.add_edges_from([(1,2),(2,3),(2,4),(2,5),(3,4),(3,5)])end = 6
for i in range(1,end):
for j in range(1,end):
#print 'from', i, 'to', j
print([p for p in nx.all_shortest_paths(g,i,j) if len(p)>2])
#print nx.dijkstra_path(g,i,j)
#print '=============='
nx.betweenness_centrality(g, normalized=False)
plt.cla()
nx.draw(g)
Betweenness Centrality
𝑥𝑥2 = �
𝑠𝑠𝑡𝑡
𝑛𝑛𝑠𝑠𝑠𝑠
2
𝑔𝑔𝑠𝑠𝑠𝑠
= 3 +
1
2
5/14/2014 Fundamentals of network theory-1 78
Kyunghoon Kim
>>> nx.betweenness_centrality(G)
{1: 0.0, 2: 0.5833, 3: 0.0833, 4: 0.0, 5: 0.0}
[[1, 2, 3]]
[[1, 2, 4]]
[[1, 2, 5]]
[[3, 2, 1]]
[[4, 2, 1]]
[[4, 2, 5], [4, 3, 5]]
[[5, 2, 1]]
[[5, 2, 4], [5, 3, 4]]
Betweenness Centrality
𝑥𝑥2 = �
𝑠𝑠𝑡𝑡
𝑛𝑛𝑠𝑠𝑠𝑠
2
𝑔𝑔𝑠𝑠𝑠𝑠
= 3 +
1
2
5/14/2014 Fundamentals of network theory-1 79
Kyunghoon Kim
>>> nx.betweenness_centrality(G)
{1: 0.0, 2: 0.5833, 3: 0.0833, 4: 0.0, 5: 0.0}
To normalize,
we use the following equation,
2
(𝑛𝑛−1)(𝑛𝑛−2)
Then,
Betweenness Centrality
𝑥𝑥2 =
2
4 × 3
�
𝑠𝑠𝑡𝑡
𝑛𝑛𝑠𝑠𝑠𝑠
2
𝑔𝑔𝑠𝑠𝑠𝑠
=
1
6
3 +
1
2
= 0.5833
5/14/2014 Fundamentals of network theory-1 80
Kyunghoon Kim
Appendix
● G.add_edges_from([
(1,3),(3,6),(3,7),(3,8),(6,8),(7,8),(8,9)])
5/14/2014 Fundamentals of network theory-1 81
Kyunghoon Kim
● nx.draw_spring(G)
● nx.to_numpy_matrix(G)
Appendix
5/14/2014 Fundamentals of network theory-1 82
Kyunghoon Kim
● Newman, Mark. Networks: an introduction.
OUP Oxford, 2009.
● An Introduction to Network Theory | Kyle
Findlay | SAMRA 2010
● http://journals.uic.edu/ojs/index.php/fm/articl
e/view/941/863
● http://www.orgnet.com/hijackers.html
Reference
5/14/2014 Fundamentals of network theory-1 83

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Distance Vector Multicast Routing Protocol (DVMRP) : Combined Presentation
Distance Vector Multicast Routing Protocol (DVMRP) : Combined PresentationDistance Vector Multicast Routing Protocol (DVMRP) : Combined Presentation
Distance Vector Multicast Routing Protocol (DVMRP) : Combined Presentation
 
Graph theory
Graph theory Graph theory
Graph theory
 
Graph theory
Graph theoryGraph theory
Graph theory
 
MATCHING GRAPH THEORY
MATCHING GRAPH THEORYMATCHING GRAPH THEORY
MATCHING GRAPH THEORY
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Bellman ford Algorithm
Bellman ford AlgorithmBellman ford Algorithm
Bellman ford Algorithm
 
Kirchoff''s matrix tree theorem
Kirchoff''s matrix tree theoremKirchoff''s matrix tree theorem
Kirchoff''s matrix tree theorem
 
Merge sort
Merge sortMerge sort
Merge sort
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
 
Heap sort
Heap sort Heap sort
Heap sort
 
EULER AND FERMAT THEOREM
EULER AND FERMAT THEOREMEULER AND FERMAT THEOREM
EULER AND FERMAT THEOREM
 
Kruskal's algorithm
Kruskal's algorithmKruskal's algorithm
Kruskal's algorithm
 
Prims and kruskal algorithms
Prims and kruskal algorithmsPrims and kruskal algorithms
Prims and kruskal algorithms
 
Interesting applications of graph theory
Interesting applications of graph theoryInteresting applications of graph theory
Interesting applications of graph theory
 
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
GRAPH APPLICATION - MINIMUM SPANNING TREE (MST)
 
Max flow min cut
Max flow min cutMax flow min cut
Max flow min cut
 
Graph isomorphism
Graph isomorphismGraph isomorphism
Graph isomorphism
 
Red Black Tree Insertion & Deletion
Red Black Tree Insertion & DeletionRed Black Tree Insertion & Deletion
Red Black Tree Insertion & Deletion
 
Prims Algorithm
Prims AlgorithmPrims Algorithm
Prims Algorithm
 
Graphs bfs dfs
Graphs bfs dfsGraphs bfs dfs
Graphs bfs dfs
 

Semelhante a Network Analysis with networkX : Fundamentals of network theory-1

All pair shortest path--SDN
All pair shortest path--SDNAll pair shortest path--SDN
All pair shortest path--SDNSarat Prasad
 
HC-4012, Complex Network Clustering Using GPU-based Parallel Non-negative Mat...
HC-4012, Complex Network Clustering Using GPU-based Parallel Non-negative Mat...HC-4012, Complex Network Clustering Using GPU-based Parallel Non-negative Mat...
HC-4012, Complex Network Clustering Using GPU-based Parallel Non-negative Mat...AMD Developer Central
 
Itc542 network design research
Itc542 network design researchItc542 network design research
Itc542 network design researchOz Paper Help
 
ICDE-2015 Shortest Path Traversal Optimization and Analysis for Large Graph C...
ICDE-2015 Shortest Path Traversal Optimization and Analysis for Large Graph C...ICDE-2015 Shortest Path Traversal Optimization and Analysis for Large Graph C...
ICDE-2015 Shortest Path Traversal Optimization and Analysis for Large Graph C...Waqas Nawaz
 
Overlapping community detection in Large-Scale Networks using BigCLAM model b...
Overlapping community detection in Large-Scale Networks using BigCLAM model b...Overlapping community detection in Large-Scale Networks using BigCLAM model b...
Overlapping community detection in Large-Scale Networks using BigCLAM model b...Thang Nguyen
 
IRJET-Artificial Neural Networks to Determine Source of Acoustic Emission and...
IRJET-Artificial Neural Networks to Determine Source of Acoustic Emission and...IRJET-Artificial Neural Networks to Determine Source of Acoustic Emission and...
IRJET-Artificial Neural Networks to Determine Source of Acoustic Emission and...IRJET Journal
 
Efficient method for finding nearest neighbors in flocking behaviors using k-...
Efficient method for finding nearest neighbors in flocking behaviors using k-...Efficient method for finding nearest neighbors in flocking behaviors using k-...
Efficient method for finding nearest neighbors in flocking behaviors using k-...IAESIJAI
 
Social Network Analysis: What It Is, Why We Should Care, and What We Can Lear...
Social Network Analysis: What It Is, Why We Should Care, and What We Can Lear...Social Network Analysis: What It Is, Why We Should Care, and What We Can Lear...
Social Network Analysis: What It Is, Why We Should Care, and What We Can Lear...Xiaohan Zeng
 
Literature Review: Convey the Data in Massive Parallel Computing
Literature Review: Convey the Data in Massive Parallel ComputingLiterature Review: Convey the Data in Massive Parallel Computing
Literature Review: Convey the Data in Massive Parallel ComputingAM Publications,India
 
Graph Analytics with Greenplum and Apache MADlib
Graph Analytics with Greenplum and Apache MADlibGraph Analytics with Greenplum and Apache MADlib
Graph Analytics with Greenplum and Apache MADlibVMware Tanzu
 
Compression-based Graph Mining Exploiting Structure Primites
Compression-based Graph Mining Exploiting Structure PrimitesCompression-based Graph Mining Exploiting Structure Primites
Compression-based Graph Mining Exploiting Structure PrimitesWerner Hoffmann
 
Optimum Relay Node Selection in Clustered MANET
Optimum Relay Node Selection in Clustered MANETOptimum Relay Node Selection in Clustered MANET
Optimum Relay Node Selection in Clustered MANETIRJET Journal
 
Victoria A. White Head, Computing Division Fermilab
Victoria A. White Head, Computing Division FermilabVictoria A. White Head, Computing Division Fermilab
Victoria A. White Head, Computing Division FermilabVideoguy
 
H030102052055
H030102052055H030102052055
H030102052055theijes
 
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...ijp2p
 
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...ijp2p
 
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...ijp2p
 
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...ijp2p
 

Semelhante a Network Analysis with networkX : Fundamentals of network theory-1 (20)

Final ppt
Final pptFinal ppt
Final ppt
 
All pair shortest path--SDN
All pair shortest path--SDNAll pair shortest path--SDN
All pair shortest path--SDN
 
HC-4012, Complex Network Clustering Using GPU-based Parallel Non-negative Mat...
HC-4012, Complex Network Clustering Using GPU-based Parallel Non-negative Mat...HC-4012, Complex Network Clustering Using GPU-based Parallel Non-negative Mat...
HC-4012, Complex Network Clustering Using GPU-based Parallel Non-negative Mat...
 
Itc542 network design research
Itc542 network design researchItc542 network design research
Itc542 network design research
 
Network analysis
Network analysisNetwork analysis
Network analysis
 
ICDE-2015 Shortest Path Traversal Optimization and Analysis for Large Graph C...
ICDE-2015 Shortest Path Traversal Optimization and Analysis for Large Graph C...ICDE-2015 Shortest Path Traversal Optimization and Analysis for Large Graph C...
ICDE-2015 Shortest Path Traversal Optimization and Analysis for Large Graph C...
 
Overlapping community detection in Large-Scale Networks using BigCLAM model b...
Overlapping community detection in Large-Scale Networks using BigCLAM model b...Overlapping community detection in Large-Scale Networks using BigCLAM model b...
Overlapping community detection in Large-Scale Networks using BigCLAM model b...
 
IRJET-Artificial Neural Networks to Determine Source of Acoustic Emission and...
IRJET-Artificial Neural Networks to Determine Source of Acoustic Emission and...IRJET-Artificial Neural Networks to Determine Source of Acoustic Emission and...
IRJET-Artificial Neural Networks to Determine Source of Acoustic Emission and...
 
Efficient method for finding nearest neighbors in flocking behaviors using k-...
Efficient method for finding nearest neighbors in flocking behaviors using k-...Efficient method for finding nearest neighbors in flocking behaviors using k-...
Efficient method for finding nearest neighbors in flocking behaviors using k-...
 
Social Network Analysis: What It Is, Why We Should Care, and What We Can Lear...
Social Network Analysis: What It Is, Why We Should Care, and What We Can Lear...Social Network Analysis: What It Is, Why We Should Care, and What We Can Lear...
Social Network Analysis: What It Is, Why We Should Care, and What We Can Lear...
 
Literature Review: Convey the Data in Massive Parallel Computing
Literature Review: Convey the Data in Massive Parallel ComputingLiterature Review: Convey the Data in Massive Parallel Computing
Literature Review: Convey the Data in Massive Parallel Computing
 
Graph Analytics with Greenplum and Apache MADlib
Graph Analytics with Greenplum and Apache MADlibGraph Analytics with Greenplum and Apache MADlib
Graph Analytics with Greenplum and Apache MADlib
 
Compression-based Graph Mining Exploiting Structure Primites
Compression-based Graph Mining Exploiting Structure PrimitesCompression-based Graph Mining Exploiting Structure Primites
Compression-based Graph Mining Exploiting Structure Primites
 
Optimum Relay Node Selection in Clustered MANET
Optimum Relay Node Selection in Clustered MANETOptimum Relay Node Selection in Clustered MANET
Optimum Relay Node Selection in Clustered MANET
 
Victoria A. White Head, Computing Division Fermilab
Victoria A. White Head, Computing Division FermilabVictoria A. White Head, Computing Division Fermilab
Victoria A. White Head, Computing Division Fermilab
 
H030102052055
H030102052055H030102052055
H030102052055
 
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
 
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
 
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
 
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
Comprehensive Analysis on the Vulnerability and Efficiency of P2P Networks un...
 

Mais de Kyunghoon Kim

넥스트 노멀 - 인간과 AI의 협업
넥스트 노멀 - 인간과 AI의 협업넥스트 노멀 - 인간과 AI의 협업
넥스트 노멀 - 인간과 AI의 협업Kyunghoon Kim
 
토론하는 AI 김컴재와 AI 조향사 센트리아
토론하는 AI 김컴재와 AI 조향사 센트리아토론하는 AI 김컴재와 AI 조향사 센트리아
토론하는 AI 김컴재와 AI 조향사 센트리아Kyunghoon Kim
 
빅데이터의 다음 단계는 예측 분석이다
빅데이터의 다음 단계는 예측 분석이다빅데이터의 다음 단계는 예측 분석이다
빅데이터의 다음 단계는 예측 분석이다Kyunghoon Kim
 
중학생을 위한 4차 산업혁명 시대의 인공지능 이야기
중학생을 위한 4차 산업혁명 시대의 인공지능 이야기중학생을 위한 4차 산업혁명 시대의 인공지능 이야기
중학생을 위한 4차 산업혁명 시대의 인공지능 이야기Kyunghoon Kim
 
4차 산업혁명 시대의 진로와 진학
4차 산업혁명 시대의 진로와 진학4차 산업혁명 시대의 진로와 진학
4차 산업혁명 시대의 진로와 진학Kyunghoon Kim
 
20200620 신호와 소음 독서토론
20200620 신호와 소음 독서토론20200620 신호와 소음 독서토론
20200620 신호와 소음 독서토론Kyunghoon Kim
 
중학생을 위한 인공지능 이야기
중학생을 위한 인공지능 이야기중학생을 위한 인공지능 이야기
중학생을 위한 인공지능 이야기Kyunghoon Kim
 
슬쩍 해보는 선형대수학
슬쩍 해보는 선형대수학슬쩍 해보는 선형대수학
슬쩍 해보는 선형대수학Kyunghoon Kim
 
파이썬으로 해보는 이미지 처리
파이썬으로 해보는 이미지 처리파이썬으로 해보는 이미지 처리
파이썬으로 해보는 이미지 처리Kyunghoon Kim
 
기계가 선형대수학을 통해 한국어를 이해하는 방법
기계가 선형대수학을 통해 한국어를 이해하는 방법기계가 선형대수학을 통해 한국어를 이해하는 방법
기계가 선형대수학을 통해 한국어를 이해하는 방법Kyunghoon Kim
 
공공데이터 활용사례
공공데이터 활용사례공공데이터 활용사례
공공데이터 활용사례Kyunghoon Kim
 
기계학습, 딥러닝, 인공지능 사이의 차이점 이해하기
기계학습, 딥러닝, 인공지능 사이의 차이점 이해하기기계학습, 딥러닝, 인공지능 사이의 차이점 이해하기
기계학습, 딥러닝, 인공지능 사이의 차이점 이해하기Kyunghoon Kim
 
2018 인공지능에 대하여
2018 인공지능에 대하여2018 인공지능에 대하여
2018 인공지능에 대하여Kyunghoon Kim
 
Naive bayes Classification using Python3
Naive bayes Classification using Python3Naive bayes Classification using Python3
Naive bayes Classification using Python3Kyunghoon Kim
 
Basic statistics using Python3
Basic statistics using Python3Basic statistics using Python3
Basic statistics using Python3Kyunghoon Kim
 
[20160813, PyCon2016APAC] 뉴스를 재미있게 만드는 방법; 뉴스잼
[20160813, PyCon2016APAC] 뉴스를 재미있게 만드는 방법; 뉴스잼[20160813, PyCon2016APAC] 뉴스를 재미있게 만드는 방법; 뉴스잼
[20160813, PyCon2016APAC] 뉴스를 재미있게 만드는 방법; 뉴스잼Kyunghoon Kim
 
사회 연결망의 링크 예측
사회 연결망의 링크 예측사회 연결망의 링크 예측
사회 연결망의 링크 예측Kyunghoon Kim
 

Mais de Kyunghoon Kim (20)

넥스트 노멀 - 인간과 AI의 협업
넥스트 노멀 - 인간과 AI의 협업넥스트 노멀 - 인간과 AI의 협업
넥스트 노멀 - 인간과 AI의 협업
 
토론하는 AI 김컴재와 AI 조향사 센트리아
토론하는 AI 김컴재와 AI 조향사 센트리아토론하는 AI 김컴재와 AI 조향사 센트리아
토론하는 AI 김컴재와 AI 조향사 센트리아
 
빅데이터의 다음 단계는 예측 분석이다
빅데이터의 다음 단계는 예측 분석이다빅데이터의 다음 단계는 예측 분석이다
빅데이터의 다음 단계는 예측 분석이다
 
중학생을 위한 4차 산업혁명 시대의 인공지능 이야기
중학생을 위한 4차 산업혁명 시대의 인공지능 이야기중학생을 위한 4차 산업혁명 시대의 인공지능 이야기
중학생을 위한 4차 산업혁명 시대의 인공지능 이야기
 
업무 자동화
업무 자동화업무 자동화
업무 자동화
 
4차 산업혁명 시대의 진로와 진학
4차 산업혁명 시대의 진로와 진학4차 산업혁명 시대의 진로와 진학
4차 산업혁명 시대의 진로와 진학
 
20200620 신호와 소음 독서토론
20200620 신호와 소음 독서토론20200620 신호와 소음 독서토론
20200620 신호와 소음 독서토론
 
중학생을 위한 인공지능 이야기
중학생을 위한 인공지능 이야기중학생을 위한 인공지능 이야기
중학생을 위한 인공지능 이야기
 
슬쩍 해보는 선형대수학
슬쩍 해보는 선형대수학슬쩍 해보는 선형대수학
슬쩍 해보는 선형대수학
 
파이썬으로 해보는 이미지 처리
파이썬으로 해보는 이미지 처리파이썬으로 해보는 이미지 처리
파이썬으로 해보는 이미지 처리
 
기계가 선형대수학을 통해 한국어를 이해하는 방법
기계가 선형대수학을 통해 한국어를 이해하는 방법기계가 선형대수학을 통해 한국어를 이해하는 방법
기계가 선형대수학을 통해 한국어를 이해하는 방법
 
공공데이터 활용사례
공공데이터 활용사례공공데이터 활용사례
공공데이터 활용사례
 
기계학습, 딥러닝, 인공지능 사이의 차이점 이해하기
기계학습, 딥러닝, 인공지능 사이의 차이점 이해하기기계학습, 딥러닝, 인공지능 사이의 차이점 이해하기
기계학습, 딥러닝, 인공지능 사이의 차이점 이해하기
 
Korean Text mining
Korean Text miningKorean Text mining
Korean Text mining
 
2018 인공지능에 대하여
2018 인공지능에 대하여2018 인공지능에 대하여
2018 인공지능에 대하여
 
Naive bayes Classification using Python3
Naive bayes Classification using Python3Naive bayes Classification using Python3
Naive bayes Classification using Python3
 
Basic statistics using Python3
Basic statistics using Python3Basic statistics using Python3
Basic statistics using Python3
 
[20160813, PyCon2016APAC] 뉴스를 재미있게 만드는 방법; 뉴스잼
[20160813, PyCon2016APAC] 뉴스를 재미있게 만드는 방법; 뉴스잼[20160813, PyCon2016APAC] 뉴스를 재미있게 만드는 방법; 뉴스잼
[20160813, PyCon2016APAC] 뉴스를 재미있게 만드는 방법; 뉴스잼
 
Topic Modeling
Topic ModelingTopic Modeling
Topic Modeling
 
사회 연결망의 링크 예측
사회 연결망의 링크 예측사회 연결망의 링크 예측
사회 연결망의 링크 예측
 

Último

Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 

Último (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 

Network Analysis with networkX : Fundamentals of network theory-1

  • 1. Kyunghoon Kim Network Analysis with networkX Fundamentals of network theory-1 2014. 05. 14. UNIST Mathematical Sciences Kyunghoon Kim ( Kyunghoon@unist.ac.kr ) 5/14/2014 Fundamentals of network theory-1 1
  • 2. Kyunghoon Kim ● A NETWORK is, in its simplest form, a collection of points joined together in pairs by lines. What is a Network? Newman, Mark. Networks: an introduction. OUP Oxford, 2009. 5/14/2014 Fundamentals of network theory-1 2
  • 3. Kyunghoon Kim ● A NETWORK is, in its simplest form, a collection of points joined together in pairs by lines. ● Network is general, but powerful means of representing patterns of connections or interactions between the parts of a system. What is a Network? Newman, Mark. Networks: an introduction. OUP Oxford, 2009. 5/14/2014 Fundamentals of network theory-1 3
  • 4. Kyunghoon Kim What is a Network? Shipping (sea) networksTelecommunications networks Air traffic networkData networks Source: Britain From Above (http://www.bbc.co.uk/britainfromabove) 5/14/2014 Fundamentals of network theory-1 4
  • 5. Kyunghoon Kim ● Network thinking can be applied almost anywhere! What is a Network? 5/14/2014 Fundamentals of network theory-1 5
  • 6. Kyunghoon Kim ● Network thinking can be applied almost anywhere! Example of Network Thinking http://journals.uic.edu/ojs/index.php/fm/article/view/941/863 My data sources were publicly released information reported in major newspapers such as the New York Times, Wall Street Journal, Washington Post, and the Los Angeles Times. As I monitored the investigation, it was apparent that the investigators would not be releasing all pertinent network/relationship information and actually may be releasing misinformation to fool the enemy. I soon realized that the data was not going to be as complete and accurate as I had grown accustomed to in mapping and measuring organizational networks. 5/14/2014 Fundamentals of network theory-1 6
  • 7. Kyunghoon Kim Example of Network Thinking http://www.orgnet.com/hijackers.html 5/14/2014 Fundamentals of network theory-1 7
  • 8. Kyunghoon Kim Example of Network Thinking 5/14/2014 Fundamentals of network theory-1 8
  • 9. Kyunghoon Kim Example of Network Thinking Six (6) shortcuts were added to the network temporarily in order to collaborate and coordinate. These shortcuts reduced the average path length in the network by over 40% thus improving the information flow in the network - see Table 1. When the network is brought closer together by these shortcuts, all of the pilots ended up in a small clique - the perfect structure to efficiently coordinate tasks and activities. There is a constant dynamic between keeping the network hidden and actively using it to accomplish objectives (Baker and Faulkner, 1993). 5/14/2014 Fundamentals of network theory-1 9
  • 10. Kyunghoon Kim Example of Network Thinking 5/14/2014 Fundamentals of network theory-1 10
  • 11. Kyunghoon Kim Example of Network Thinking 5/14/2014 Fundamentals of network theory-1 11
  • 12. Kyunghoon Kim Example of Network Thinking Saddam Hussein 5/14/2014 Fundamentals of network theory-1 12
  • 13. Kyunghoon Kim Example of Network Thinking 5/14/2014 Fundamentals of network theory-1 13
  • 14. Kyunghoon Kim Example of Network Thinking 5/14/2014 Fundamentals of network theory-1 14
  • 15. An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 15 Where’s it applied? Epidemiology (i.e. spread of diseases) e.g. spread of foot & mouth disease in the UK in 2001 over 75 days URL: http://www.youtube.com/watch?v=PufTeIBNRJ4
  • 16. An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 16 Physics e.g. particle interactions, the structure of the universe Where’s it applied? URL: http://www.youtube.com/watch?v=8C_dnP2fvxk
  • 17. An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 17 Engineering e.g. creation of robust infrastructure (e.g. electricity, telecoms), rust formation (natural growth processes similar to diffusion limited aggregation) Where’s it applied? URL: http://www.youtube.com/watch?v=lRZ2iEHFgGo URL: http://www.youtube.com/watch?v=AEoP-XtJueo
  • 18. An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 18 Technology e.g. mapping the online world, making networks resilient in the face of cyber-terrorism, optimising cellular networks, controlling air traffic Where’s it applied? URL: http://www.youtube.com/watch?v=l-RoDv7c5ok URL: http://www.youtube.com/watch?v=o4g930pm8Ms Vid not working
  • 19. An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 19 Where’s it applied? Biology e.g. fish swimming in schools, ant colonies, birds flying in formation, crickets chirping in unison, giant honeybees shimmering URL: http://www.youtube.com/watch?v=Sp8tLPDMUygURL: http://www.youtube.com/watch?v=YadP3w7vkJA
  • 20. An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 20 Medicine e.g. cell formation, nervous system, neural networks Where’s it applied? Source: The Human Brain Book by Rita Carter
  • 21. An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 | 21 And, most interestingly…society e.g. interactions between people (e.g. Facebook; group behaviour) Where’s it applied? URL: http://www.youtube.com/watch?v=9n9irapdON4 URL: http://www.youtube.com/watch?v=sD2yosZ9qDw
  • 22. Kyunghoon Kim ● A network – also called a graph in the mathematical literature – is, as we have said, a collection of vertices joined by edges. Networks and their Representation Area Object Relation Graph Theory Vertices Edges Computer Science Nodes Links Physics Sites Bonds Sociology Actors Ties 5/14/2014 Fundamentals of network theory-1 22
  • 23. Kyunghoon Kim Networks and their Representation Figure 6.1: Two small networks. (a) A simple graph, i.e., one having no multiedges or self-edges. (b) A network with both multiedges and self-edges. Newman, Mark. Networks: an introduction. OUP Oxford, 2009. 5/14/2014 Fundamentals of network theory-1 23
  • 24. Kyunghoon Kim Networks and their Representation 𝐴𝐴𝑖𝑖𝑖𝑖 = � 1 0 𝑖𝑖𝑖𝑖 𝑡𝑡 𝑡𝑡𝑡𝑡𝑡𝑡𝑡 𝑖𝑖𝑖𝑖 𝑎𝑎𝑎𝑎 𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏 𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣𝑣 𝑖𝑖 𝑎𝑎𝑎𝑎𝑎𝑎 𝑗𝑗, 𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜. 5/14/2014 Fundamentals of network theory-1 24
  • 25. Kyunghoon Kim ● import networkx as nx G = nx.Graph() G.add_node(1) G.add_nodes_from([1,2,3,4,5]) G.nodes() ● >>> [1, 2, 3, 4, 5] Networks and their Representation 5/14/2014 Fundamentals of network theory-1 25
  • 26. Kyunghoon Kim ● G.add_edge(1,2) G.add_edges_from([(1,2),(2,4),(2,5),(3,4)]) G.edges() ● >>> [(1, 2), (2, 4), (2, 5), (3, 4)] Networks and their Representation 5/14/2014 Fundamentals of network theory-1 26
  • 27. Kyunghoon Kim ● nx.to_numpy_matrix(G) ● matrix([[ 0., 1., 0., 0., 0.], [ 1., 0., 0., 1., 1.], [ 0., 0., 0., 1., 0.], [ 0., 1., 1., 0., 0.], [ 0., 1., 0., 0., 0.]])  nx.draw(G) Networks and their Representation 5/14/2014 Fundamentals of network theory-1 27
  • 28. Kyunghoon Kim Networks and their Representation 5/14/2014 Fundamentals of network theory-1 28
  • 29. Kyunghoon Kim Networks and their Representation = 𝐴𝐴 = 5/14/2014 Fundamentals of network theory-1 29
  • 30. Kyunghoon Kim Networks and their Representation 5/14/2014 Fundamentals of network theory-1 30
  • 33. Kyunghoon Kim Degree 𝑘𝑘𝑖𝑖 = � 𝑗𝑗=1 𝑛𝑛 𝐴𝐴𝑖𝑖𝑖𝑖 𝑘𝑘2 = � 𝑗𝑗=1 5 𝐴𝐴1𝑗𝑗 = 3 5/14/2014 Fundamentals of network theory-1 33
  • 35. Kyunghoon Kim Degree 𝑘𝑘𝑖𝑖 = � 𝑗𝑗=1 𝑛𝑛 𝐴𝐴𝑖𝑖𝑖𝑖 2𝑚𝑚 = � 𝑖𝑖=1 𝑛𝑛 𝑘𝑘𝑖𝑖 5/14/2014 Fundamentals of network theory-1 35
  • 36. Kyunghoon Kim Total Degree m 𝑘𝑘𝑖𝑖 = � 𝑗𝑗=1 𝑛𝑛 𝐴𝐴𝑖𝑖𝑖𝑖 2𝑚𝑚 = � 𝑖𝑖=1 𝑛𝑛 𝑘𝑘𝑖𝑖 𝑚𝑚 = 1 2 � 𝑖𝑖=1 𝑛𝑛 𝑘𝑘𝑖𝑖 = 1 2 � 𝑖𝑖𝑖𝑖 𝐴𝐴𝑖𝑖𝑖𝑖 5/14/2014 Fundamentals of network theory-1 36
  • 37. Kyunghoon Kim Total Degree m 𝑘𝑘𝑖𝑖 = � 𝑗𝑗=1 𝑛𝑛 𝐴𝐴𝑖𝑖𝑖𝑖 2𝑚𝑚 = � 𝑖𝑖=1 𝑛𝑛 𝑘𝑘𝑖𝑖 𝑚𝑚 = 1 2 � 𝑖𝑖=1 𝑛𝑛 𝑘𝑘𝑖𝑖 = 1 2 � 𝑖𝑖𝑖𝑖 𝐴𝐴𝑖𝑖𝑖𝑖 𝑛𝑛 5/14/2014 Fundamentals of network theory-1 37
  • 38. Kyunghoon Kim Mean Degree c 𝑘𝑘𝑖𝑖 = � 𝑗𝑗=1 𝑛𝑛 𝐴𝐴𝑖𝑖𝑖𝑖 2𝑚𝑚 = � 𝑖𝑖=1 𝑛𝑛 𝑘𝑘𝑖𝑖 𝑐𝑐 = 1 𝑛𝑛 � 𝑖𝑖=1 𝑛𝑛 𝑘𝑘𝑖𝑖 = 2𝑚𝑚 𝑛𝑛 5/14/2014 Fundamentals of network theory-1 38
  • 39. Kyunghoon Kim Mean Degree c 𝑐𝑐 = 1 𝑛𝑛 � 𝑖𝑖=1 𝑛𝑛 𝑘𝑘𝑖𝑖 = 2𝑚𝑚 𝑛𝑛 >>> G.degree() {1: 1, 2: 3, 3: 1, 4: 2, 5: 1} >>> G.degree(2) 3 >>> Degree = G.degree().values() [1, 3, 1, 2, 1] >>> sum(Degree)/len(G.nodes()) 1.6000000000000001 5/14/2014 Fundamentals of network theory-1 39
  • 40. Kyunghoon Kim Density or connectance of a graph 𝑛𝑛 2 = 1 2 𝑛𝑛(𝑛𝑛 − 1) in a simple graph(i.e., one with no multiedges or self-edges) 5/14/2014 Fundamentals of network theory-1 40
  • 41. Kyunghoon Kim Density or connectance of a graph 𝜌𝜌 = 𝑚𝑚 𝑛𝑛 2 = 2𝑚𝑚 𝑛𝑛(𝑛𝑛 − 1) = 𝑐𝑐 𝑛𝑛 − 1 𝑛𝑛 2 = 1 2 𝑛𝑛(𝑛𝑛 − 1) 5/14/2014 Fundamentals of network theory-1 41
  • 42. Kyunghoon Kim Density or connectance of a graph 𝜌𝜌 = 𝑚𝑚 𝑛𝑛 2 = 2𝑚𝑚 𝑛𝑛(𝑛𝑛 − 1) = 𝑐𝑐 𝑛𝑛 − 1 >>> total = 0.5*5*(5-1) >>> 4/total 0.4 >>> nx.density(G) 0.4 5/14/2014 Fundamentals of network theory-1 42
  • 43. Kyunghoon Kim ● The in-degree is the # of ingoing edges connected to a vertex. ● The out-degree is the # of outgoing edges connected to a vertex. ● 𝐴𝐴𝑖𝑖𝑖𝑖 = 1 if there is an edge from 𝑗𝑗 to 𝑖𝑖. In-degree and out-degree 𝑘𝑘𝑖𝑖 𝑖𝑖 𝑖𝑖 = � 𝑗𝑗=1 𝑛𝑛 𝐴𝐴𝑖𝑖𝑖𝑖 𝑘𝑘𝑖𝑖 𝑜𝑜𝑜𝑜𝑜𝑜 = � 𝑖𝑖=1 𝑛𝑛 𝐴𝐴𝑖𝑖𝑖𝑖 5/14/2014 Fundamentals of network theory-1 43
  • 44. Kyunghoon Kim ● A path in a network is any sequence of vertices such that every consecutive pair of vertices in the sequence is connected by an edge in the network. Paths 5/14/2014 Fundamentals of network theory-1 44
  • 45. Kyunghoon Kim ● A path in a network is any sequence of vertices such that every consecutive pair of vertices in the sequence is connected by an edge in the network. ● A path is a route across the network that runs from vertex to vertex along the edges of the network. Paths 5/14/2014 Fundamentals of network theory-1 45
  • 46. Kyunghoon Kim ● The length of a path in a network is the # of edges traversed along the path (not the # of vertices). Length of Paths 5/14/2014 Fundamentals of network theory-1 46
  • 47. Kyunghoon Kim ● The length of a path in a network is the # of edges traversed along the path (not the # of vertices). ● 𝐴𝐴𝑖𝑖𝑖𝑖 = 1 if there is an edge from 𝑗𝑗 to 𝑖𝑖, and 0 otherwise. Length of Paths 5/14/2014 Fundamentals of network theory-1 47
  • 48. Kyunghoon Kim ● The length of a path in a network is the # of edges traversed along the path (not the # of vertices). ● 𝐴𝐴𝑖𝑖𝑖𝑖 = 1 if there is an edge from 𝑗𝑗 to 𝑖𝑖, and 0 otherwise. Length of Paths 𝑁𝑁𝑖𝑖𝑖𝑖 (2) = � 𝑘𝑘=1 𝑛𝑛 𝐴𝐴𝑖𝑖 𝑖𝑖 𝐴𝐴𝑘𝑘𝑘𝑘 = 𝐀𝐀2 𝑖𝑖𝑖𝑖 5/14/2014 Fundamentals of network theory-1 48
  • 49. Kyunghoon Kim ● The length of a path in a network is the # of edges traversed along the path (not the # of vertices). ● 𝐴𝐴𝑖𝑖𝑖𝑖 = 1 if there is an edge from 𝑗𝑗 to 𝑖𝑖, and 0 otherwise. i ← k , k ←j Length of Paths 𝑁𝑁𝑖𝑖𝑖𝑖 (2) = � 𝑘𝑘=1 𝑛𝑛 𝐴𝐴𝑖𝑖 𝑖𝑖 𝐴𝐴𝑘𝑘𝑘𝑘 = 𝐀𝐀2 𝑖𝑖𝑖𝑖 5/14/2014 Fundamentals of network theory-1 49
  • 50. Kyunghoon Kim ● The length of a path in a network is the # of edges traversed along the path (not the # of vertices). ● 𝐴𝐴𝑖𝑖𝑖𝑖 = 1 if there is an edge from 𝑗𝑗 to 𝑖𝑖, and 0 otherwise. Length of Paths 𝑁𝑁𝑖𝑖𝑖𝑖 (2) = � 𝑘𝑘=1 𝑛𝑛 𝐴𝐴𝑖𝑖 𝑖𝑖 𝐴𝐴𝑘𝑘𝑘𝑘 = 𝐀𝐀2 𝑖𝑖𝑖𝑖 𝑁𝑁𝑖𝑖𝑖𝑖 (3) = � 𝑘𝑘,𝑙𝑙=1 𝐴𝐴𝑖𝑖 𝑖𝑖 𝐴𝐴𝑘𝑘𝑙𝑙 𝐴𝐴𝑙𝑙𝑗𝑗 = 𝐀𝐀3 𝑖𝑖𝑖𝑖 5/14/2014 Fundamentals of network theory-1 50
  • 51. Kyunghoon Kim ● import numpy as np matrix = nx.to_numpy_matrix(G) matrix*np.transpose(matrix) matrix([[ 1., 0., 0., 1., 1.], [ 0., 3., 1., 0., 0.], [ 0., 1., 1., 0., 0.], [ 1., 0., 0., 2., 1.], [ 1., 0., 0., 1., 1.]]) Length of Paths 𝑁𝑁𝑖𝑖𝑖𝑖 (2) = � 𝑘𝑘=1 𝑛𝑛 𝐴𝐴𝑖𝑖 𝑖𝑖 𝐴𝐴𝑘𝑘𝑘𝑘 = 𝐀𝐀2 𝑖𝑖𝑖𝑖 5/14/2014 Fundamentals of network theory-1 51
  • 53. Kyunghoon Kim ● A shortest path is a path between two vertices such that no shorter path exists: Shortest path (Geodesic path) Newman, Mark. Networks: an introduction. OUP Oxford, 2009. 5/14/2014 Fundamentals of network theory-1 53
  • 54. Kyunghoon Kim ● A shortest path is a path between two vertices such that no shorter path exists: ● Shortest paths are necessarily self-avoiding. ● Shortest paths are not necessarily unique. Shortest path (Geodesic path) Newman, Mark. Networks: an introduction. OUP Oxford, 2009. 5/14/2014 Fundamentals of network theory-1 54
  • 55. Kyunghoon Kim ● The shortest distance between vertices 𝑖𝑖 and 𝑗𝑗 is the smallest value of 𝑟𝑟 such that 𝐀𝐀𝑟𝑟 𝑖𝑖𝑖𝑖 > 0. Shortest distance (Geodesic distance) 5/14/2014 Fundamentals of network theory-1 55
  • 56. Kyunghoon Kim ● The shortest distance between vertices 𝑖𝑖 and 𝑗𝑗 is the smallest value of 𝑟𝑟 such that 𝐀𝐀𝑟𝑟 𝑖𝑖𝑖𝑖 > 0. ● However, in practical case we use Dijkstra’s algorithm. We will study it later. Shortest distance (Geodesic distance) 5/14/2014 Fundamentals of network theory-1 56
  • 57. Kyunghoon Kim ● The diameter of a graph is the length of the longest geodesic path between any pair of vertices in the network for which a path actually exists. Diameter of a graph 5/14/2014 Fundamentals of network theory-1 57
  • 58. Kyunghoon Kim ● Which are the most important or central vertices in a network? Measures and Metrics 5/14/2014 Fundamentals of network theory-1 58
  • 59. Kyunghoon Kim ● Which are the most important or central vertices in a network? ● Degree centrality, Closeness centrality, Betweenness centrality, Eigenvector centrality, Pagerank, Similarity… Measures and Metrics 5/14/2014 Fundamentals of network theory-1 59
  • 60. Kyunghoon Kim ● Degree is sometimes called degree centrality in the social networks literature. ● In directed networks, vertices have both an in- degree and an out-degree, and both may be useful as measures of centrality in the appropriate circumstances. Degree Centrality 5/14/2014 Fundamentals of network theory-1 60
  • 61. Kyunghoon Kim Degree Centrality 5/14/2014 Fundamentals of network theory-1 61
  • 62. Kyunghoon Kim Clustering Coefficient (local) ● For a vertex 𝑖𝑖, we define : 𝐶𝐶𝑖𝑖 = (𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑜𝑜𝑜𝑜 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 𝑜𝑜𝑜𝑜 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑜𝑜𝑜𝑜 𝑖𝑖 𝑡𝑡 𝑡𝑡𝑡𝑡𝑡 𝑎𝑎𝑎𝑎𝑎𝑎 𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐) (𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑜𝑜𝑜𝑜 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 𝑜𝑜𝑜𝑜 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑜𝑜𝑜𝑜 𝑖𝑖) 5/14/2014 Fundamentals of network theory-1 62
  • 63. Kyunghoon Kim Clustering Coefficient (local) ● >>> nx.clustering(G) ● {1: 0.0, 2: 0.3333, 3: 0.6666, 4: 1.0, 5: 1.0} 𝐶𝐶2 = 2 4 2 = 1 3 = 0.3333 5/14/2014 Fundamentals of network theory-1 63
  • 64. Kyunghoon Kim Clustering Coefficient (local) 5/14/2014 Fundamentals of network theory-1 64 “Unclustered” network “Clustered” network None of Ego’s friends know each other* All of Ego’s friends know each other An Introduction to Network Theory | Kyle Findlay | SAMRA 2010
  • 65. Kyunghoon Kim Clustering Coefficient (local) 5/14/2014 Fundamentals of network theory-1 65 – A real-world example: CEOs of Fortune 500 companies • Which companies share directors? Clusters are colour-coded An Introduction to Network Theory | Kyle Findlay | SAMRA 2010
  • 66. Kyunghoon Kim ● This measures the mean distance from a vertex to other vertices. ● Suppose 𝑑𝑑𝑖𝑖𝑖𝑖 is the length of a geodesic path from 𝑖𝑖 to 𝑗𝑗, meaning the # of edges along the path. Closeness Centrality 5/14/2014 Fundamentals of network theory-1 66
  • 67. Kyunghoon Kim ● This measures the mean distance from a vertex to other vertices. ● Suppose 𝑑𝑑𝑖𝑖𝑖𝑖 is the length of a geodesic path from 𝑖𝑖 to 𝑗𝑗, meaning the # of edges along the path. ● The mean shortest distance from 𝑖𝑖 to 𝑗𝑗, averaged over all vertices 𝑗𝑗 in the network, is Closeness Centrality 𝑙𝑙𝑖𝑖 = 1 𝑛𝑛 � 𝑗𝑗 𝑑𝑑𝑖𝑖𝑖𝑖 5/14/2014 Fundamentals of network theory-1 67
  • 68. Kyunghoon Kim ● Exclude for 𝑗𝑗 = 𝑖𝑖, Closeness Centrality 𝑙𝑙𝑖𝑖 = 1 𝑛𝑛 − 1 � 𝑗𝑗(≠𝑖𝑖) 𝑑𝑑𝑖𝑖𝑖𝑖 𝑙𝑙𝑖𝑖 = 1 𝑛𝑛 � 𝑗𝑗 𝑑𝑑𝑖𝑖𝑖𝑖 5/14/2014 Fundamentals of network theory-1 68
  • 69. Kyunghoon Kim ● This quantity takes low values for vertices that are separated from others by only a short shortest distance on average. ● which is the opposite of other measures. ● So commonly we take inverse : Closeness Centrality 𝐶𝐶𝑖𝑖 = 1 𝑙𝑙𝑖𝑖 = 𝑛𝑛 ∑𝑗𝑗 𝑑𝑑𝑖𝑖𝑖𝑖 5/14/2014 Fundamentals of network theory-1 69
  • 70. Kyunghoon Kim >>> nx.closeness_centrality(G) {1: 0.5714, 2: 1.0, 3: 0.8, 4: 0.6666, 5: 0.6666} Closeness Centrality 𝐶𝐶𝑖𝑖 = 1 𝑙𝑙𝑖𝑖 = 𝑛𝑛 ∑𝑗𝑗 𝑑𝑑𝑖𝑖𝑖𝑖 𝐶𝐶1 = 4 ∑𝑗𝑗 𝑑𝑑1𝑗𝑗 = 4 1 + 2 + 2 + 2 = 0.5714 5/14/2014 Fundamentals of network theory-1 70
  • 71. Kyunghoon Kim ● This measures the extent to which a vertex lies on paths between other vertices. Betweenness Centrality 5/14/2014 Fundamentals of network theory-1 71
  • 72. Kyunghoon Kim ● This measures the extent to which a vertex lies on paths between other vertices. ● For example, assume that every pair of vertices exchanges a message with equal probability per unit time and that messages always take the shortest path. Betweenness Centrality 5/14/2014 Fundamentals of network theory-1 72
  • 73. Kyunghoon Kim ● For example, assume that every pair of vertices exchanges a message with equal probability per unit time and that messages always take the shortest path. ● Question : if we wait a suitably long time until many messages have passed between each pair of vertices, how many messages, on average, will have passed through each vertex en route to their destination? Betweenness Centrality 5/14/2014 Fundamentals of network theory-1 73
  • 74. Kyunghoon Kim ● Question : if we wait a suitably long time until many messages have passed between each pair of vertices, how many messages, on average, will have passed through each vertex en route to their destination? ● Answer : since messages are passing down each shortest path at the same rate, the number passing through each vertex is simply proportional to the # of shortest paths the vertex lies on. Betweenness Centrality 5/14/2014 Fundamentals of network theory-1 74
  • 75. Kyunghoon Kim ● Let 𝑛𝑛𝑠𝑠𝑠𝑠 𝑖𝑖 be 1 if vertex 𝑖𝑖 lies on the shortest path from 𝑠𝑠 to 𝑡𝑡 and 0 if it does not or if there is no such path. ● The betweenness centrality 𝑥𝑥𝑖𝑖 is given by Betweenness Centrality 𝑥𝑥𝑖𝑖 = � 𝑠𝑠𝑡𝑡 𝑛𝑛𝑠𝑠𝑠𝑠 𝑖𝑖 5/14/2014 Fundamentals of network theory-1 75
  • 76. Kyunghoon Kim ● Note that the shortest paths between a pair of vertices need not be vertex independent, meaning they may pass through some of the same vertices. ● Define 𝑔𝑔𝑠𝑠𝑠𝑠 to be the total # of shortest paths from 𝑠𝑠 to 𝑡𝑡 . where 𝑛𝑛𝑠𝑠𝑠𝑠 𝑖𝑖 𝑔𝑔𝑠𝑠𝑠𝑠 = 0 if both 𝑛𝑛𝑠𝑠𝑠𝑠 𝑖𝑖 and 𝑔𝑔𝑠𝑠𝑠𝑠 are zero. Betweenness Centrality 𝑥𝑥𝑖𝑖 = � 𝑠𝑠𝑡𝑡 𝑛𝑛𝑠𝑠𝑠𝑠 𝑖𝑖 𝑔𝑔𝑠𝑠𝑠𝑠 5/14/2014 Fundamentals of network theory-1 76
  • 77. Kyunghoon Kim >>> nx.betweenness_centrality(G) {1: 0.0, 2: 0.5833, 3: 0.0833, 4: 0.0, 5: 0.0} Betweenness Centrality 𝑥𝑥𝑖𝑖 = � 𝑠𝑠𝑡𝑡 𝑛𝑛𝑠𝑠𝑠𝑠 𝑖𝑖 𝑔𝑔𝑠𝑠𝑠𝑠 𝑥𝑥1 = � 𝑠𝑠𝑡𝑡 𝑛𝑛𝑠𝑠𝑠𝑠 1 𝑔𝑔𝑠𝑠𝑠𝑠 5/14/2014 Fundamentals of network theory-1 77
  • 78. Kyunghoon Kim >>> nx.betweenness_centrality(G) {1: 0.0, 2: 0.5833, 3: 0.0833, 4: 0.0, 5: 0.0} g = nx.Graph() g.add_edges_from([(1,2),(2,3),(2,4),(2,5),(3,4),(3,5)])end = 6 for i in range(1,end): for j in range(1,end): #print 'from', i, 'to', j print([p for p in nx.all_shortest_paths(g,i,j) if len(p)>2]) #print nx.dijkstra_path(g,i,j) #print '==============' nx.betweenness_centrality(g, normalized=False) plt.cla() nx.draw(g) Betweenness Centrality 𝑥𝑥2 = � 𝑠𝑠𝑡𝑡 𝑛𝑛𝑠𝑠𝑠𝑠 2 𝑔𝑔𝑠𝑠𝑠𝑠 = 3 + 1 2 5/14/2014 Fundamentals of network theory-1 78
  • 79. Kyunghoon Kim >>> nx.betweenness_centrality(G) {1: 0.0, 2: 0.5833, 3: 0.0833, 4: 0.0, 5: 0.0} [[1, 2, 3]] [[1, 2, 4]] [[1, 2, 5]] [[3, 2, 1]] [[4, 2, 1]] [[4, 2, 5], [4, 3, 5]] [[5, 2, 1]] [[5, 2, 4], [5, 3, 4]] Betweenness Centrality 𝑥𝑥2 = � 𝑠𝑠𝑡𝑡 𝑛𝑛𝑠𝑠𝑠𝑠 2 𝑔𝑔𝑠𝑠𝑠𝑠 = 3 + 1 2 5/14/2014 Fundamentals of network theory-1 79
  • 80. Kyunghoon Kim >>> nx.betweenness_centrality(G) {1: 0.0, 2: 0.5833, 3: 0.0833, 4: 0.0, 5: 0.0} To normalize, we use the following equation, 2 (𝑛𝑛−1)(𝑛𝑛−2) Then, Betweenness Centrality 𝑥𝑥2 = 2 4 × 3 � 𝑠𝑠𝑡𝑡 𝑛𝑛𝑠𝑠𝑠𝑠 2 𝑔𝑔𝑠𝑠𝑠𝑠 = 1 6 3 + 1 2 = 0.5833 5/14/2014 Fundamentals of network theory-1 80
  • 82. Kyunghoon Kim ● nx.draw_spring(G) ● nx.to_numpy_matrix(G) Appendix 5/14/2014 Fundamentals of network theory-1 82
  • 83. Kyunghoon Kim ● Newman, Mark. Networks: an introduction. OUP Oxford, 2009. ● An Introduction to Network Theory | Kyle Findlay | SAMRA 2010 ● http://journals.uic.edu/ojs/index.php/fm/articl e/view/941/863 ● http://www.orgnet.com/hijackers.html Reference 5/14/2014 Fundamentals of network theory-1 83