Skip to content

Add cohorts() function#81

Open
mcelrath wants to merge 2 commits intozawy12:masterfrom
mcelrath:cohorts
Open

Add cohorts() function#81
mcelrath wants to merge 2 commits intozawy12:masterfrom
mcelrath:cohorts

Conversation

@mcelrath
Copy link
Copy Markdown

@mcelrath mcelrath commented Jan 3, 2025

Notes:
You were setting the genesis block (0) as its own parent, I removed this as it borks the cohort algorithm. It doesn't seem to affect your code otherwise.

I had to compute the children array, which is just a reversal of direction on the parents array. next_generation is a generalization of both that allows traversal of the graph from genesis to tip or backwards from tip to genesis.

int/nb.int32 differences don't seem to have any impact but I can force it to use np.int32 if you want.

I didn't use this cohorts() function anywhere, just providing its definition here so you can use it instead of a correction factor.

Use this like:

for c in cohorts(): print(c) # Starts from genesis
for c in cohorts(12999, True): print(c) # starts from tip

@mcelrath
Copy link
Copy Markdown
Author

mcelrath commented Jan 3, 2025

I tested this like:

from DAG_braidpool_simulator import *
# let it run and generate its graph. Close graph window.
for c in cohorts(): print(c)

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

Successfully merging this pull request may close these issues.

1 participant