JuliaGraphs / JuliaGraphs/Graphs.jl

`SimpleGraph(::Base.OneTo)`

Open
#365 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I think it would be helpful to add constructors:

SimpleGraph(Base.OneTo(4)) == SimpleGraph(4)
SimpleDiGraph(Base.OneTo(4)) == SimpleDiGraph(4)

representing the more general concept of constructing a graph from a set of vertices. It would enable writing generic code like:

rem_all_edges(g::AbstractGraph) = typeof(g)(vertices(g))

which would work with graphs that don't have simple vertices.

This is analogous to constructing Julia arrays from axes:

julia> zeros(Base.OneTo(3), Base.OneTo(3))
3×3 Matrix{Float64}:
 0.0  0.0  0.0
 0.0  0.0  0.0
 0.0  0.0  0.0

(though for whatever reason Matrix{Float64}(undef, (Base.OneTo(3), Base.OneTo(3))) doesn't work).

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

The issue names the SimpleGraph and SimpleDiGraph constructors but no files or tests. Start by locating those constructor entry points and the existing vertex-handling behavior; done means both Base.OneTo examples work and the generic rem_all_edges pattern can construct an equivalent graph.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.