This example computes the betweenness score for each person in the social network shown in the following figure.
Betweenness Example Social Network
Input
The Vertices table has the names of people. The Edges table represents the connections between the people.
vertexid |
---|
TED |
RICKY |
ETHEL |
FRED |
JOE |
RANDY |
LUCY |
source | target |
---|---|
TED | ETHEL |
RICKY | FRED |
ETHEL | LUCY |
ETHEL | RANDY |
FRED | ETHEL |
ETHEL | FRED |
JOE | ETHEL |
RANDY | RICKY |
RICKY | RANDY |
FRED | LUCY |
SQL Call
SELECT * FROM Betweenness ( ON soc_nw_vertices AS Vertices PARTITION BY vertexid ON soc_nw_edges AS Edges PARTITION BY source USING TargetKey ('target') Accumulate ('vertexid') ) AS dt ORDER BY vertexid;
Output
Ethel has the highest betweenness score.
vertexid betweenness -------- ----------- ethel 10.0 fred 4.0 joe 0.0 lucy 0.0 randy 4.0 ricky 3.0 ted 0.0
Download a zip file of all examples and a SQL script file that creates their input tables.