Closeness Example | Teradata Vantage - Closeness Example: Unweighted, Unbounded Graph - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
9.02
9.01
2.0
1.3
Published
February 2022
Language
English (United States)
Last Update
2022-02-10
dita:mapPath
rnn1580259159235.ditamap
dita:ditavalPath
ybt1582220416951.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

Input

Input tables are from AllPairsShortestPath Example: Unweighted, Unbounded Graph:

  • Vertices: callers
  • Edges: calls

SQL Call

SELECT * FROM Closeness (
  ON callers as Vertices PARTITION BY callerid
  ON calls as Edges PARTITION BY callerfrom
  USING
  TargetKey ('callerto')
  MaxDistance (-1)
  Accumulate ('callerid', 'callername')
) AS dt ORDER BY callerid;

Output

Because callerid 6 (Diana) has no outbound calls, the k-degree is 0.

 callerid callername inv_sum_dist inv_avg_dist sum_inv_dist kdegree 
 -------- ---------- ------------ ------------ ------------ ------- 
        1 john               0.25          1.0          4.0     4.0
        2 carla               0.5          1.0          2.0     2.0
        3 simon               1.0          1.0          1.0     1.0
        4 celine              1.0          1.0          1.0     1.0
        5 winston             1.0          1.0          1.0     1.0
        6 diana              NULL         NULL         NULL     0.0

Download a zip file of all examples and a SQL script file that creates their input tables.