LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tree Data Structure with DVR Arrays

I am trying to create a simple tree data structure using DRVs. I created a typedef cluster with the following elements:

 

Int (node's data)

Array of this typedef cluster (child nodes)

 

My plan here is to save the head node, and be able to iterate through the tree via the child node array. However I cannot dynamically build and assign an array of nodes, I can only add a static array. The following image shows the error that I get.

 

DVR Error.png

Any ideas why this would give me an error?

 

Thanks

 

 

 

0 Kudos
Message 1 of 6
(3,481 Views)

Can you attach the VI  (and typedef) instead of a picture.

 

It is not clear to me what you are trying to do. Does not make a lot of sense at the moment....

0 Kudos
Message 2 of 6
(3,453 Views)

Just a guess


@Will_Toth wrote:

I am trying to create a simple tree data structure using DRVs. I created a typedef cluster with the following elements:

 

Int (node's data)

Array of this typedef cluster (child nodes)

 

My plan here is to save the head node, and be able to iterate through the tree via the child node array. However I cannot dynamically build and assign an array of nodes, I can only add a static array. The following image shows the error that I get.

 

DVR Error.png

Any ideas why this would give me an error?

 

Thanks

 

 

 


That .. looks recursive to me. Can you post the actual code? I'm suspicious that the DVR type is of a cluster without the same DVR in it (hence the error - DVR types are only compatible if they point to the exact same types of data).

 

EDIT: I think the problem lies in your first paragraph (formatting is mine):

 

I am trying to create a simple tree data structure using DRVs. I created a typedef cluster with the following elements:

Int (node's data)

Array of this typedef cluster (child nodes)

 

What you are saying is that the control contains instances of itself (via the DVR). This is not permitted - you end up with recursion and Controls do not support this directly. I think what you actually have there is a different cluster then you think you do - using the Context Help check the DVR contained type and make sure the DVR is the type you expect. 

 

You could implement this by effectively by-passing LabVIEW's check by storing the DVR as a Variant instead (via the To Variant primitive). Variants can be effectively null. Or, if you don't mind using classes, you can use the approach listed here:

 

https://decibel.ni.com/content/docs/DOC-12668

0 Kudos
Message 3 of 6
(3,442 Views)

Why would you add yourself as a child node? If you're assuming the 1st element to be This, you need to add/change it in a DVR-structure after the DVR is created. I did a similar thing in a file structure some time ago, i'll see if i can find a link.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 6
(3,406 Views)

Check the last post in Filelist

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 6
(3,397 Views)

Hey Ya'll,

I've just pushed (as a very very very early release) a side project I've been working on called the LabVIEW Container that may help solving tree type problems. Just wanted to throw it out there to see what you guys thought of the idea.

 

Here's a super short 5 min video.

 

 

If that sounds interesting at all, here's the community page (again, lots of work to do on the page). 

 

Thanks!

 

Chris Cilino

National Instruments

LV CLD.png

Message 6 of 6
(3,349 Views)