-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Added :class:.DiGraph
, a mobject representing directed graphs
#2974
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First things first: thanks for your efforts, and sorry for the long wait! One problem I currently see with this approach is that it intertwines what is needed to construct a graph and what is needed to construct a digraph a fair amount -- something that would perhaps be better if it were separated a bit more cleanly.
What do you think about this:
- The current implementation of
Graph
is moved toGenericGraph
(which is not exposed to users), and new classesGraph
andDiGraph
are implemented. GenericGraph.__init__
could be slightly refactored to move code specific to one implementation in a separate method, the corresponding code is moved to the respective special class, and implemented as araise NotImplementedError
in the generic class.- Otherwise there won't be a lot of code required for
Graph
andDiGraph
; the main thing would still be that the default argument to the proposedconstructor
/graph_type
is fixed to the undirected and directed version, respectively.
Regardless of this suggestion for refactoring: the documentation build currently fails, something is wrong with the proposed example -- and the tests are failing due to the change with passing vertex centers vs. the vertex objects to the edge mobjectsm, and/or the change in the updater function. This has to be fixed before the PR can be merged.
Somehow this PR has passed under my radar several releases in a row, sorry. I've just skimmed over the current implementation, it looks good to me! I'd like to do some more tests tomorrow, and there are some details I'd like to change about the docstring of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much again for your contribution! I sat down and improved a bunch of things:
Graph
,Digraph
,GenericGraph
now all have docstrings with documented parameters,- Examples have been moved from the (practically abstract)
GenericGraph
base class toGraph
, - I've removed the proposed
graph_type
keyword argument and instead introduced a bunch of graph class specific methods (nothing too exciting; one method for populating the.edges
attribute, and another one for determining the empty networkx graph class) - While doing so, I've also simplified the logic for the
tip_shape
settings; everything should still work as expected, - and one last, technically breaking change: I've cleaned up the weird design decision regarding edges in undirected graphs; now the tuple representing the edge in
edge_config
etc. has to be in the same order as it is specified in theedges
list -- further unifying the code between directed and undirected graphs.
Tests should pass (and otherwise I'll fix remaining issues); I'll leave this open for a few more hours in case anyone declares interest in taking a closer look at this -- and otherwise this PR will finally get merged. :-)
.DiGraph
, a mobject representing directed graphs
Great! Thank you for accepting this PR. Any ideas when the new Manim version will be released? 😊 |
In a few hours, see #3198 :-) |
Overview: What does this pull request change?
Graph
Mobject can be directed and we can configure the tip globally or per edgeCloses #2935
Closes #2843
Supersedes #2850 in a non breaking way
Motivation and Explanation: Why and how do your changes improve the library?
At the moment directed graph are not supported
Links to added or changed documentation pages
https://manimce--2974.org.readthedocs.build/en/2974/reference/manim.mobject.graph.GenericGraph.html#manim.mobject.graph.GenericGraph
https://manimce--2974.org.readthedocs.build/en/2974/reference/manim.mobject.graph.Graph.html
https://manimce--2974.org.readthedocs.build/en/2974/reference/manim.mobject.graph.DiGraph.html
Further Information and Comments
Reviewer Checklist