Center for Financial Studies at the Goethe UniversityPhD Mini-courseFrankfurt, 25 January 2013Financial Networks2. Fundame...
FNA      www.fna.fi
FNA Platform• Go to www.fna.fi• Register account  (click login on top right)• Watch ‘Getting started with  FNA’ video• Mor...
FNA Commands• FNA operates on commands that are submitted to FNA server for  execution. Commands explore the database, alt...
Data Modelloada -file sample-arcs.csv -preserve falsesample-arcs.csvnetwork,source,target,value2005-1Q,Australia,Austria,4...
Basic terms• Graph• Network = Graph with properties• Node, Vertex, (Point)• Link, (Line)• Arc = Directed Link• Edge = Undi...
Types of Networks                    7
Trivial Graph (1)#G(V,E) = Trivial Graph#V = {1}#E = {empty set}# Add network ‘Trivial to database.addn -n Trivial -preser...
Empty Graph (2)# G(V,E) = Empty Graph# V = {1, 2, 3, 4}# E = {empty set}# Add network ‘Empty to database.# The -preserve p...
Simple Undirected Graph (3)# G(V,E) = Simple Graph# V = {1, 2, 3, 4}# E = {(1,2),(1,3),(2,3),(2,4),(3,4)}# Add network ‘Si...
Complete Graph –K4 (4)# Add network netk4 to database.complete -nv 4 -directed false -preserve false# Visualize network ne...
Complete Graph –K7 (5)# Add network netk7 to database.complete -nv 7 -directed false -saveas netk7 -preserve false# Visual...
Directed Graph, Digraph (6)# Create a Petersen Graph# -direction any allows creation of arcs in any direction between two ...
Directed Weighted Graph (7)# A directed and weighed Petersen graph.# Create a Petersen Graph# -direction both creates arcs...
Example application areasCross-border banking exposures   Interbank payment flows                                         ...
Bipartite Graph (8)#G(V,E) = Bipartite Graph# Vl = {1, 2, 3, 4, 5, 6, 7, 8}# Vr = {9, 10, 11, 12, 13, 14, 15, 16}# E = {ra...
Bipartite Graph# Create a bipartite graph with 8 vertices in left group (-nl) and 8 vertices in right group (-nr) and 12  ...
Example application areasBanks        Countries   Insurers   Risk Drivers                                           18
Tree (9)# A tree is a graph with no cycles# Create a tree with 6 verticestree -nv 10 -seed 111 -saveas Tree#Visualize the ...
Minimum Spanning Tree (10)#G(V,E) = MST,#V = {1, 2, 3, 4, 5, 6, 7}#E = {(1,2),(1,4),(3,2),(3,4),(4,6),(4,7),(5,3),(5,4),(6...
Minimum Spanning Tree# Create random network with 10 vertices and 30 arcsrandom -nv 5 -na 10 -seed 123 -preserve false# Ca...
MST: ApplicationRosario Mantegna (1999). Hierarchical Structure in FinancialMarkets. Eur. Phys. J. B 11, 193-197.         ...
Connectivity               23
DegreeDegree (11)# Add network degree to databasepetersen -direction any -seed 111 -saveas Path -preserve false# Calculate...
Degree Distribution                      The topology of interbank                      payment flows. Soramäki et        ...
Degree Correlations• Calculate    – Neighbor degree/out-degree/in-degree (and)    – Successor degree/out-degree/in-degree ...
Example: US Banks                    27
Paths, Trails, Walks (12)# Create a Petersen Graph# -seed 111 allows the same standard layout to be produced each time.pet...
Other connectivity measures•   Size: Number of arcs•   Order: Number of vertices•   Connectivity: order/(size*(size-1))•  ...
Weighted Shortest Path (13)# Create a Petersen Graph# -seed 111 allows the same standard layout to be produced each time.p...
ComponentsGWCC : Giant Weakly Connected ComponentGIN : Giant In-ComponentGSSC : Giant Strongly Connected Component   Dorog...
Weakly Connected Graph (14)# Create random networkrandom -nv 30 -na 40 -seed 100 -preserve false# Identify SCwc# Color ver...
Strongly Connected Graph (15)# Create random networkrandom -nv 30 -na 60 -seed 100 -preserve false# Identify SCsc# Color v...
Blog, Library and Demos at www.fna.fiDr. Kimmo Soramäkikimmo@soramaki.netTwitter: soramaki
Upcoming SlideShare
Loading in …5
×

Financial Networks: II. Fundamentals of Network Theory and FNA

1,094 views

Published on

Second lecture of a PhD level course on "Financial Networks" at Center for Financial Research at Goethe University, Frankfurt.

Published in: Economy & Finance
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,094
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
26
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Financial Networks: II. Fundamentals of Network Theory and FNA

  1. 1. Center for Financial Studies at the Goethe UniversityPhD Mini-courseFrankfurt, 25 January 2013Financial Networks2. Fundamentals of NetworkTheory and FNA Dr. Kimmo Soramäki Founder and CEO FNA, www.fna.fi
  2. 2. FNA www.fna.fi
  3. 3. FNA Platform• Go to www.fna.fi• Register account (click login on top right)• Watch ‘Getting started with FNA’ video• More documentation available at www.fna.fi/gettingstarted 3
  4. 4. FNA Commands• FNA operates on commands that are submitted to FNA server for execution. Commands explore the database, alter it or create visualizations from it• Command syntax: commandname –parameter1 value1 –parameter2 value2 … e.g. loada -file sample-arcs.csv -preserve false (load arcs from sample-arcs.csv file and don’t preserve any existing networks in database)• Each command is on a single line. Character # marks a comment line• Commands can be bundled into scripts and executed in one go 4
  5. 5. Data Modelloada -file sample-arcs.csv -preserve falsesample-arcs.csvnetwork,source,target,value2005-1Q,Australia,Austria,4992005-1Q,Australia,Belgium,1135 Stores the data into2005-1Q,Australia,Canada,1884 a graph database... on FNA Servernet_id : 2005-1Q arc_id : Australia-Austria vertex_id : Austria value : 499 … vertex_id : Australia vertex_id : Belgium … vertex_id : Canada 5
  6. 6. Basic terms• Graph• Network = Graph with properties• Node, Vertex, (Point)• Link, (Line)• Arc = Directed Link• Edge = Undirected Link 6
  7. 7. Types of Networks 7
  8. 8. Trivial Graph (1)#G(V,E) = Trivial Graph#V = {1}#E = {empty set}# Add network ‘Trivial to database.addn -n Trivial -preserve false# Add vertex v1 to network ‘Trivial .addv -id Trivial -v v1# Visualize network ‘Trivial.viz -id Trivial -vlabel vertex_id -vsizedefault 10 -fontsize 25 -saveas TrivialViz -scale 1
  9. 9. Empty Graph (2)# G(V,E) = Empty Graph# V = {1, 2, 3, 4}# E = {empty set}# Add network ‘Empty to database.# The -preserve parameter defines whethe to keep# existing networks in memory or to delete themaddn -n Empty -preserve false# Add vertices v1 to v4 to network ‘Empty .addv -id Empty -v v1addv -id Empty -v v2addv -id Empty -v v3addv -id Empty -v v4# Visualize network ‘Empty . Add vertex names using -vlabel and change the font size of these labels using -fontsize. Set size of vertices to size 10 using -vsizedefault.viz -id Empty -vlabel vertex_id -vsizedefault 10 -fontsize 25 -saveas EmptyViz
  10. 10. Simple Undirected Graph (3)# G(V,E) = Simple Graph# V = {1, 2, 3, 4}# E = {(1,2),(1,3),(2,3),(2,4),(3,4)}# Add network ‘Simple to database.addn -n Simple -preserve false# Add vertices v1 to v4 to network ‘Simple.addv -id Simple -v v1addv -id Simple -v v2addv -id Simple -v v3addv -id Simple -v v4# Add arcs to network ‘Simple.adda -id Simple -a v1-v2adda -id Simple -a v1-v3adda -id Simple -a v2-v3adda -id Simple -a v2-v4adda -id Simple -a v3-v4# Visualize network ‘Simple.viz -id Simple -vlabel vertex_id -awidthdefault 2 -vsizedefault 10 -fontsize 25 -arrows false -saveas SimpleViz
  11. 11. Complete Graph –K4 (4)# Add network netk4 to database.complete -nv 4 -directed false -preserve false# Visualize network netk4.viz -vlabel vertex_id -awidthdefault 2 -vsizedefault 10 -fontsize 25 -arrows false -saveas complete_k4 Notes If no -saveas parameter is given, created networks are autonamed Without -id paremeter in the viz - command all networks in memry are visualized
  12. 12. Complete Graph –K7 (5)# Add network netk7 to database.complete -nv 7 -directed false -saveas netk7 -preserve false# Visualize network netk7.viz -vlabel vertex_id -awidthdefault 2 -vsizedefault 10 -fontsize 25 -arrows false -saveas complete_k7
  13. 13. Directed Graph, Digraph (6)# Create a Petersen Graph# -direction any allows creation of arcs in any direction between two verticespetersen -direction any -seed 111 -saveas Digraph -preserve false# Visualize the network. Setting the parameter -arrows true gives a directed network.viz -id Digraph -awidthdefault 2 -vsizedefault 10 -fontsize 25 -vlabel vertex_id -arrows true -saveas Digraph
  14. 14. Directed Weighted Graph (7)# A directed and weighed Petersen graph.# Create a Petersen Graph# -direction both creates arcs in both directionpetersen -direction both -seed 111 -saveas WeightedDigraph -preserve false# Set random arc propertycalcap -e [?random:uniform:1,10?] -saveas value# Visualize the network# Setting the parameter -arrows true shows direction of arcsviz -id WeightedDigraph -alabel value -awidthdefault 3 -vsizedefault 10 - fontsize 25 -vlabel vertex_id -arrows true -saveas Digraph# Visualize arc values as arc widthviz -id WeightedDigraph -awidth value -awidthdefault 3 -vsizedefault 10 - fontsize 25 -vlabel vertex_id -arrows true -saveas Digraph
  15. 15. Example application areasCross-border banking exposures Interbank payment flows 15
  16. 16. Bipartite Graph (8)#G(V,E) = Bipartite Graph# Vl = {1, 2, 3, 4, 5, 6, 7, 8}# Vr = {9, 10, 11, 12, 13, 14, 15, 16}# E = {randomly generated set}
  17. 17. Bipartite Graph# Create a bipartite graph with 8 vertices in left group (-nl) and 8 vertices in right group (-nr) and 12 randomly assigned arcs (-na) that will go in both directions.bipartite -nl 8 -nr 8 -na 12 -direction any -partition true -seed 123 -saveas bipartite -preserve false# Separate the two sets of vertices, ready for visualization.bipartitelayout -partition partition# Visualize the bipartite network.viz -vsizedefault 10 -vlabel vertex_id -awidthdefault 2 -fontsize 25 -saveas BipartiteNotesAdding the parameter -seed to the bipartitecommand will generate a specific graph. So forexample using -seed 111 will always assign the arcsin the same way, to generate the same graph.Without the -seed parameter the the randomgenerator is initialized from system time.
  18. 18. Example application areasBanks Countries Insurers Risk Drivers 18
  19. 19. Tree (9)# A tree is a graph with no cycles# Create a tree with 6 verticestree -nv 10 -seed 111 -saveas Tree#Visualize the treeviz -id Tree -vlabel vertex_id -vsizedefault 5 -awidthdefault 3 Notes A forest is a disjoint union of trees
  20. 20. Minimum Spanning Tree (10)#G(V,E) = MST,#V = {1, 2, 3, 4, 5, 6, 7}#E = {(1,2),(1,4),(3,2),(3,4),(4,6),(4,7),(5,3),(5,4),(6,5),(6,7),(7,6)}
  21. 21. Minimum Spanning Tree# Create random network with 10 vertices and 30 arcsrandom -nv 5 -na 10 -seed 123 -preserve false# Calculate random arc property between 1 and 10calcap -e [?random:uniform:1,10:111?] -saveas value# Visualize original networkviz -vlabel vertex_id -awidthdefault 2 -saveas Random# Identify minimun spanning tree for value propertyminst -p value# Highlight Minimum Spannign Tree in Random networkviz -acolor minst -alabel value -awidthdefault 2 -saveas RandomWithMST# Drop arcs not in Minimum Spannin treedropa -e minst=false# Visualize Minimum Spanning Treeviz -vlabel vertex_id -awidthdefault 2 -alabel value -saveas MST
  22. 22. MST: ApplicationRosario Mantegna (1999). Hierarchical Structure in FinancialMarkets. Eur. Phys. J. B 11, 193-197. 22
  23. 23. Connectivity 23
  24. 24. DegreeDegree (11)# Add network degree to databasepetersen -direction any -seed 111 -saveas Path -preserve false# Calculate degree, in-degree and out-degree In-Degreedegree -saveas degreedegree -direction in -saveas in-degreedegree -direction out -saveas out-degree# Visualize network degree. The vertices are labelled using their degree.viz -vlabel degree -vsizedefault 10 -vcolordefault orange - fontsize 25 -awidthdefault 3 -saveas Degreeviz -vlabel in-degree -vsizedefault 10 -vcolordefault orange - Out-Degree fontsize 25 -awidthdefault 3 -saveas In-Degreeviz -vlabel out-degree -vsizedefault 10 -vcolordefault orange - fontsize 25 -awidthdefault 3 -saveas Out-Degree
  25. 25. Degree Distribution The topology of interbank payment flows. Soramäki et al. Physica A: Statistical Mechanics and its Applications 379 (1), 317-333 25
  26. 26. Degree Correlations• Calculate – Neighbor degree/out-degree/in-degree (and) – Successor degree/out-degree/in-degree (asd) – Predecessor degree/out-degree/in-degree (apd)• Correlate to degree/out-degree/in-degree of each node: – zero for uncorrelated networks – positive for assortative networks and – negative fordisasortative networks• In assortative networks nodes with a given degree are more likely to have links with nodes of similar degree. Disassortative if the opposite is true. 26
  27. 27. Example: US Banks 27
  28. 28. Paths, Trails, Walks (12)# Create a Petersen Graph# -seed 111 allows the same standard layout to be produced each time.petersen -direction any -seed 111 -saveas Path -preserve false# Calculate the path from vertex 5 to vertex 8distance -from 00005 -to 00008 -p value -savepath true# Visualize the network. The arc colors highlight the pathviz -acolor path(00005,00008) -awidthdefault 2 -vsizedefault 10 - fontsize 25 -vlabel vertex_id -saveas PathNotesA Walk is any free movement along the arcsA Trail is a walk where a given arc is visited only onceA Path is a walk where a given vertex is visited only onceA Geadesic Path is the Shortest PathA Cycle is a path starting and ending to the same vertex
  29. 29. Other connectivity measures• Size: Number of arcs• Order: Number of vertices• Connectivity: order/(size*(size-1))• Ego distance: distance to/from given vertex from/to other vertices• Eccentricity: Maximum distance from/to a vertex• Diameter: Maximum eccentricity• Clustering coefficient: Share of neighbours with links 29
  30. 30. Weighted Shortest Path (13)# Create a Petersen Graph# -seed 111 allows the same standard layout to be produced each time.petersen -direction any -seed 111 -saveas Path -preserve false#Assign random values to arcs.calcap -e[?random:uniform:1,10:104?] -saveas value# Calculate the path from vertex 5 to vertex 8distance -from 00005 -to 00008 -p value -savepath true# Visualize the network. The arc colors highlight the pathviz -acolor path(00005,00008) -alabel value -awidthdefault 2 - vsizedefault 10 -fontsize 25 -vhover vertex_id -saveas WeightedPath4 30
  31. 31. ComponentsGWCC : Giant Weakly Connected ComponentGIN : Giant In-ComponentGSSC : Giant Strongly Connected Component Dorogovtsev S.N., J.F.F. Mendes, and A.N. SamukhinGOUT : Giant Out-Component (2001). “Giant strongly connected component of directed networks”, Phys. Rev. E 64.
  32. 32. Weakly Connected Graph (14)# Create random networkrandom -nv 30 -na 40 -seed 100 -preserve false# Identify SCwc# Color vertices in SC as redsetvp -p color -value blacksetvp -e wc=0 -p color -value red# Create visualizationviz -vcolor color -vsizedefault 5 -saveas WCViZ
  33. 33. Strongly Connected Graph (15)# Create random networkrandom -nv 30 -na 60 -seed 100 -preserve false# Identify SCsc# Color vertices in SC as redsetvp -p color -value blacksetvp -e sc=0 -p color -value red# Color arcs within nodes in SC as redcalcap -e source.sc=0 -saveas srcsccalcap -e target.sc=0 -saveas tgtsccalcap -e "srcsc AND tgtsc" -saveas scarcsetap -p color -value blacksetap -p color -e scarc=true -value red# Create visualizationviz -vcolor color -acolor color -vsizedefault 8 -awidthdefault 2 -saveas SCViZ
  34. 34. Blog, Library and Demos at www.fna.fiDr. Kimmo Soramäkikimmo@soramaki.netTwitter: soramaki

×