I have a situation in which there is an ID which I receive in a function. This ID when I pass to an API it provides me a relation list, for example if I pass as an ID A, I get:
From | To | Type |
---|---|---|
A | B | RelationType1 |
A | C | RelationType2 |
C | D | RelationType3 |
D | A | RelationType4 |
Now I need to find in a recursive manner the relations for all unique ID I get (A,B,C,D) and for each I need to list down the IDs with types until I cannot find any more relations .
Finally I need to save all this data within the database which is not an issue but it will be a combination of From,To and Type.
This is being attempted in php in which I am working on using a class as the basis to start off, thus implementing DFS to do . Is there a better alternative with efficient calls to the API and faster processing.
Thanks for your help.