@@ -14,7 +14,7 @@ Use PageRank and degree centrality to identify influential users:
1414``` sql
1515-- Create social network edges
1616create table follows as select * from (values
17- (1 , 2 ), (1 , 3 ), (2 , 3 ), (3 , 4 ), (4 , 5 ), (5 , 1 ), (2 , 4 ), (3 , 5 )
17+ (1 :: bigint , 2 :: bigint ), (1 , 3 ), (2 , 3 ), (3 , 4 ), (4 , 5 ), (5 , 1 ), (2 , 4 ), (3 , 5 )
1818) t(follower, followed);
1919
2020-- Find top influencers by PageRank
@@ -61,8 +61,8 @@ High local clustering may indicate coordinated behavior:
6161
6262``` sql
6363create table transactions as select * from (values
64- (100 , 200 ), (200 , 300 ), (300 , 100 ), -- Triangle (suspicious)
65- (400 , 500 ), (500 , 600 ) -- Normal chain
64+ (100 :: bigint , 200 :: bigint ), (200 , 300 ), (300 , 100 ), -- Triangle (suspicious)
65+ (400 , 500 ), (500 , 600 ) -- Normal chain
6666) t(sender, receiver);
6767
6868-- Find nodes with high clustering (potential fraud rings)
@@ -85,7 +85,7 @@ where triangles > 0;
8585``` sql
8686-- User interaction graph
8787create table interactions as select * from (values
88- (1 , 10 ), (1 , 20 ), (2 , 10 ), (2 , 30 ), (3 , 20 ), (3 , 30 )
88+ (1 :: bigint , 10 :: bigint ), (1 , 20 ), (2 , 10 ), (2 , 30 ), (3 , 20 ), (3 , 30 )
8989) t(user_id, item_id);
9090
9191-- Create edges (user-item bipartite graph)
@@ -95,7 +95,7 @@ create table edges as
9595-- Recommend items for user 1 based on their interactions
9696-- Using ego graph to explore local neighborhood
9797select *
98- from onager_sub_k_hop_neighbors( edges, start := 1 , k := 2 )
98+ from onager_sub_k_hop(( select src, dst from edges) , start := 1 :: bigint , k := 2 )
9999where node_id > 1000 ; -- Filter to items only
100100```
101101
0 commit comments