oscoin / osrank-rs

A pre-alpha osrank implementation in Rust.
http://oscoin.io/
3 stars 3 forks source link

Refactor algorithm.rs #42

Closed adinapoli-mndc closed 5 years ago

adinapoli-mndc commented 5 years ago

Once #33 will be completed, I think this will be a good time for us to take stock and trying to see if we can refactor algorithm.rs. There are a number of things which are currently a bit clunky in that module:

My tentative proposal would be the following:

A note on RandomWalks

I have realised at some point this week, while I was working on the RandomWalks new abstraction, that for this data structure we have to copy the node ids. This is because we cannot rely on the lifetime of the input Graph G, because in the real world(TM) we would be given some form of serialised-from-disk RandomWalks type, and therefore this needs to own its content: not just from an ownership perspective, but also because by the time we receive this data structure as input, the network topology might have changed: new nodes might have been added, and stale nodes (still referenced by the RandomWalks) might be gone, therefore we cannot rely on the Rust lifetime system here.

Not that I am writing this, I am also thinking that perhaps RandomWalks should be somehow abstracted over as a trait, because it's unlikely that the storage & protocol teams will depend on our own type: we will probably be given some form of iterator or some more specific data structure and we will have to either perform the conversion on-the-fly, or use RandomWalks as it is now only for tests.

@MeBrei thoughts?

MeBrei commented 5 years ago

:+1: A good list! Though some of this might be heavily influenced by decisions of the Graph API. Additionally you could list switching to a multi-edge graph as outlined in the data model document.

adinapoli-mndc commented 5 years ago

Fixed by https://github.com/oscoin/osrank-rs/pull/59 .