1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Graph can come with many types of discrete labels. We need to map original labels of graph data files to discrete labels.
//!
//! It is possible to have labels in datafile that can be mapped to our discrete labels but that
//! are neither strings nor u6, u16 etc.
//! Moreover the default initialization of labels (i.E 0 for u8, u16 etc)
//! is used internally to cover the case where a node has no input (or output) edge. In this case
//! the embedded vector is represented by the default value (i.e 0).
//! **So effective labels stored in the graph must not be 0!!**
//!
//! We must also store reordering of nodes.
//!
use Hash;
use NodeIndex;
use IndexMap;
use *;
// TODO Do we keep u32 or do we parametrize on initial node Id?
/// ToLabel is the original label of nodes (or edge) of graph, Label is discrete label associated to Nodes in MgraphSketch
// end of struct IdMap
/// When loading a datafile, A graph is returned together with a structure satisfying trait IdMapper
///
/// When a node has no input edge or no output edge, if we want to get an Array2 are embedding result we must define a specific label
/// to fill the corresponding In or Out sketching vector. This is the Default label!
/// (An alternative woud have been to return an Option\<Vec\> for each node, but still we would have to relabel to fit into our labels)
/// Moreover we may need to map labels in datafile to out implemented labels. So there is a specific relabelling pass in reading data
/// Typically the default label 0 must be remapped to someting else (max label used + 1)
/// In the same way at the end of the embedding process we do have correspondance between embedded vectors (accessed by a row in embbed Array2 corresponding
/// to a NodeIndex) and initial rank of node
///
// end of trait IdMapper
// end of impl IdMap
// end of impl block