This system using Breadth-first search. It search layer by layer with restrictions on the maximum search depth. If we doesn't have new layer, we load it from database. Loaded layers store in memory and doesn't load twice.
Implementation write, read and delete relations in MySQL.
User Relations - is an infinite and looped graph.
Direct relation - is a close friend or foe.
Indirect relation - is a far friend or foe, thru some number of relations.
This method automatically creates necessary DB structure.
Adds direct friend to target user.
Adds direct foe to target user.
Removes direct relation for target user.
Returns TRUE if the specified User is a direct or indirect friend for target user.
Returns TRUE if the specified User is a direct or indirect foe for target user.
Returns list of all direct and indirect friends.
Returns list of users that are friends and foes at the same time for different users in the graph. We can reach the user through friends and foe at the same time.