Repository navigation
Speed up copies, edge removal and JSON saving; fix three bugs - #53
Merged
Merged
Conversation
Performance, measured on the 172,000 interactions of the high-school contacts: - copy() copies the hypergraph's containers and shares their immutable contents, instead of calling copy.deepcopy: 1.43 s to 0.38 s. - remove_nodes(..., keep_edges=False) and remove_edges of Hypergraph and TemporalHypergraph remove all edges in one pass over each member's incident edges. Removing them one at a time was quadratic for nodes in many edges (keeping 50 of 327 nodes: about 3 s to 0.1 s). The result is the same as removing one at a time. Directed and multiplex hypergraphs keep their own removal. - save_json_hypergraph writes with json.dumps, which uses the C encoder: 5.3 s to 1.4 s, with byte-identical output. Fixes: - annealed_adjacency_matrix assumed consecutive integer times, so it raised KeyError at the first gap. It also shaped the matrix by the largest node index and counted each pair twice in one triangle. It now returns the mean of the snapshots' adjacency matrices: symmetric, n x n, with a zero diagonal. - s_betweenness_nodes_averaged and s_closenness_nodes_averaged raised TypeError on numbered nodes and dropped named nodes containing an "E". - Loading a JSON file with tuple nodes raised TypeError, since JSON writes tuples as lists. Tuple nodes are now read back as tuples. Behaviour changes: - remove_nodes and remove_edges check every node or edge before removing any. A missing one, or an edge listed twice, raises and leaves the hypergraph unchanged. - annealed_adjacency_matrix returns corrected values. Tests cover copies, batch removal against removal one at a time, the annealed adjacency against the mean of snapshots with gaps in time, centralities on numbered and named nodes, and the JSON round trip of tuple nodes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Performance, measured on the 172,000 interactions of the high-school contacts:
Fixes:
Behaviour changes:
Tests cover copies, batch removal against removal one at a time, the annealed adjacency against the mean of snapshots with gaps in time, centralities on numbered and named nodes, and the JSON round trip of tuple nodes.