1
$\begingroup$

I have 'discovered' a way to encode rose trees (see e.g. What are the applications of Rose trees? ) as a sparse matrix: if you have a node n with ID i and parent ID p, then you place n in the matrix at coordinates (row, column) of (p, i). This makes it easy to:

  • Get a node by its ID and parent ID (single lookup of the matrix)
  • Get all children of a node ID (lookup a matrix row)
  • Prune and graft subtrees (change the coordinates of the subtree root)

Now I'm thinking that I can't be the first person to have thought of this. Can anyone point me to any literature which discuss this encoding?

$\endgroup$
2
$\begingroup$

In view of rose tree being just a special case of a graph, the matrix representation you mentioned is simply the adjacency matrix representation of directed graph. Your particular encoding takes the rose tree's edge to always be directed consistently either from parent to child or child to parent.

Questions about rose tree in this encoding thus can be researched easily by looking up results about adjacency matrix representation of directed tree graph.

Relevant notions are:

  • get all leaves of subtree -> reachability
  • graft tree -> wedge sum
$\endgroup$
  • $\begingroup$ Thanks for the pointers! I discovered my terminology was a bit off; the structure I have in mind is really an adjacency list implemented as a jagged array. lix.polytechnique.fr/~liberti/data_structures.pdf §4.1.1 has a good example pretty much identical to mine, except as you mentioned, mine is directed consistently between parent/child. $\endgroup$ – Yawar Jan 30 '17 at 18:14
  • $\begingroup$ @Yawar Glad to be of help $\endgroup$ – Apiwat Chantawibul Jan 30 '17 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.