# How can I add weights to vertices based on the topological distance?

Mesh Weights Test Mesh v0.gh (220.5 KB)

How can I assign weights (ranging from 0 to 1.000) to vertices/edges/faces based on their topological distance from one or several vertices/edges/faces within the same mesh?

By topological distance, I am referring to the number of nodes away from the attractor vertice(s)/edge(s)/face(s).

I hope the solution is relatively fast.
Thank you!

Kangaroo has a vertex neighbors component. You can use that to calculate e.g. the average distance from a vert to its neighbors.

2024-01-16_avg_vert_distance.gh (7.6 KB)

Thank you very much! @Bernd_MĂ¶ller
I am very glad to learn the Vertex Neighbours, it is useful in solving many problems.
But what I am seeking is, that maybe I was not clear, I like to calculate the graph distance from nodes to node(Vs to V, Es to E, Fs to F), and I like to turn the quantity of the nodes between into weights.

After composing my question, I did a little bit of research. So now I am thinking it must be a graph problem. There are indeed many components in GH that show the topology of mesh/lines/points, but no one returns the distance information, so I am seeking help here.

Hi @Quan_Li
wouldnâ€™t this distance be the calculated length of A* shortest path?

Ah, sorry, I jumped to conclusions a bit too early
Besides the shortest path mentioned by Toni, I had to think of the heat method, see for example this thread: Heat Method - Grasshopper - McNeel Forum

I have finally found the method for doing it. The solution hides within Mesh+.

1 Like

If you want to follow the edges, you could use shortest path. Length is 1 for each edge and at the end you donâ€™t use the length but the number of segments.

Some of my tools gives something similar but more smooth

You can look at the flow

Adding Weights to Vertex based on the topological distance Nautilus.gh (218.2 KB)

And Cluster Mesh can give you the faces connections, you can use the lines to make a network.

Adding Weights to Vertex based on the topological distance Nautilus edges.gh (218 KB)

1 Like

I added Faces Ring in Nautilus 1.7
In order to select the departure points you can uses vertex index, Curves and points

You can use the weights to smooth them

If you donâ€™t want the random colors there is now a menu

mesh face rings.gh (10.7 KB)