Skip to content
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

Remove n^2 loops #94

Open
bdemchak opened this issue Aug 3, 2022 · 0 comments
Open

Remove n^2 loops #94

bdemchak opened this issue Aug 3, 2022 · 0 comments

Comments

@bdemchak
Copy link
Collaborator

bdemchak commented Aug 3, 2022

There are a number of functions that contain checks for a node or edge list being contained within a network. For very large networks and very large lists, this becomes an n^2 operation. I recently verified that for a million node network, the check in load_table_data() took longer than 2 days (before I gave up).

The general pattern is to create a comprehension and then test whether True or False is in the comprehension.

For example:

    test_present = [x in all_names   for x in node_suids]
    if not False in test_present:
        return node_suids

These can be found in:

    py4cytoscape_utils:node_suid_to_node_name()
    py4cytoscape_utils:edge_suid_to_edge_name()
    py4cytoscape_utils:_item_to_suid()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant