Skip to content

Basic Usage

Setup

-- Create a sample social network
create or replace table social_edges as
select *
from (values (1::bigint, 2::bigint),
             (1, 3),
             (2, 3),
             (2, 4),
             (3, 4),
             (3, 5),
             (4, 5),
             (5, 6)) t(user_from, user_to);

Run in the playground

Find Key Influencers

select *
from onager_ctr_pagerank((select user_from, user_to from social_edges))
order by rank desc;

Run in the playground

Detect Communities

select *
from onager_cmm_louvain((select user_from, user_to from social_edges));

Run in the playground

Check Network Connectivity

-- How many connected components?
select count(distinct component) as num_components
from onager_cmm_components((select user_from, user_to from social_edges));

Run in the playground

Measure Network Structure

select diameter,
       (select avg_clustering
        from onager_mtr_avg_clustering((select user_from, user_to from social_edges))) as clustering
from onager_mtr_diameter((select user_from, user_to from social_edges));

Run in the playground

Generate Test Data

-- Create a larger random network for testing
create or replace table test_network as
select *
from onager_gen_erdos_renyi(500, 0.02, seed := 42);

-- Analyze it
select count(*) as edge_count
from test_network;

Run in the playground