-
Notifications
You must be signed in to change notification settings - Fork 328
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
Proposal: Future of this crate #551
Comments
becoming a new long-term maintainer sounds great, I'm happy to read about your initiative. I am not able to be very active in this. |
Thank you for your kind words @bluss ! I plan on keeping a change log of all changes while doing them (as to not forget anything) as well as maybe write up a blog post once ready. (Tho I don't know where to publish it to just yet) I fully expected to work on this by myself so no worries! To adjust to the resource constraints of the team my proposed plan of action is (depending on how comfortable you are with it):
The last step will only happen once (A) enough test coverage has been achieved - I am aiming for 90+% (I know that coverage is not the best statistic, but it's a good indicator IMO) (B) everything has been properly documented. While working on the changes I'd be happy to answer any questions and/or report progress! While doing all of this I'd love to be able to privately message you in case I find something that is unclear to me (I don't expect this to be a regular occurrence) |
I see that you are asking me, but I'm not the active maintainer unfortunately, so we'll have to ask everyone. Maybe @ABorgna has some thoughts. |
That sounds like a great proposal! Some thoughts
These are quite a few ideas. I think they can be implemented each on their own, and we can progressively merge them. I just added you as a collaborator. Thanks for offering your time ! |
@ABorgna Can I add you as direct owner of the crate on petgraph for future proofness? Ownership through team is not like full ownership, that I know. Great that petgraph has you! And let me know if there is somthing admin-y that I need to do. If one would contact me, maybe it works to contact me with dms from #rust-sci:matrix.org on Matrix/Element or https://social.linux.pizza/@bluss on mastodon. The latter is the likely the best, right now. |
Sure! |
The current trait_template! macro and what it does is truly a monster. An achievement at the time, funny still, but it would be great to replace all of that with HRTB or GAT systems for visitor traits. And that has always been the plan! GAT just took some time to arrive.. |
That is the plan! I want to eliminate most, if not all, macros used to implement traits. I have made several proposals in the linked issue. Due to the complexity of the iterators (and their usage of GATs), I'd like to wait until we have decided how to "modernize" all the other traits. Here experimentation is key. |
@ABorgna I seem unable to create new branches, meaning I cannot create my working branches (without a fork) or the |
Can you check now? I updated the permissions, I hope that's enough. |
Didn't seem to have worked, I still get:
|
@bluss I've been looking through the code and have been wondering, is there a specific reason why |
Unrelated to the initial proposal, but maybe someone knows here: was there any specific reason the It seems to be non-standard, and from what I gathered, there are several "standard-ish" formats out there, like GEXF (being the most popular, but also being XML based), Cytoscape JSON, sigma.js. The reason I am asking is because I think adhering to a common standard would be quite beneficial, it would allow graphs generated in e.g. petgraph be serialized, loaded in networkx then visualized in cytoscape. |
I just contributed one algorithm in the past, but here are some of my thoughts. I have been doing some independent experimentation in this repository (this is not to promote it, just a reference for those who are interested in the ideas that I am going to present).
These are the main ones. Everything would be a massive breaking change. I would definitely understand that it would not be worthy. Or deciding to postpone it and release a version with traits rework first, which in itself will probably be quite significant. Regarding the comments about |
Hey @pnevyk, thank you for your opinion. Mine are pretty closely aligned with yours, which is excellent! I already did (1) in #561 (with backward-compatible imports in the main crate). All in all, these are all quite drastic changes (with mine combined), and I have been contemplating just ripping off the band-aid and also touching up the algorithms as well. I like the idea of using the builder pattern for the API; it may make sense to facilitate the builder-lite pattern. You have an entry point: Then on
Where The goal is to convert every algorithm into a generic one, so no more About 4: that is precisely what #561 is doing; everything is its crate, so you have About (by the way I like the API of matching that you created) |
This sounds like a great compromise!
I like this.
Hmm, I took a look and it's not precisely what I meant, if I didn't overlook something. My idea was to allow something like this: let matrix = Graph::new_in(AdjMatrix::new());
let csr = Graph::new_in(Csr::new()); This might allow to be minimalistic with required API on the storages themselves, but implement variety of methods on the
That's exactly what I had in mind.
I think these could be orthogonal features. When you implement serde
I think it would be good to proceed in smaller steps, especially as petgraph is quite an established library. Smaller steps have also higher chance for being reviewed and accepted by the maintainers. But it's good to have an ambitious vision :) |
I really, really like this. I haven't considered such an API just yet, but the idea that you could simply do the following: struct Graph<S: Storage> {...} ... sounds like a very interesting idea. It would remove the burden of every single graph implementation to implement every single trait (which we do right now :/) and would make the API a whole lot cleaner. There are some things to consider, as there are some differences between graphs that we currently have; some do not support self-loops, and others do not support multiple edges between the same nodes, but I wonder if we can overcome those, by only having a select number of traits that I will create a competing proposal to #552 to explore this idea further. At the top of my head,
... and I think that's it 🤔 ... but I guess (like you mentioned) this would be "even more" of a breaking change than I am proposing. ... but now that I think about it, the trait rework and your allocator API style idea do not necessarily XOR themselves; what I could imagine is that |
But let's keep this thread relatively focused on the plan that you proposed in your original post. I just wanted to share the ideas so they could potentially influence the work somehow, but I definitely don't want to put even more work on you. If you are interested, you could have a look on my work, where I implemented the ideas that I presented here. It might be useful. I don't link it to promote my "library" here, personally I would rather have these features in petgraph. |
@indietyp is there a chance you can merge #547 ? I'm asking because the PR contains a simple fix for an integer overflow resulting from an ancient default setting that prevents the MatrixGraph from silently overwriting nodes when hitting the 50k limit. -No breaking changes
BTW, totally love the new generic storage design. Thank you for all your good work. |
My current plan of action is as follows:
I will likely change |
@indietyp setting in generic is perfectly fine for the time being. Can you do that or should I propose a PR? I am asking for this patch because I am about to release my crate which currently depends on a patched fork of petgraph, but I would rather prefer to switch to the official release if its possible this gets fixed. |
What I mean is, wouldn't you be able to do: |
Yea, that did the trick for the time being. I just figured out, when doing
that, one has to call either default() or with_capacity()
because new somehow gives an error as it is not generic over index.
Anyway, thanks for the pointer. Issue is solved.
… Message ID: ***@***.***>
|
@indietyp about the serialization format, it's just bespoke, written to be a version-stable format (instead of an autoderived one). Using a standard format would be better, but does that fit into the serde model, and how does the user's weight types fit into that, they can be arbitrary serde serialized entities too. @indietyp about DfsSpace, I don't really know, if the code looks like it has no use, it can of course be refactored. |
I've done some research into different formats and it seems like the best way to do this is to simply allow exports to defined formats as well as a default one. I think (but need to check) there's a format supported by NetworkX that supports arbitrary node and and edge weights. about DfsSpace during my exhaustive refactoring (which is now finally going to continue as I have a bit more free time) DfsSpace has gone away. I am also sorry for the delay, 0.7.0 has transformed a bit in scope and what it does and it has been quite a bit more work than anticipated^^ |
Well, don't be sorry, I haven't had the mind space to work on this myself. We all want the project to be stable and have a community of contributors, that's ultimately better than any single individuals carrying it by themselves. Is it possible to reduce the scope or release an alpha version early? Or maybe some other way of of breaking it up into multiple and incremental PRs. As big as the 0.7 PR is now, it's probably better to merge it and develop in the tree instead of a PR, that could be more fun? If 0.6.x patches are needed, a branch could track that. |
Yea for sure we can do that! I planned for an alpha release soon, I think I've got the essentials finally figured out (as to how I want things to work, looking at implementations etc) I am currently working on a comprehensive test suite for graph implementations and once that's done I think I'd be ready to open this up in tree. This is because we then have
All of these can then be used to port existing code to 0.7.0 quite easily, but finding the right balance of how things might look like was a challenge (hence why I took it on mostly alone) It might make sense here to create a project board with open things for 0.7.0 release and see when we can create an alpha. The most demotivating thing for me rn was creating documentation as that is quite the laborious task, so for example help on that front would be huge. I thought about delaying the documentation until it's in an alpha state/ready to ship, but I found that in some cases formulating the documentation lead to some more introspection and redefinition. |
after the graph test suite my next goal was to either move to graph views (for reverse etc) and/or traversal algorithms. I really want to push this forward in the coming weeks as I (personally) really like the new direction of the project that developed over the last months. |
about incremental, it might be best to focus on the most common algorithms and adapt/implement those and then release an alpha. Most things besides other graph implementations are already working. |
Hi!
Thank you all for creating such an incredible library. I use
petgraph
nearly on a day-to-day basis in both my professional and personal projects. After observing progress (and the different issues) over the last couple of months, I thought that it might make sense for me to contribute topetgraph
itself, not only potentially adding some new functionality but also maybe leadpetgraph
into a new direction while maintaining its usefulness and broad adoption.After thinking about it, I have come up with some action points I'd like to realize, and I know they are pretty drastic. Nevertheless, to not duplicate work or implementation, it makes sense to build onto the foundation of the existing
petgraph
.If this is suitable for this crate, please let me know, and I'll start working on it. I still have some open questions, like:
next
branch might make sense)Thank you so much for considering all of this! (and I guess this is where I need to mention @bluss?) I look forward to working with you all!
I am open to having a lively discussion and going more in-depth, potentially leading to a change in plans.
Plan
1. Reorganization
Split up the crate:
petgraph-core
: Includes all traits. To reduce churn, we should consider stabilizing this first and avoid breaking changes. This way, other crates can feel comfortable implementing their algorithms onto it.petgraph-graph
: includesGraph
andStableGraph
(as they are commonly used interchangeably, I'd bundle them in a single crate)petgraph-adjacency-list
: includesList
petgraph-csr
: includesCSR
graphpetgraph-graphmap
: includesGraphMap
petgraph-matrix
: includesMatrixGraph
(name might need changes, to not confuse with matrices in a non-graph type sense)petgraph-algorithms
: includes all algorithms currently in petgraph; we might want to feature gate them (not onlyscc
and friends, but also, if possible,Bfs
)petgraph-dot
: support fordot
writing (and maybe reading in the future)petgraph
: re-export of all sub-crates, main entry point for binaries(names are ofc up to debate)
2. GATification (#552)
This would raise the MSRV to 1.65 but enable a lot more flexibility; every trait that could benefit from this should be converted into its GAT form, allowing things like mutable vs. reference access.
3. Trait rework (#552)
Think if we can extend the current set of traits to enable more flexible approaches, things like:
Filter
,FilterMap
, andMap
as traits.IMO there are a lot of valuable traits that are hidden or need to be correctly explained. I want to surface traits more as well as adequately describe them. Some traits, like
IntoNeighbours
, are (again IMO) named quite misleading. While technically correct, it is only implemented for&Graph
and friends, meaning it is non-consuming (even thoInto
as a trait is consuming).We should also look at all functions implemented directly and see if we can reconcile them into traits. Even marker traits may be of use.
4. Backlog Bonanza
Over the past few months (/ year?), many issues and pull requests have been opened once the new foundation of the crate has been created. I want to go through all issues and address (or close them).
5. My friend, my foe NetworkX
I enjoy the NetworkX library from Python, and I miss some of the capabilities it provided; as a long-term plan, I'd love to be able to use similar functionality in Rust. I think
petgraph
has the potential to live up to it.This includes the rich set of graph algorithms it provides. I want petgraph to be able to do most of the possible things in NetworkX. I want to implement most of the functions and generators that NetworkX provides (and even some novel ones?) so that petgraph is a comprehensive toolkit for graph analysis.
6. no-std
Judging from the issues (and my own selfish needs), I think
no-std
is a somewhat important goal for such a "fundamental" library and enables the use of petgraph in many more use cases. Initially, I'd like petgraph to be available withalloc
(I don't think that should be too hard™). In the future, we might be able also to makealloc
opt-in, creating a separate crate for, e.g., fixed-size graphs or use of the nightly allocator API.7. CI
While doing some major rework on the library itself, I'd like to touch up some areas, adding more tests, benchmarks, and coverage statistics, as well as tests using
cargo-hack
to ensure that all feature permutations work.8. Documentation Touchup
I think the existing documentation is already excellent, but the docs in the
lib.rs
file do not adequately introduce the available traits, etc.; while doing this rework, I'd like to review the docs and add some sections.Timeline
This would most definitely be a breaking change (warranting a
0.7.0
release). 1-3 are more immediate goals, while I'd like to focus on 4-8 longer term.I guess that 1-3 might take one to three months maximum, depending on review speed, discussions, etc., for 4-8, as they are more of an ongoing effort, I have no time guesstimate.
The text was updated successfully, but these errors were encountered: