# Adjacent elements of a Vertex in Meshes.jl

**URL:** <https://discourse.julialang.org/t/adjacent-elements-of-a-vertex-in-meshes-jl/131900>\
**Category:** Visualization\
**Tags:** meshes\
**Created:** [August 27, 2025, 9:44pm UTC](https://discourse.julialang.org/t/adjacent-elements-of-a-vertex-in-meshes-jl/131900 "2025-08-27T21:44:19Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![raman\_kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raman_kumar/32/26782_2.png) [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Post date:** [August 29, 2025, 9:13pm UTC](https://discourse.julialang.org/t/adjacent-elements-of-a-vertex-in-meshes-jl/131900/3 "2025-08-29T21:13:37Z")

</div>

For my mesh i have a element’s color matrix . This code can be used to create vertex colors when our data don’t have color for vertex. It takes vertex color as average of colors in adjacent elements.

```julia-auto
vertex_color = Float64[]
for i in 1:nelements(g)
    el= element(g,i)
    bd = Boundary{3,0}(topology(g))(i)	#Ntuple of vertex ids of i-th element
    for id in bd
		adels= Coboundary{0,3}(topology(g))(id)	#Ntuple of element ids adjacent to this vertex
		clct = collect(Element_color[(elem2cart(topology(g),idx))...] for idx in adels)	#position of i-th element in grid	
		push!(vertex_color, sum(clct)/length(clct))
	end
	@inline viz!(el, color =vertex_color, alpha=0.2)
	#@show clr
end

```

Can you tell more efficient version of this code? Thanks.

---

_[View the full topic](https://discourse.julialang.org/t/adjacent-elements-of-a-vertex-in-meshes-jl/131900)._
