# LightGraphs users (and other interested parties): please opine below

**URL:** <https://discourse.julialang.org/t/lightgraphs-users-and-other-interested-parties-please-opine-below/37660>\
**Category:** Graphs\
**Tags:** question, proposal, lightgraphs, poll, survey\
**Created:** [April 15, 2020, 6:45pm UTC](https://discourse.julialang.org/t/lightgraphs-users-and-other-interested-parties-please-opine-below/37660 "2020-04-15T18:45:22Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Post date:** [April 19, 2020, 5:02pm UTC](https://discourse.julialang.org/t/lightgraphs-users-and-other-interested-parties-please-opine-below/37660/21 "2020-04-19T17:02:13Z")

</div>

> [@abulak](#):
>
> Ok, but then what is the point of `ShortestPaths.Dijkstra` struct, when it will be used only in `ShortestPaths.shortest_path` function?

consider when you want to do Dijkstra with the same parameters across multiple graphs, and different shortest paths algorithms on the same graph:

```julia
d_alg = ShortestPaths.Dijkstra(track_vertices=true)
dsp1 = shortest_paths(g1, 1, d_alg)
dsp11 = shortest_paths(g1, 1, distance_matrix, d_alg)
for sp_alg in [Dijkstra(), BellmanFord()]
    shortest_paths(g, 1, distance_matrix, sp_alg)
end

```

---

<div class="post-metadata">

**Author:** ![anon67531922](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anon67531922](https://discourse.julialang.org/u/anon67531922)\
**Post date:** [April 24, 2020, 8:44am UTC](https://discourse.julialang.org/t/lightgraphs-users-and-other-interested-parties-please-opine-below/37660/22 "2020-04-24T08:44:39Z")

</div>

What do you think of Zach’s [trait-like idea](https://discourse.julialang.org/t/lightgraphs-users-and-other-interested-parties-please-opine-below/37660/12)?

```julia
d_alg = ShortestPaths.Dijkstra(track_vertices=true)

```

becomes

```julia
d_alg = ShortestPaths.algorithm(Dijkstra(), track_vertices=true)

```

and you only have one `Dijkstra` struct (or something).

---

<div class="post-metadata">

**Author:** ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Post date:** [April 24, 2020, 3:32pm UTC](https://discourse.julialang.org/t/lightgraphs-users-and-other-interested-parties-please-opine-below/37660/23 "2020-04-24T15:32:13Z")

</div>

Hm. That could work. The only disadvantage I see right now – and it’s not a huge one – is that the “track\_vertices” is a parameter of the `ShortestPaths.algorithm` and not `Dijkstra`. From an abstraction perspective, this doesn’t make sense, as `track_vertices` is specific to `Dijkstra` and not, say, `FloydWarshall`. We would have to throw errors in that case, and it would be really complex to handle defaults.

It’s a really interesting approach though. I need to give it more thought.

---

<div class="post-metadata">

**Author:** ![anon67531922](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anon67531922](https://discourse.julialang.org/u/anon67531922)\
**Post date:** [April 24, 2020, 7:57pm UTC](https://discourse.julialang.org/t/lightgraphs-users-and-other-interested-parties-please-opine-below/37660/24 "2020-04-24T19:57:37Z")

</div>

Sure, but why would you need to handle default arguments for other algorithms. When you call `algorithm` with a Dijkstra argument, it will dispatch on that particular method that can have different kwargs than other methods (unless I’m confused… again 😅).

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [April 25, 2020, 9:12am UTC](https://discourse.julialang.org/t/lightgraphs-users-and-other-interested-parties-please-opine-below/37660/25 "2020-04-25T09:12:11Z")

</div>

Right now you have:

```julia
function Dijkstra(;all_paths=false, track_vertices=false, maxdist=typemax(Float64))
    ...
end

```

What I’m suggesting would probably be implemented like:

```julia
function PathParams(algo::Dijkstra; all_paths=false, track_vertices=false, maxsdist=typemax(Float64))
    PathParams( algo, (all_paths=all_paths, track_vertices=track_vertices, maxsdist=maxsdist))
end

function PathParams(algo::FloydWarshal)
    PathParams(algo, NamedTuple((),Tuple{})())
end

```

I could come up with some combination of multiple dispatch and `kwargs...` to throw more specific error messages. If you feel like it’s the right approach I’d be happy to iron out more specifics of implementation.

---

<div class="post-metadata">

**Author:** ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)\
**Post date:** [April 25, 2020, 4:21pm UTC](https://discourse.julialang.org/t/lightgraphs-users-and-other-interested-parties-please-opine-below/37660/26 "2020-04-25T16:21:23Z")

</div>

I need to think about this a bit more, so please hold off on doing any work 🙂 At first blush it looks overly complicated.

I’m also rethinking my initial bias to not export the structs. It turns out there are some real advantages to exporting them (discoverability, for one), and we might be able to reduce the mane conflicts another way. So many choices!

[Previous page](https://discourse.julialang.org/t/lightgraphs-users-and-other-interested-parties-please-opine-below/37660.md?page=1)
