I have a table called friendgraph(friend_id, friend_follower_id) and I want to calculate 6-degrees of separation for a given friend and a given degree. The table looks like this:
friend_id, friend_follower_id
0,1
0,9
1,47
1,12
2,41
2,66
2,75
3,65
3,21
3,4
3,94
4,64
4,32
How do I go and built a query where given friend_id_a, and order_k, find the users who are k degree apart from friend_id_a?
This is how my initial query file looks like:
create or replace function degree6
(friend_id_a in integer, order_k in integer)
return sys_refcursor as crs sys_refcursor;
I am looking for any kind of help or resources that will get me started and eventually arrive at the output.
UPDATE: The output would be a list of other friends k degrees apart from friend_id_a.
Define order-k follower B of A such that B is not A, and: 1. if k = 0, then A is the only order-0 follower of A. 2. if k = 1, then followers of A are order-1 followers of A. 3. if k > 1; then for i = 0 to k-1, B is not order-i follower of A; and B is a follower of a order-(k-1) follower of A
Thanks.