Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 计算友谊的程度_Mysql_Algorithm_Data Structures_Social Networking - Fatal编程技术网

Mysql 计算友谊的程度

Mysql 计算友谊的程度,mysql,algorithm,data-structures,social-networking,Mysql,Algorithm,Data Structures,Social Networking,我创建了以下用于存储用户朋友的数据模型- 数据库-MySQL 选项1为此使用MySQL OQGraph引擎,但这需要 Mysql的特殊构建 选项2使用MySQL中的存储过程执行BFS 你能在这里提出一些比我已经说过的更多的算法/模型吗 谢谢 tbl_user [ user_id - pk ] tbl_user_friend [ inviter_id - fk, friend_id - fk, status - 1/2/3 ] status = 2 => friend ,

我创建了以下用于存储用户朋友的数据模型-

数据库-MySQL

选项1为此使用MySQL OQGraph引擎,但这需要 Mysql的特殊构建 选项2使用MySQL中的存储过程执行BFS 你能在这里提出一些比我已经说过的更多的算法/模型吗

谢谢

tbl_user [ user_id - pk ]    
tbl_user_friend [ inviter_id - fk, friend_id - fk,  status - 1/2/3 ]   

status = 2 => friend , = 1 => invite ...

select friend_id from tbl_user_friend where inviter_id = <logged_in_id> and status = 2
UNION
select inviter_id from tbl_user_friend where friend_id = <logged_in_id> and status = 2
Convert above data into Graph and do BFS search.
Level of a node in BFS traversal will be its degree of connection.