Does anyone have the code for a class that implements a collection with many-to-many / self-referencing? I'm thinking of a class that houses the collection of objects, and a custom object that represents the actual object (e.g. webfile) that itself has a parent & children list. Anyone what I'm trying to solve is:

1. Need to model a website which is based on a number of web files (e.g. class = "webfile"),
2. Model parent & child relationship - In terms of associations a webfile can have multiple child webfiles, and child webfiles can have multiple parents. (think of a HTML page that have multiple images, or multiple HTML pages that share the same image)
3. A file can be both a parent & a child - or in other words a HTML page can have a link to other HTML pages.
4. There should be no duplicates anywhere, assume that the URI is the key. In a sense I'm wanting to model the files sitting on a web site. There is only one actual copy of image XYZ, however there will be links to it from multiple pages.
5. The actual webfile class itself would be key'ed of a unique URI, however I envisage other attributes in the class such as lastmodifieddate, size etc.
6. Oh, and I was going to use XML serialization on the class as well, to save/load the data. Not sure if this affects the answer
7. Would like it to support the ability to ask questions such as: "give me children for file XYZ (a Uri would be a good key)", or "addChildToParent(Uri child, Uri parent)"

Hope this makes sense.

If anyone has code for this class (or classes, perhaps it would be one container class, and one class that models the webfile?)