1.0 - 8.00 - LocalClusteringCoefficient Example 1: WUN - Teradata Vantage

Teradata® Vantage Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.0
8.00
Release Date
May 2019
Content Type
Programming Reference
Publication ID
B700-4003-098K
Language
English (United States)

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.

vertices: country
countryid name
1 USA
2 China
3 UK
4 Japan
5 France
edges: trade
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.00000 0.44642
2 China 2 2 2.00000 1.01569
3 UK 4 6 1.00000 0.44642
4 Japan 2 2 2.00000 0.85667
5 France 2 2 2.00000 0.80615