rsc / pdf

PDF reader
BSD 3-Clause "New" or "Revised" License
510 stars 327 forks source link

How to avoid loops when traversing the graph? #5

Closed qbengt closed 7 years ago

qbengt commented 7 years ago

Greetings,

Given a PDF file that has a loop (ex: pages found from "Kids" have entries for "Parent" pointing back), how to I traverse the graph without getting stuck?

I tried saving the Values that I have visited, but they are not == to the new Values.

rsc commented 7 years ago

I don't believe there's a good way to do this, other than hard-coding a list of back-edges not to follow (starting with "Parent"). My guess is that the PDF format does not have too many back-edges that you have to exclude.