-
Notifications
You must be signed in to change notification settings - Fork 1
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
ENH: Improve directional diagram algo #113
Conversation
* Changes directional diagram algorithm to use depth-first-search (i.e. `nx.dfs_tree`) to generate the directional edges. * Removes private functions `diagrams._collect_sources` and `diagrams.get_directional_path_edges`
* Use networkx method to build the directional diagram with reversed edges * Move array-based edge flipping code into the `return_edges=True` code path * Changes directional diagram return type for `return_edges=False` to a `nx.DiGraph`
With a little more digging, I found a slightly different way to accomplish the same changes. Since Here is the performance on the latest commit:
While it is nice to see performance gains on the simpler models, the only test case I am really interested in is the On the original commit:
On the latest commit:
Since the latest version appears to be at least as good I think I'm happy with the changes here. |
Just as a final performance check, I went ahead and added a new test case for the diagram benchmarks which tests a maximally-connected 7-state diagram. For maximally-connected graphs, there are Here is the performance comparison with the new test model included for the latest commit:
And for
It appears for diagrams this complex there is also a benefit for peak memory (probably due to the use of the less complex
I don't think I will be adding the 7-state test case to the benchmark suite due to the long run time of For future reference I will paste the benchmark output with the 7-state case included: Benchmarks ran with Max-7-state
|
I re-ran the Python 3.11 runner in an attempt to get a Codecov output
|
Alright, everything looks good here (except I'll just note that the depth-first-search algorithm time complexity is The |
Description
This branch changes the way we generate directional diagrams from partial diagrams. Since the paths for the directional diagrams are known ahead of time, we can use a depth-first-search algorithm to find the directed versions of the paths.
NetworkX.dfs_tree
returns the correct diagrams but with the edges reversed (our previous algorithm also did this) so we simply reverse the edges like before and voila! The new algorithm is significantly more efficient for larger graphs (see results below) and still noticeably faster for small graphs.Changes
Changes directional diagram algorithm
to use depth-first-search (i.e.
nx.dfs_tree
)to create the directional diagrams. Also
uses the
nx.DiGraph.reverse
method to buildthe directional diagram with reversed edges
and changes directional diagram return type
for
return_edges=False
to anx.DiGraph
.Removes private functions
diagrams._collect_sources
anddiagrams.get_directional_path_edges
Move array-based edge flipping code into
the
return_edges=True
code pathAddresses the directional diagram
algo improvement portion of ENH: Update KDA partial and directional diagram generation algorithm #22
Performance changes
On this branch we see a significant increase in performance for many of the benchmarks. Running
$ asv continuous master improve_dir_edge_generation
showed improvements even for some of the functions fromcalculations.py
because they rely on generating the diagrams to create the expressions.