kda.diagrams.generate_partial_diagrams() currently appends the partial diagram edge lists to a list instead of filling in an array because it was previously difficult to quantify the number of partial diagrams/spanning trees that could be generated from an input diagram. This is now pretty simple to calculate with the addition of kda.diagrams.enumerate_partial_diagrams(), given the rate matrix is provided.
To conserve the current call signature for generate_partial_diagrams(), a call to kda.graph_utils.retrieve_rate_matrix() should suffice for retrieving the rate matrix. With this it should be possible to preallocate an array for the partial diagram edges, which should result in a reasonable speedup and a small reduction in spacial complexity. The final array should have the shape P x (N-1) x M, where P is the number of partial diagrams (calculated from enumerate_partial_diagrams()), N is the number of nodes in the input diagram, and M is the length of the edge tuples (2 or 3).
The returned edge list is already converted to an array, so this should be a pretty straight-forward change.
kda.diagrams.generate_partial_diagrams()
currently appends the partial diagram edge lists to a list instead of filling in an array because it was previously difficult to quantify the number of partial diagrams/spanning trees that could be generated from an input diagram. This is now pretty simple to calculate with the addition ofkda.diagrams.enumerate_partial_diagrams()
, given the rate matrix is provided.To conserve the current call signature for
generate_partial_diagrams()
, a call tokda.graph_utils.retrieve_rate_matrix()
should suffice for retrieving the rate matrix. With this it should be possible to preallocate an array for the partial diagram edges, which should result in a reasonable speedup and a small reduction in spacial complexity. The final array should have the shapeP x (N-1) x M
, whereP
is the number of partial diagrams (calculated fromenumerate_partial_diagrams()
),N
is the number of nodes in the input diagram, andM
is the length of the edge tuples (2 or 3).The returned edge list is already converted to an array, so this should be a pretty straight-forward change.