# AbstractGraph interface assumes a continous set of vertex ids? Alternative Interface?

**URL:** https://discourse.julialang.org/t/abstractgraph-interface-assumes-a-continous-set-of-vertex-ids-alternative-interface/90268
**Category:** General Usage
**Tags:** question, package
**Created:** [November 15, 2022, 1:25am UTC](https://discourse.julialang.org/t/abstractgraph-interface-assumes-a-continous-set-of-vertex-ids-alternative-interface/90268 "2022-11-15T01:25:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Eulertin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eulertin/32/43061_2.png) [@Eulertin](https://discourse.julialang.org/u/Eulertin)
#### Post date: [November 15, 2022, 1:25am UTC](https://discourse.julialang.org/t/abstractgraph-interface-assumes-a-continous-set-of-vertex-ids-alternative-interface/90268/1 "2022-11-15T01:25:59Z")

</div>

I’ve implemented a custom Graph representation and wanted to use the functionality of the _Graphs_ package, so I’ve implemented the _AbstractGraph_ interface as explained in the packages manual here:  
[https://juliagraphs.org/Graphs.jl/dev/ecosystem/interface/](https://juliagraphs.org/Graphs.jl/dev/ecosystem/interface/)

Wanting to use some algorithms from the package, I ran into errors that, if I interpreted them right, stem from the assumption of the package that if my graph has N nodes their labels will be in 1:N. That is not the case for my graph as I keep adding and deleting nodes and need them to keep their ids so I might have 100 nodes but their labels/ids are anywhere in 1:1000.

Does anyone know if can get Graphs to work with that or if there is another Interface for graphs, that would have no issues with discontinuous ids?

I mean I could write a mapping from my labels to a continuous set for a point in time, but that seems inefficient and unelegant.

Thanks in advance!

---

<div class="post-metadata">

### Author: ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)
#### Post date: [November 15, 2022, 4:51am UTC](https://discourse.julialang.org/t/abstractgraph-interface-assumes-a-continous-set-of-vertex-ids-alternative-interface/90268/2 "2022-11-15T04:51:08Z")

</div>

You could try SimpleGraphs.jl:

> **[GitHub - scheinerman/SimpleGraphs.jl: Convenient way to handle simple graphs...](https://github.com/scheinerman/SimpleGraphs.jl)**
>
> Convenient way to handle simple graphs and digraphs - GitHub - scheinerman/SimpleGraphs.jl: Convenient way to handle simple graphs and digraphs

---

<div class="post-metadata">

### Author: ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)
#### Post date: [November 15, 2022, 5:33pm UTC](https://discourse.julialang.org/t/abstractgraph-interface-assumes-a-continous-set-of-vertex-ids-alternative-interface/90268/3 "2022-11-15T17:33:51Z")

</div>

There is also [MetaGraphsNext.jl](https://github.com/JuliaGraphs/MetaGraphsNext.jl) which allows you to work with labels, although the underlying graph remains numbered from 1 to N.  
The discussions around the Graphs.jl interface are far from settled, so feel free to contribute eg [here](https://github.com/JuliaGraphs/Graphs.jl/issues/146)

---

<div class="post-metadata">

### Author: ![Eulertin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eulertin/32/43061_2.png) [@Eulertin](https://discourse.julialang.org/u/Eulertin)
#### Post date: [November 16, 2022, 1:51am UTC](https://discourse.julialang.org/t/abstractgraph-interface-assumes-a-continous-set-of-vertex-ids-alternative-interface/90268/4 "2022-11-16T01:51:54Z")

</div>

Thank you for your answers!

Looks like I’ll have to write a mapping from my labels to {1,…,N} then for now. But I’m excited to see that the currently discussed definition of the interface plans to not assume range based labels but rather have it as a special trait.
