Gephi Python code Use Metricspy from the workshops website 2 NetworkX Reference PDF reference for NetworkX Github interactive version 3 Finding centralities The part of the code that finds ID: 743669
Download Presentation The PPT/PDF document "Central Nodes (Python and" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Central Nodes
(Python and
Gephi)Slide2
Python code
Use Metrics.py from the workshop’s website
2Slide3
NetworkX Reference
PDF reference for NetworkXGithub interactive version
3Slide4
Finding centralities
The part of thecode that finds and printscentralities:Output not sorted,
rather a list as:
Node
:
centrality_value
4Slide5
Follow along or try it
Follow along:http://faculty.nps.edu/rgera/MA4404/PythonCode/MetricsV2.htmlOr
try the code on your computer
, the same zip file from the main page, and use
MetricsV2-ForPython3.py (for version 3.5) or MetricsV2-ForPython2.py
(for version 2.7)
5Slide6
Top centrality nodes Cod: MetricsV2-ForPython2 (or 3)
This part of the code arranges and prints the top 10 central nodes (degree centrality)Python 2.7:
Python 3.5:
The ten was arbitrary, change it here:
6Slide7
Closeness/Eigenvector
The closeness centrality is normalized by dividing by (n-1), where n is the number of nodes in the connected part of graph containing the node. If the graph is not completely connected, this algorithm computes the closeness centrality for each connected part separately
.
The eigenvector calculation is done by the power iteration method and has no guarantee of convergence. The iteration will stop after
max_iter
iterations or an error tolerance of
number_of_nodes(G)*
tol has been reached. For directed graphs this is “left”
eigevector
centrality which corresponds to the in-edges in the graph. For out-edges eigenvector centrality first reverse the graph with
G.reverse
().
7
https
://
networkx.github.io/documentation/networkx-1.9/reference/generated/networkx.algorithms.centrality.eigenvector_centrality.html#networkx.algorithms.centrality.eigenvector_centralitySlide8
Visualizing them on the network
Code that identifies the top 30%:http://glowingpython.blogspot.com/2013/02/betweenness-centrality.html
I have not
implemented
it, you can try
it if you would
like.
8Slide9
Gephi
Excellence Through KnowledgeSlide10
Resources for Gephi:
Overview and explanations of GephiGephi’s
overview
tutorial
An
introductory video to create data for Gephi
and to use degree, closeness and betweeness (also posted on the website
unde today’s lecture).Gephi’s
overview of layouts
Basic navigationSlide11
Layouts
Choose the appropriate layout so that visualization is meaningful. Common force directed (repulsion) ones:Force Atalas
2 (It
is focused on
being
useful to explore and get meaning for real
data, and a good readability, slow)
Yifan Hu (similar to FA2, fast, good for large graphs)Fruchterman-Reingold (The
nodes are the mass particles and the edges are springs between the particles. The algorithms try to minimize the energy of this physical system. It has become a standard but remains very slow
.)
OpenOrd
layout (good for communities)
Not force directed:
Expansion
Geographic
map with
GeoLayout
11Slide12
SAVE
Once you have a visualization that you like, save the network, so that the next time you open it looks the sameCannot use undo in Gephi
When you run an analysis, save the network again with a different name for future references
When you open part of a network on a new tab in
Gephi
, save that as well.
12Slide13
Preview Tab
Click Preview next to the Data
Laboratory
, you
might like that
view of the
network better:If you export, then this is what
you export:
13Slide14
Centrality graph example
14
Source: Discovering Sets of Key Players in Social Networks – Daniel Ortiz-Arroyo – Springer 2010/
Open both your network and
this graph
(you can also find it on the
website
).Slide15
Centralities
Click diameter under Statisticsmodule on the rightCentralities that are available:
Closeness
PageRank
HITS
BetweenessFor directed
graphs, check:
15Slide16
Ranking nodes by centrality
Once you ran a metric, you can size/color the nodes based on your choices you ran.Under on the topleft, choose
Nodes
and
either
size or
colorDepending on the version you run, you will see:
16Slide17
Filtering nodes by centralty
Find Filters on the top right, next to Statistics
Under topology, you can find
the centralities
Choose one, drag and drop
it to the Queries
Choose the bounds needed.
17Slide18
Export
You can export the visualized graph as SVG or PDF:Go to preview (fix if needed)Resize for large networksClick SVG
(SVG is
vectorial
graphics like PDF so they scale to different sizes nicely)
18Slide19
Other metrics
19
Average path length: under
the statics module, right
Computes the average of
shortest paths between all
pairs of nodes Result:Slide20
Most of these are not in Gephi/Python/R
20
An interactive periodic table of centralities:
http://
schochastics.net/sna/periodic.html