umons-dept-comp-sci / PhoegRustGraph

Graph library specialized for small graphs.
3 stars 2 forks source link

format::encode/decode and graph::GraphFormat::to_bin/from_bin types #14

Open antegallya opened 1 year ago

antegallya commented 1 year ago

The format::encode/decode functions handle u64 arrays/vecs. Why is there this huge granularity ? Isn't Nauty's granularity at byte level ? The same goes for graph::GraphFormat::to_bin/from_bin.

GauvainD commented 1 year ago

It has been a while since I wrote the code but if I remember correctly, in the case of to_bin, our operations are directly on the internal u64 words of the graph. We can then directly operate on 8 bytes at a time when doing our conversion.

However, the rest of the code involved in the conversion to g6 (including encode/decode) needs to directly interact with each byte so these could indeed use arrays of bytes. It is also true for the code for from_bin which needs to handle the symmetrical nature of the adjacency matrix and thus needs to go over each edge unfortunately (adding edge (i,j) and (j,i)).

Nauty's internal format is the same as the GraphNauty struct: an array of binary words with the wordsize being determined at compile time. We use 64 bits since we did not see a usecase for smaller wordsize during implementation. It is only afterwards that wasm came out which only supports 32 bits.