C#: Avoid infinite recursion when traversing object graph

后端 未结 6 1932
心在旅途
心在旅途 2020-12-24 03:17

I have an object graph wherein each child object contains a property that refers back to its parent. Are there any good strategies for ignoring the parent references in orde

6条回答
  •  有刺的猬
    2020-12-24 03:53

    I'm not exactly sure what you are trying to do here but you could just maintain a hashtable with all previously visited nodes when you are doing your breadth first search of depth first search.

提交回复
热议问题