Central nodes Python and Gephi Python code Use

  • Slides: 20
Download presentation
Central nodes (Python and Gephi)

Central nodes (Python and Gephi)

Python code • Use Metrics. py from the workshop’s website 2

Python code • Use Metrics. py from the workshop’s website 2

Network. X Reference PDF reference for Network. X Github interactive version 3

Network. X Reference PDF reference for Network. X Github interactive version 3

Finding centralities • The part of the code that finds and prints centralities: •

Finding centralities • The part of the code that finds and prints centralities: • Output not sorted, rather a list as: Node: centrality_value 4

Follow along or try it • Follow along: http: //faculty. nps. edu/rgera/MA 4404/Python. Code/

Follow along or try it • Follow along: http: //faculty. nps. edu/rgera/MA 4404/Python. Code/ Metrics. V 2. html • Or try the code on your computer, the same zip file from the main page, and use Metrics. V 2 -For. Python 3. py (for version 3. 5) or Metrics. V 2 -For. Python 2. py (for version 2. 7) 5

Top centrality nodes Cod: Metrics. V 2 -For. Python 2 (or 3) • This

Top centrality nodes Cod: Metrics. V 2 -For. Python 2 (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: 6

Closeness/Eigenvector • The closeness centrality is normalized by dividing by (n-1), where n is

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_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(). https: //networkx. github. io/documentation/networkx 1. 9/reference/generated/networkx. algorithms. centrality. eigenvector_centrality. html#netwo 7 rkx. algorithms. centrality. eigenvector_centrality

Visualizing them on the network • Code that identifies the top 30%: http: //glowingpython.

Visualizing them on the network • Code that identifies the top 30%: http: //glowingpython. blogspot. com/2013/02/betwee nness-centrality. html I have not implemented it, you can try it if you would like. 8

GEPHI Excellence Through Knowledge

GEPHI Excellence Through Knowledge

Resources for Gephi: • Overview and explanations of Gephi • Gephi’s overview tutorial •

Resources for Gephi: • Overview and explanations of Gephi • Gephi’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 navigation

Layouts • Choose the appropriate layout so that visualization is meaningful. Common force directed

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 FA 2, 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. ) – Open. Ord layout (good for communities) Not force directed: – Expansion – Geographic map with Geo. Layout 11

SAVE • Once you have a visualization that you like, save the network, so

SAVE • Once you have a visualization that you like, save the network, so that the next time you open it looks the same • Cannot 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. 12

Preview Tab • Click Preview next to the Data Laboratory, you might like that

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: 13

Centrality graph example Open both your network and this graph (you can also find

Centrality graph example Open both your network and this graph (you can also find it on the website or dropbox). Source: Discovering Sets of Key Players in Social Networks – Daniel Ortiz-Arroyo – Springer 2010/ 14

Centralities • Click diameter under Statistics module on the right • Centralities that are

Centralities • Click diameter under Statistics module on the right • Centralities that are available: – – Closeness Page. Rank HITS Betweeness • For directed graphs, check: 15

Ranking nodes by centrality • Once you ran a metric, you can size/color the

Ranking nodes by centrality • Once you ran a metric, you can size/color the nodes based on your choices you ran. • Under on the top left, choose Nodes and either size or color • Depending on the version you run, you will see: 16

Filtering nodes by centralty • Find Filters on the top right, next to Statistics

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. 17

Export • You can export the visualized graph as SVG or PDF: – Go

Export • You can export the visualized graph as SVG or PDF: – Go to preview (fix if needed) – Resize for large networks – Click SVG (SVG is vectorial graphics like PDF so they scale to different sizes nicely) 18

Other metrics • Average path length: under the statics module, right • Computes the

Other metrics • Average path length: under the statics module, right • Computes the average of shortest paths between all pairs of nodes • Result: 19

Most of these are not in Gephi/Python/R An interactive periodic table of centralities: http:

Most of these are not in Gephi/Python/R An interactive periodic table of centralities: http: //schochastics. net/sna/periodic. html 20