Make objects behave like graphs without plugging them into type hierarchy
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 22/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- julia
- Domain
- backend-api-design
Research direction
No files, tests, or implementation entry points are named. Start by reviewing the Tables.jl inspiration and the proposed GraphsBase traits and iterator methods, then inspect the existing GraphsBase interface. Done would require an agreed design for making external objects usable by graph algorithms.
Written by the indexing model from the issue text.
Description
I'm writing this at a request of @gdalle to pool random design ideas ;)
Aim
I'd be great if we could make other objects behave like graphs, cheaply without plugging into type hierarchy.
This idea is inspired by the design of Tables.jl which is exemplified by this discourse post.
TLDR: It's very easy to make things behave like row/column based Tables without plugging into any type system.
Usecase
I have my separate type-system where I implement graph-like structures, but focusing on other aspects (deterministic? complete/regular? etc.) It would be very convenient to define just a bunch of methods (like iterators ;)) to make my structures behave like graphs and work with graphs algorithms.
Example (?)
I have a dfsa (deterministic finite state automaton = directed, labeled graph); I'd like to find shortest loop in it. Run a backtrack search on it.
here is (it's just an example, not a proposal!) a rough way one could think in terms of code about this:
const GB = GraphsBase
GB.isgraph(x::Any) = fale # the default
GB.Directness(::Type{...}) # GB.Directed()/GB.Undirected()/...
GB.Simplicity(::Type{...}) # GB.IsSimpleGraph()/GB.IsMultiGraph()/GB.IsHypergraph()/...
GB.Eagerness(::Type{...}) # GB.Eager()/GB.Lazy() # if vertices edges are given only locally
GB.vertex_type(::Type{...})
GB.edge_type(::Type{...})
.... # and (many?) more
and (based on those traits) a separate sets of interface functions
GB.vertices(graph) = GB.vertices(graph) # an iterator over vertices
GB.neighbours(graph, vertex) # required if GB.Undirected()
GB.out_neighbours(graph, vertex) # which is different from
GB.in_neighbours(graph, vertex) # these two are only required for GB.Directed()
GB.hasedge(graph, vertex, edge) # if graph is GB.Lazy(), otherwise
GB.hasedge(graph, edge)
... # and so on, these are just examples, not a fixed proposal
This way graph can stay un-typed and it'd be easy to "turn anything into a graph"™, including e.g. BitMatrix (hopefully without committing type piracy).
Cons:
- potentially hard/complex "dispatch" path (but JuMP is an example that even more complex designs are possible ;);
- explosion of different methods (signatures);
- no clear type structure that we all love...
- Dominant language
- Julia
- Stars
- 11
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaGraphs/GraphsBase.jl
-
Constructors for 2.0Openquestion
Difficulty 5/5 Over a week Newbie friendliness 25/100
JuliaGraphs/GraphsBase.jl#34 ·
-
question
Difficulty 5/5 Over a week Newbie friendliness 15/100
JuliaGraphs/GraphsBase.jl#28 ·
-
question
Difficulty 5/5 Over a week Newbie friendliness 25/100
JuliaGraphs/GraphsBase.jl#27 · 1 comment · 1 reaction ·
-
question
Difficulty 5/5 Over a week Newbie friendliness 25/100
JuliaGraphs/GraphsBase.jl#25 · 3 comments · 1 reaction ·
-
question
Difficulty 5/5 Over a week Newbie friendliness 25/100
JuliaGraphs/GraphsBase.jl#24 ·
All issues in JuliaGraphs/GraphsBase.jl
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
JuliaStats/LogExpFunctions.jl#134 · 2 comments ·
-
code bug PowerSystems 6.0
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Sienna-Platform/PowerSystems.jl#1849 ·
Maintainers usually reply within 7 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
FluxML/Metalhead.jl#407 ·
Maintainers usually reply within 1 day