I have to build a directed graph of a social network based on interactions with a business. My starting element is a two column table [user_id, [Friends]]. The entries for user_id come from subsetting a larger set on the basis of interaction with a specified business(if an interaction is detected, the user_id is included in this table). The entries for user_id are factors, and the entries for Friends are a list of factors, pulled directly from the database and include all friends per user_id.
example:
| user_id | Friends |
|--------:|------------------------|
| Jake | ['Laura','Bob','Mary'] |
| Laura | ['Bob','John','Peter'] |
| Bob | ['Jane','Fred','Mary'] |
In order to determine my edges, I would like to cross reference each user_id with the friends of every other user_id. From the example: is Bob in Jake's or Laura's friends list? is Jake in Bob's or Laura's friends list? is Laura in Bob's or Jake's friends list?
Every time the question is answered positively, add an edge between users. This I am hoping to represent in an adjacency matrix. Our example would return something like this:
| | Bob | Jake | Laura | Jane | Fred | Mary | John | Peter |
|------:|-----|------|-------|------|------|------|------|-------|
| Bob | | | | | | | | |
| Jake | 1 | | 1 | | | | | |
| Laura | 1 | | | | | | | |
| Jane | | | | | | | | |
| Fred | | | | | | | | |
| Mary | | | | | | | | |
| John | | | | | | | | |
| Peter | | | | | | | | |
Finally I would like to build a graph based on this matrix
Thanks!
Edit for clarity and added example