Skip to content

Use traits for (un)directed types #40

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

Merged
merged 3 commits into from
Feb 22, 2023
Merged

Conversation

filchristou
Copy link
Contributor

I find the definition of MetaUndirectedGraph and MetaDiGraph very constrained.
Graphs.jl solves this problem by using traits.
Here, I made the changes so that the same solution is followed.

SimpleTraits.jl is already in the Manifest as an indirect dependency due to Graphs.jl

With this solution we can now build MetaGraphs of any subtype of AbstractGraph implementing Graphs.is_directed()
Before only MetaGraphs of SimpleGraph and SimpleDiGraph could be built.

Use case

For example, if this PR, together with QuantumBFS/Multigraphs.jl#18 and QuantumBFS/Multigraphs.jl#17 are completed, we will be able to have a MetaGraph of Multigraph.
This will be a huge advantage over MetaGraphs.jl, which for now it's also only limited to SimpleGraph and SimpleDiGraph.

More discussion

I don't quite agree with the Graphs.SimpleGraph and Graphs.SimpleDiGraph methods.
To me they look like constructors and they should return a new object, and not the graph of the MetaGraph.
For this reason, we could instead have something simple like a getgraph method.

@bramtayl
Copy link
Collaborator

bramtayl commented Feb 7, 2023

Thanks! Using traits for this makes sense to me!

@bramtayl
Copy link
Collaborator

bramtayl commented Feb 7, 2023

I also agree with you about the Graphs.SimpleGraph and Graphs.SimpleDiGraph methods being confusing. We inherited this from the original MetaGraphs

@bramtayl
Copy link
Collaborator

bramtayl commented Feb 7, 2023

If you want to help maintain I could add you as a collaborator?

@filchristou
Copy link
Contributor Author

Do you have any comments on the PR ? Keep in mind that this is a breaking change, since I removed MetaDiGraph and MetaUndirectedGraph. No particular reason why I removed those and one could add them back, but they go opposite to the idea of MetaGraphNext being a general wrapper.

I also agree with you about the Graphs.SimpleGraph and Graphs.SimpleDiGraph met

I made an issue if more conversation needs to happen #42
This PR already took the liberty to remove these. Let me know if that's fine.

If you want to help maintain I could add you as a collaborator?

Yes sure! I cannot promise working consistently but I will be of help, so please go on!

@gdalle gdalle self-requested a review February 9, 2023 10:46
@bramtayl
Copy link
Collaborator

What do you think @gdalle?

@codecov
Copy link

codecov bot commented Feb 22, 2023

Codecov Report

Merging #40 (a1ef56f) into master (f1175c1) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #40      +/-   ##
==========================================
- Coverage   90.90%   90.83%   -0.08%     
==========================================
  Files           8        7       -1     
  Lines         242      240       -2     
==========================================
- Hits          220      218       -2     
  Misses         22       22              
Impacted Files Coverage Δ
src/MetaGraphsNext.jl 100.00% <ø> (ø)
src/metagraph.jl 84.61% <ø> (ø)
src/directedness.jl 100.00% <100.00%> (ø)
src/graphs.jl 83.49% <100.00%> (+0.66%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@gdalle gdalle self-requested a review February 22, 2023 09:14
@gdalle
Copy link
Member

gdalle commented Feb 22, 2023

Thanks for the great PR @filchristou, it's a really awesome idea!

@gdalle gdalle merged commit fe2a5bb into JuliaGraphs:master Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants