# Unexpected branches out from GH cluster

**URL:** <https://discourse.mcneel.com/t/unexpected-branches-out-from-gh-cluster/183245>\
**Category:** Grasshopper\
**Tags:** windows, rhino7\
**Created:** [June 2, 2024, 10:41am UTC](https://discourse.mcneel.com/t/unexpected-branches-out-from-gh-cluster/183245 "2024-06-02T10:41:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cloudsvisitor77](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/cloudsvisitor77/32/771524_2.png) [@cloudsvisitor77](https://discourse.mcneel.com/u/cloudsvisitor77)\
**Post date:** [June 2, 2024, 10:41am UTC](https://discourse.mcneel.com/t/unexpected-branches-out-from-gh-cluster/183245/1 "2024-06-02T10:41:12Z")

</div>

Hi

I am making a cluster to be used to obtain values depending the distance between points obtained by intersecting different crvs.

each curve is referenced in to a GH , i can have up to 8 curves ( 1,2…8 ) each curve is generating a set of values contained in a specific branch and when the curve is missing the corresponding branch must not be created.

![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/4/2/94204748c29978941879c2f767f7f9b038291880.png)

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/a/c/9ace2decaff49ba9dd6676569b2ea6af24f4b065.png)

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/b/7/e/b7e3e7f5ae53038135662a352f9d5c8b6c51e9b1.png)

PROBLEM : the logic seems to work while running script from inside the cluster but then when i exit the cluster mode there are "ghost branches " showing up also when crv is not referenced.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/f/8/9f886ec0ac6aab0fc6d48feec4f950ac6e9b5d0f.png)

HERE IS THE DEFINITION :  
[20240602 GH CLUSTER EMPTY BRANCHES.gh](https://discourse.mcneel.com/uploads/short-url/oXlCgwEGRoyzBcbnAQSqqaoIl5Q.gh) (24.8 KB)

does anyone know how to get rid of this “empty” branches ? i tried to clean the tree but its not working.

thnaks , regards

---

<div class="post-metadata">

**Author:** ![inno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/inno/32/544036_2.png) [@inno](https://discourse.mcneel.com/u/inno)\
**Post date:** [June 2, 2024, 3:18pm UTC](https://discourse.mcneel.com/t/unexpected-branches-out-from-gh-cluster/183245/2 "2024-06-02T15:18:06Z")

</div>

the script does not produce the problem you show in the picture if you don’t internalize also these:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/0/b/c/0bc9c0eb42de1d888820320c20771780c38b1978.png)

> [@cloudsvisitor77](#):
>
> i tried to clean the tree but its not working

on Clean tree you need to specify True for “Remove empty branches from the Tree” (by default it’s False)

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/0/2/4/024b9b756e7debcfaa0176a3490f148adc5c488f.png)

---

<div class="post-metadata">

**Author:** ![cloudsvisitor77](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/cloudsvisitor77/32/771524_2.png) [@cloudsvisitor77](https://discourse.mcneel.com/u/cloudsvisitor77)\
**Post date:** [June 2, 2024, 6:05pm UTC](https://discourse.mcneel.com/t/unexpected-branches-out-from-gh-cluster/183245/3 "2024-06-02T18:05:11Z")

</div>

you are right @inno , sorry, attached please find script with all crv refenced and internialized.

[20240602 GH CLUSTER EMPTY BRANCHES 02.gh](https://discourse.mcneel.com/uploads/short-url/3EtiR1BXJZ6I9swCQ2SPbqHaqBr.gh) (28.4 KB)

that said i tried to place clean tree outside the cluster but it does not work as shown in your post.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/e/a/a/eaaa1f9827796357835a0c0ba556373eeb1fc0cd.png)

i still face the problem and the tree stratistic component is showing a different tree when connetcted inside or outside the cluster.

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/0/c/5/0c5d1ca24b2a66d0d2df1ba8843af43941f964f5.png)

i don’t know whats wrong , i never faced this problem before , these empty branches are showing up from nowhere , there is no way to get rid of them and there is not a reason for them to be there, the problem is they they messed up everything downstream

---

<div class="post-metadata">

**Author:** ![kev.r](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kev.r/32/771963_2.png) [@kev.r](https://discourse.mcneel.com/u/kev.r)\
**Post date:** [June 2, 2024, 10:30pm UTC](https://discourse.mcneel.com/t/unexpected-branches-out-from-gh-cluster/183245/4 "2024-06-02T22:30:39Z")

</div>

Easy to find lots of threads that reference this problem, but no explanation of why this occurs and no solutions.

> [@Empty branches disappear in cluster and reappear in cluster output](https://discourse.mcneel.com/t/empty-branches-disappear-in-cluster-and-reappear-in-cluster-output/162597):
>
> Hi there, I read that this weird behavior is there since 2014 but nobody solves it. Empty branches disappear in cluster and reappear outside but this mess up the data structure and the process inside the cluster. The data is reorganized in the explode tree component. See images below. I know solutions like adding nulls to empty branches or calling branches by path but these are just workarounds to a bug. In any programming language, an empty list is also an object and should be visible.

> [@Empty branches hidden inside cluster](https://discourse.mcneel.com/t/empty-branches-hidden-inside-cluster/83001):
>
> This is an old topic but there hasn’t been an update on it for a while so I’m posting it again. all looking good from outside, but… [image] inside empty paths are missing. Clearly, this only becomes a problem for previewing an output when working inside clusters but it’s still pretty critical.

> [@Clusters removing empty branches on inputs, but only when inside the cluster](https://discourse.mcneel.com/t/clusters-removing-empty-branches-on-inputs-but-only-when-inside-the-cluster/77249):
>
> Hi, I just ran into an unexpected bug with clusters that is causing some headaches. Namely, I have some intentionally empty branches on some of my inputs that are being removed when inside the cluster. Oddly, those branches are only being removed when I am inside editing the cluster, which is actually causing me to get different results when I am outside vs inside the cluster. Outside of the cluster, my outputs are behaving as I intended, but while inside my results are all garbled because the …

> [@I love grasshopper, but not the bugs on empty branches](https://discourse.mcneel.com/t/i-love-grasshopper-but-not-the-bugs-on-empty-branches/181692):
>
> I love grasshopper, and I have used it for almost 7 years now. It is an amazing tool. But the data trees have some really strange behaviors regarding empty branches, which have caused me countless hours of pain! sweat_smileEmpty branches are not visible inside clusters The cluster works as expected but it is easy to introduce bugs when all empty branches are removed. Expression component adds null to empty bran…

> [@\[BUG\] Cluster data differences between inside and outside](https://discourse.mcneel.com/t/bug-cluster-data-differences-between-inside-and-outside/99012):
>
> There are some cluster data differences between inside and outside of the cluster. I’ve found some old topic about that. I’m using Rhino WIP.

The Clean Tree components in the file you posted are not having any effect because the _ **“problem”** _ branches are not empty, they contain 1 item.

> [@cloudsvisitor77](#):
>
> [20240602 GH CLUSTER EMPTY BRANCHES 02.gh](https://discourse.mcneel.com/uploads/short-url/3EtiR1BXJZ6I9swCQ2SPbqHaqBr.gh) (28.4 KB)
> 
> that said i tried to place clean tree outside the cluster but it does not work as shown in your post.
> 
> ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/e/a/a/eaaa1f9827796357835a0c0ba556373eeb1fc0cd.png)

Since you are passing the original datatree through your cluster, you can use the empty branches from this to cull your result. Not a fix, but a possible workaround for the case you provided.

 ![240602_cluster_branches_1](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/d/a/9dacaa2cf2d6742fd20466e8fea34827c4a23bf9.jpeg)

[20240602 GH CLUSTER EMPTY BRANCHES 02\_re.gh](https://discourse.mcneel.com/uploads/short-url/27iSkePn5xjPps7lD5jjApz8T2a.gh) (29.8 KB)

-Kevin

---

<div class="post-metadata">

**Author:** ![inno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/inno/32/544036_2.png) [@inno](https://discourse.mcneel.com/u/inno)\
**Post date:** [June 3, 2024, 10:15am UTC](https://discourse.mcneel.com/t/unexpected-branches-out-from-gh-cluster/183245/5 "2024-06-03T10:15:47Z")

</div>

these 8 curve containers:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/b/0/e/b0ebe45b555cb25b5876ccfbae11eac9411d1816.png)

will each of those Curve Parameters always contain either zero or just exactly one curve?

---

<div class="post-metadata">

**Author:** ![cloudsvisitor77](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/cloudsvisitor77/32/771524_2.png) [@cloudsvisitor77](https://discourse.mcneel.com/u/cloudsvisitor77)\
**Post date:** [June 3, 2024, 4:00pm UTC](https://discourse.mcneel.com/t/unexpected-branches-out-from-gh-cluster/183245/6 "2024-06-03T16:00:36Z")

</div>

thanks @kev.r and sorry for haven’t realized that before.

as i can see now this is an old issue and there’s no other than using your fix for the time being .

thanks for taking the time to collect the links and also for arranging the updated script.

cheers

---

<div class="post-metadata">

**Author:** ![cloudsvisitor77](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/cloudsvisitor77/32/771524_2.png) [@cloudsvisitor77](https://discourse.mcneel.com/u/cloudsvisitor77)\
**Post date:** [June 3, 2024, 4:05pm UTC](https://discourse.mcneel.com/t/unexpected-branches-out-from-gh-cluster/183245/7 "2024-06-03T16:05:47Z")

</div>

Hi @inno , sorry i got you wrong when posting the script 02 but i actually attached 3 of the seven curves in order to show the problem

when i internialise all 7 curves there are no empty branches and there is no bug.

that said this is a the script with the 7 crvs and as you can see everything is working fine in this case.

[20240602 GH CLUSTER EMPTY BRANCHES 03.gh](https://discourse.mcneel.com/uploads/short-url/ubIdtMHkHKaZwbrNqETsTG7ew5H.gh) (41.3 KB)

for the time being i will use @kev.r suggested fix, if you have any other idea please share. thanks

cheers

---

<div class="post-metadata">

**Author:** ![inno](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/inno/32/544036_2.png) [@inno](https://discourse.mcneel.com/u/inno)\
**Post date:** [June 3, 2024, 4:13pm UTC](https://discourse.mcneel.com/t/unexpected-branches-out-from-gh-cluster/183245/8 "2024-06-03T16:13:59Z")

</div>

I understand what you mean 👍 my question was about using less than the 8 curves that the definition can handle now

for instance, if you are 100% sure that each Curve Parameter will always contain either nothing or one single curve, instead of Entwine you might use a grafted merge, like this:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/4/b/8/4b8b2316474d5a23125ee8440f71a868699c910e.png)

but again, this works well only if each of your initial Curve Parameter will contain nothing or one single curve
