-
Notifications
You must be signed in to change notification settings - Fork 184
Scaffolding discussion #527
Comments
One of the lessons I learned from the Julia type system is that shallow hierarchies are preferred over deep hierarchies both from the designer perspective as well as from the user perspective. It is very hard to contribute to code with deep hierarchies. What other types do you see fitting in this proposal besides Graph and Digraph? |
Well, what I was thinking is something like
to mimic what we have now for Graph. This allows us to do, for example,
to specify a graph that has metadata for vertices, and
etc. |
A question from someone that is still getting used to the Julia type system as it evolves... Why in the option you showed there are two abstract types instead of one? Maybe my question is more about what motivates the design with both abstract AbstractGraph
type Graph <: AbstractGraph end
type DiGraph <: AbstractGraph end |
Yes, of course - but I thought it might be interesting to explore having separate types. This solves a bunch of issues (#401, |
I need to use the type system more before I can counter argue, but my impression is that we could have the separation you mentioned with a single abstract base and dispatch on the concrete types as usual. I am looking forward to see how the changes will unfold 😊 |
Yes, you can, except it would be a bit harder to have unique edge types for Graphs and DiGraphs without having different types for the graph structures themselves. There's more than one way to do this, and I'm not particularly worried at this point about getting it perfect. |
Thinking about this some more, I don't think we want to go away from the abstract AbstractGraph{VI<:Integer}
abstract AbstractDiGraph{VI<:Integer}
type Graph{VI ,VD,ED} <: AbstractGraph{VI}
vind::UnitRange{VI}
vertices::VD # must be indexable via vind
edges::ED
fadjlist::Vector{Vector{VI}}
end This looks complicated, and it is, but it would be easier if we could get rid of the Edited: we might not even need to parameterize |
What about the following?
Then you could get the types from any implementation, but don't need to specify it with parameterized types at the AbstractGraph level. |
We have to be careful with such constructs in Julia, at the moment they are not quite practical like C++ metaprogramming, I had issues trying to inspect the type at the time of usage and it seems a solution is still not implemented in the language: https://discourse.julialang.org/t/recovering-parameter-type-from-parameter-list/1343/5?u=juliohm |
One thing that we can do without any impact on the code is to replace every occurrence of |
Yeah that would be good. |
That won't compile as you haven't parameterized |
I've been playing around with this most of the day. Here's what I've found makes the most sense:
Rationale / explanation
|
Does AbstractSimpleGraph mean anything that represents a graph with no multiedges? |
That, and (possibly?) with a sparse adjacency list, and no vertex or edge metadata. |
We should write down the names we will use for these types of graphs. Maybe these terms?
All graphs are accessed primarily through |
or |
Yeah I was going to add that and then remembered that you can always build |
We're doing that with Edgeiter now, right? That is, we're using the adjacency lists to generate the iterator. |
See #541 please. |
I'm closing this out due to the advanced progress of #541. |
Ref #526
Option 1:
We will need
index(V)
in order to store adjacencies efficiently, andV
should have an efficient reverse function. (This argues for a Dict-like structure.)The text was updated successfully, but these errors were encountered: