Skip to content

Check tree sequences topologically equal (i.e. ignoring node times) #1273

Answered by hyanwong
hyanwong asked this question in Q&A
Discussion options

You must be logged in to vote

I've just PR'ed a method to port whole tree sequences (i.e. the ARG, if we have recombination nodes) into NetworkX. So now to check for tree sequence topological identity we can just read them into NetworkX and use nx.is_isomorphic while ensuring that the edges have identical left and right attributes:

import msprime
import networkx as nx

def edges_identical(d1, d2):
    return set((v["left"], v["right"]) for v in d1.values()) == set((v["left"], v["right"]) for v in d2.values())

def as_dict_of_dicts_reorder(ts, mapping=None):
    # like ts.as_dict_of_dicts PRed in #1296 but also allows the node IDs
    # to be randomly shuffled, so that the mappings are unbiased
    # (only needed if yo…

Replies: 4 comments 12 replies

Comment options

hyanwong
Mar 27, 2021
Collaborator Author

You must be logged in to vote
1 reply
@hyanwong
Comment options

hyanwong Mar 27, 2021
Collaborator Author

Comment options

You must be logged in to vote
5 replies
@hyanwong
Comment options

hyanwong Mar 27, 2021
Collaborator Author

@petrelharp
Comment options

@hyanwong
Comment options

hyanwong Mar 27, 2021
Collaborator Author

@hyanwong
Comment options

hyanwong Mar 27, 2021
Collaborator Author

@petrelharp
Comment options

Comment options

You must be logged in to vote
5 replies
@hyanwong
Comment options

hyanwong Mar 28, 2021
Collaborator Author

@hyanwong
Comment options

hyanwong Mar 28, 2021
Collaborator Author

@jeromekelleher
Comment options

@hyanwong
Comment options

hyanwong Mar 28, 2021
Collaborator Author

@hyanwong
Comment options

hyanwong Apr 2, 2021
Collaborator Author

Comment options

hyanwong
Apr 2, 2021
Collaborator Author

You must be logged in to vote
1 reply
@hyanwong
Comment options

hyanwong Apr 10, 2021
Collaborator Author

Answer selected by hyanwong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants