84 int size = NIdV.
Len();
85 for (
int ind = 0; ind < size; ind++) {
86 KNN->AddNode(NIdV[ind]);
88 KNN->AddFltAttrE(
"sim");
93 int NumThreads = omp_get_max_threads();
94 omp_set_num_threads(NumThreads);
95 #pragma omp parallel private(ThNodeList, ThTopK)
101 #pragma omp for schedule(dynamic,1000)
102 for (
int ind = 0; ind < size; ind++) {
112 for (
int i = 0; i < K; i++) {
116 Neighbors->
Clr(
false);
117 Neighbors_old->
Clr(
false);
119 for (
int i = 0; i < NI.
GetOutDeg(); i++) {
121 MergeNbrs(Neighbors, Neighbors_old, Inst_NI);
123 temp = Neighbors_old;
125 Neighbors_old = Neighbors;
131 temp = Neighbors_old;
132 Neighbors_old = Neighbors;
134 for(
int j = 0; j< Neighbors->
Len(); j++) {
139 if (TopK[K-1].GetVal1() < similarity) {
141 for (
int i = K-2; i >= 0; i--)
142 if (TopK[i].GetVal1() < similarity) {
143 TopK.
SetVal(i+1, TopK[i]);
153 ThNodeList.
Add(NIdV[ind]);
161 for (
int j = 0; j < ThTopK.
Len(); j++) {
162 TopKList.
Add(ThTopK[j]);
163 NodeList.
Add(ThNodeList[j]);
168 int size2 = NodeList.
Len();
169 for (
int i= 0; i < size2 ; i++) {
171 for (
int j = 0; j < K; j++) {
172 if (TopKList[i][j].GetVal2() <= -1) {
175 int EId = KNN->AddEdge(NodeList[i], TopKList[i][j].GetVal2());
176 KNN->AddFltAttrDatE(EId, TopKList[i][j].GetVal1(),
"sim");
float JaccardSim(TNGraph::TNodeI NI1, TNGraph::TNodeI NI2)
void GetNIdV(TIntV &NIdV) const
Gets a vector IDs of all nodes in the graph.
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
TSizeTy Len() const
Returns the number of elements in the vector.
void MergeNbrs(TIntV *NeighbourV, TIntV *list1, TNGraph::TNodeI NI2)
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
void SetVal(const TSizeTy &ValN, const TVal &Val)
Sets the value of element at position ValN to Val.
int GetOutDeg() const
Returns out-degree of the current node.
Node iterator. Only forward iteration (operator++) is supported.
int GetInDeg() const
Returns in-degree of the current node.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
static PNEANet New()
Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New().
int GetOutNId(const int &NodeN) const
Returns ID of NodeN-th out-node (the node the current node points to).