# Tree visualisation - programming technique

I would like to visualize words in a tree structure - like a Mindmap structure read out of a XML-file. Actually I found out TreeView.node is a way to obtain it.
-But now, my problem is, how to show this. In textual programming I would create a recursive function to collect and show data. Whats the best way to do it with 4V?
-Is there a way to store data in spreads like a multi-dimensional array (with non fixed amount of vars)? Actually spreads are always sorted in linear order (even though vectors), dont they?

node cons ?

Mmmh, but problems occur if I want to get a spread in between some others, like myArr= ( (0,2,3,5,6),(1,1,1),(34,35,3,23) ).
How to get the (1,1,1)?
Cons makes it still in linear order.
Anyway, some ideas about this recursive stuff? I’ve read the language design.pdf from node08. hopefully, some guys participating this workshop do have a hint?

hi frank!

i’m sorry to say that multidimensional arrays are not supported and also recursive patches are not.

so you will need to work with binsizes and such.

for your simple demo of multidimensional arrays
( (0,2,3,5,6),(1,1,1),(34,35,3,23) )

you would need to store the binsizes somehow like that
( 5, 3, 4 )

now for this example you are done, because we already have a onedimensional array here which is somehow something like a normal spread.

for more complex examples you could need more steps to reduce the complexity / to describe the tree structure…

( (0, (2, 3), 5, 6), (1, 1, 1), ( ( (34,35), 3), 23) )

binsizes would look like
( (1, 2, 1, 1), 3, ( (2, 1), 1) )

binsizes for the upper “spread” would be
( 4, 1, (2, 1) )

binsizes for the upper “tree” would be
( 1, 1, 2 )

so if you have 4 spreads like:
( 1, 1, 2 )
( 4, 1, 2, 1 )
( 1, 2, 1, 1, 3, 2, 1, 1 )
( 0, 2, 3, 5, 6, 1, 1, 1, 34,35, 3, 23 )

you could somehow retrieve the tree structure.

however this is not beautiful i know.
and then also there are other ways to encode / decode tree structures in 1d lists.

however sometimes there are other possibilities that pop up somehow.

in the attached penrose system

• each kite can be put together by 3 smaller objects (2 kites, 1 dart)
• each dart can be put together by 2 smaller objects (1 kite, 1dart)

if you start with one shape and recursively replace darts and kites by that rule above you get dense network of small kites and darts.

you can look at that as a sort of tree structure. however the trick here is that all different levels are separated from each other.

the recursive system is not really patched recursively, like you will see at the first glimpse. but sometimes it is ok to limit the depth level, i certainly don’t know it that is true for your application.

so many questions open and i can only offer some hacks for you, but sometimes it is really crazy what you still can do with these 1d lists…

grtz, s

Penrose Darts and Kites.zip (9.8 kB)

Wow!! You got me :) cool patch!! Thanks for sharing!

Hey gregsn,
thanks for your long reply. Unfortunately, your example doesnt work for me somehow. There are some nodes not connected at right side and I see not a thing. Wierd, that Desaxismundi does see and is amazed.

I also had a look at new Lindenmayer node. Actually, this wikipedia page gives a good insight. Beautiful pictures and structures there. Later I’ll do some experiments with that. But for my purposes it isnt suitable as its branch structures are fixed. I need it dynamic.

I’ll keep on this issue.

hm i don’t know why it doesn’t work for you. just downloaded it again and it works.

however ignore those nodes on the right side. the left side explains the concept.
do you see anything in the renderer?

another workaround for complex data structures are strings - either some simple homebrewn bracket syntax or as xml strings - things like regexpr and xpath and xslt can do quite complex things.

Mmmh, this XMl idea is worth a look. I did a little sunday-patch with it. Quite powerful.
I build a working casefor me, using a spread (linear) and treat it as a multidimensional array - in a way.
So if anyone is interested in this here are the modules.