# vtkDijkstraGraphGeodesicPath scalar weight question

**URL:** https://discourse.vtk.org/t/vtkdijkstragraphgeodesicpath-scalar-weight-question/2663
**Category:** Support
**Created:** [February 20, 2020, 5:53pm UTC](https://discourse.vtk.org/t/vtkdijkstragraphgeodesicpath-scalar-weight-question/2663 "2020-02-20T17:53:38Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Sunderlandkyl](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sunderlandkyl/32/230_2.png) [@Sunderlandkyl](https://discourse.vtk.org/u/Sunderlandkyl)
#### Post date: [February 20, 2020, 5:53pm UTC](https://discourse.vtk.org/t/vtkdijkstragraphgeodesicpath-scalar-weight-question/2663/1 "2020-02-20T17:53:39Z")

</div>

When UseScalarWeights is enabled, the cost is calculated by dividing the distance by the squared scalar weight:  
[https://gitlab.kitware.com/vtk/vtk/blob/master/Filters/Modeling/vtkDijkstraGraphGeodesicPath.cxx#L165-169](https://gitlab.kitware.com/vtk/vtk/blob/master/Filters/Modeling/vtkDijkstraGraphGeodesicPath.cxx#L165-169)

> cost = distance/(scalar\*scalar)

Does anyone know why this equation is used instead of adding, or multipying/dividing by the scalar without squaring? My first though is that it’s to ensure that the sign is always positive, but then the following would work as well:

> cost = distance/abs(scalar)

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [February 22, 2020, 4:17pm UTC](https://discourse.vtk.org/t/vtkdijkstragraphgeodesicpath-scalar-weight-question/2663/2 "2020-02-22T16:17:44Z")

</div>

Does anyone use vtkDijkstraGraphGeodesicPath filter for drawing lines on surfaces?

We have a few ideas for improving it, especially how point scalars are used to compute the “shortest” path, but if there is no interest then we would just do these enhancements in our own repository in a derived class.
