# How can i set distance(len) for an Edge?

**URL:** <https://igraph.discourse.group/t/how-can-i-set-distance-len-for-an-edge/458>\
**Category:** Usage\
**Tags:** Python\
**Created:** [24 September 2020 15:08 UTC](https://igraph.discourse.group/t/how-can-i-set-distance-len-for-an-edge/458 "2020-09-24T15:08:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RenzoPrats](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@RenzoPrats](https://igraph.discourse.group/u/RenzoPrats)\
**Post date:** [24 September 2020 15:08 UTC](https://igraph.discourse.group/t/how-can-i-set-distance-len-for-an-edge/458/1 "2020-09-24T15:08:41Z")

</div>

I’m new in this library and I read the tutorial but i still in doubt. I need to creating a project using Dijkstra’s algorithm, so then I have a map and I need to calculate the shortest path. To do that I need to set len(distance) in the edges, for example I have to go from New York to Boston there’s 220 miles, so this edge that connect these citys need to has the value of 220. With what function can I do that? and how can I after from setting all the distances beetween the cities calculate the shortest path?

---

<div class="post-metadata">

**Author:** ![RenzoPrats](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@RenzoPrats](https://igraph.discourse.group/u/RenzoPrats)\
**Post date:** [24 September 2020 20:02 UTC](https://igraph.discourse.group/t/how-can-i-set-distance-len-for-an-edge/458/2 "2020-09-24T20:02:05Z")

</div>

I think that I understood everything. But now I’m in doubt, how can I draw a graph that works like this, for exemple i have 3 vertices A, B and C, the vertice A are 50km distant of the vertice B and the vertice A are 20km distant of the vertice C, so I want a graph that vertice A is closer to C than to B
