JuliaGraphs / JuliaGraphs/Graphs.jl

Contiguous vertices a requirement?

Open
#297 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
538
Forks
128
Avg merge
10h 25m
Merged PRs (30d)
2

Description

I read through the documentation for Graphs.jl and I understood that the provided implementations of AbstractGraph (e.g, SimpleGraph) assumed that the vertices were contiguous and started from 1 (e.g. 1, 2, 3, ...). But I didn't realize this was a requirement. So I implemented all the necessary functions for a Graph where the vertices could be any set of integers (e.g.,, 2, 7, 25, ...). I was able to implement all the methods associated with the AbstractGraph type, but when I went to run dijkstra_shortest_paths), I immediately hit an error.

Looking at the code for dijkstra_shortest_path, it seems clear that it assumes this continguous from 1 semantics because it allocates the dist array as dists = fill(typemax(T), nvg) and then uses the vertices as indices into the dist array, e.g., dists[src] = zero(T). Since the array's indices must be contiguous starting from 1 (no?) this implies so must the vertices.

So either I'm missing something and disjointed sets of integers can be used as vertices (although I don't see how given the implementation of dijkstra_shortest_path, but I'm a newcomer to Julia so perhaps I'm overlooking something) or I missed something in the documentation that mentions that all graphs must have vertices must start from 1 and cannot be disjoint in which case I'm scratching my head as to why both nv and vertices functions are required (since vertices would always be 1:nv(g)).

Assuming I am correct and that it is assumed that vertices must be contiguous and start from 1, then it seems like there should be some mention of this here in the documentation, no?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Graphs.vertices documentation and the dijkstra_shortest_paths implementation mentioned in the issue. Confirm whether AbstractGraph requires vertices to be contiguous and 1-based, then document that requirement in the interface documentation so the supported vertex representation is explicit.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.