Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructors for 2.0 #34

Open
etiennedeg opened this issue Apr 28, 2024 · 0 comments
Open

Constructors for 2.0 #34

etiennedeg opened this issue Apr 28, 2024 · 0 comments
Labels
question Further information is requested

Comments

@etiennedeg
Copy link
Member

etiennedeg commented Apr 28, 2024

Here is a thread for discussing the constructors for Graphs 2.0

Current constructors

Constructors for SimpleGraph

  • SimpleGraph{T}() : empty graph
  • SimpleGraph{T}(nv::Integer) : graph with no edges
  • SimpleGraph{T}(nv::Integer, ne::Integer) : random graph (erdos-renyi)
  • SimpleGraph(::Type{T}) : empty graph
  • SimpleGraph(nv::Integer, ne::Integer, edgestream::Channel) : add edges from the stream until stream end or we reach ne edges.
  • SimpleGraphFromIterator(edgelist)
  • SimpleGraph(adjmx::AbstractMatrix)
  • SimpleGraph{T}(g::AbstractGraph)
  • SimpleGraph(edge_list::Vector{SimpleGraphEdge{T}})

Goals for 2.0

We will have a new concrete graph type Graph{V} which can represent arbitrary vertices.
We would need new constructors to be able to construct such new graphs.

Instead of passing nv, we should provide a list (or even an iterator ?) of the vertices of the graph.

As the type of vertices can be arbitrary, the type signatures of generators can quickly become a mess / incompatible

Also we will need to support multigraphs

My proposal

  • Graph{V}() and Graph(::Type{V})should be unambiguous
  • Remove SimpleGraph{T}(nv::Integer, ne::Integer) (much better to call explicitly erdos-renyi)
  • I don't really get this one SimpleGraph(nv::Integer, ne::Integer, edgestream::Channel), I think It does not add much to SimpleGraphFromIterator
  • Keep Graph{T<:Integer}(nv::Integer)
  • Use keywords for other generators:
    • Graph{V<:Integer}(adjmx=adjmx)
    • (Multi)Graph{V}(edge_list=edge_list)
    • (Multi)Graph{V}(vertices=vertices)
    • (Multi)Graph{V}(vertices=vertices::Vector{V})
    • Graph{V}(vertices=vertices::Vector{V}, adjmx=adjmx)
    • (Multi)Graph{V}(vertices=vertices::Vector{V}, edge_list=edge_list)

Is this proposal sound?
Do you have some other ideas of generators? A better proposal?

@etiennedeg etiennedeg added the question Further information is requested label Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant