This example treats the input graph as a weighted, undirected network (WUN).
Input
In the following figure, nodes represent countries, edges connect countries that trade with each other, and numbers on edges represent trade propensity.
Graph of Trading Partners
The graph in the figure is represented by the Vertices and Edges tables country and trade, respectively.
countryid | name |
---|---|
1 | USA |
2 | China |
3 | UK |
4 | Japan |
5 | France |
fromid | toid | tradeweight |
---|---|---|
1 | 2 | 0.8 |
1 | 3 | 0.5 |
1 | 4 | 0.8 |
2 | 3 | 0.5 |
3 | 1 | 0.2 |
3 | 4 | 0.3 |
3 | 5 | 0.4 |
5 | 1 | 0.5 |
SQL Call
SELECT * FROM LocalClusteringCoefficient ( ON trade as Edges PARTITION BY fromid ON country as Vertices PARTITION BY countryid USING TargetKey ('toid') EdgeWeight ('tradeweight') Directed ('f') Accumulate ('countryid', 'name') ) AS dt ORDER BY countryid;
Output
countryid name degree tri_cnt cc w_cc --------- ------ ------ ------- -- ------- 1 usa 4 6 1 0.44642 2 china 2 2 2 1.01569 3 uk 4 6 1 0.44642 4 japan 2 2 2 0.85667 5 france 2 2 2 0.80615
Download a zip file of all examples and a SQL script file that creates their input tables from the attachment in the left sidebar.