Hi @hmd_pouya
Your problem is the same as the one solved in this other thread:
Your data can be considered as a table of edges of a relational graph. A relational graph is made of nodes and edges. Your letters from “a” to “g” are the nodes. Your Table rows are the edges between nodes: for instance first row says “a is connected to b”. What you want to find is the beginning and end node of a set of connected nodes, i.e. a path leading from “a” to “d”. Btw, your 3rd column is the name of the path: for instance path x is “a-b-c-d”.
The thread given above should thus be a solution to your question.
Hope this helps. Otherwise please let us know and we will be happy to help.
Best
Ael