6 namespace TSnapDetail {
 
   18   Cmty1.
Clr(
false);  Cmty2.
Clr(
false);
 
   22     if (BtwEH.
Empty()) { 
return; }
 
   27     if (BFS.
GetHops(NId1, NId2) == -1) { 
 
   40   for (
int c = 0; c < CnComV.
Len(); c++) {
 
   41     const TIntV& NIdV = CnComV[c]();
 
   42     double EIn = 0, EEIn = 0;
 
   43     for (
int i = 0; i < NIdV.
Len(); i++) {
 
   46       EEIn += OutDegH.
GetDat(NIdV[i]);
 
   48     Mod += (EIn-EEIn*EEIn / (2.0*OrigEdges));
 
   50   if (Mod == 0) { 
return 0; }
 
   51   else { 
return Mod / (2.0*OrigEdges); }
 
   55   float InModule = 0.0, OutModule = 0.0, Val;
 
   56   int Mds[2] = { a, b };
 
   57   for (
int i = 0; i<2; i++) {
 
   58     InModule = 0.0, OutModule = 0.0;
 
   59     if (Qi.
IsKey(Mds[i])) {
 
   60       int CentralModule = Mds[i];
 
   66         if (Module.
GetDat(NI.GetId()) == CentralModule)
 
   70       for (
int j = 0; j<newM.
Len(); j++) {
 
   74         for (
int k = 0; k<Graph->
GetNI(newM[j]).
GetDeg(); k++) {
 
   79           int ms = Module.
GetDat(ids);
 
   80           int md = Module.
GetDat(idd);
 
   92       if (InModule >1) InModule = InModule / 2;
 
   97       if (InModule + OutModule > 0) {
 
   98         Val = OutModule / (InModule + OutModule);
 
  110   double SumPAlpha = 1.0, SumQi = 0.0, SumQiLogQi = 0.0;
 
  111   double SumQiSumPAlphaLogQiSumPAlpha = 0.0, logqi = 0.0, qi = 0.0;
 
  112   for (
int i = 0; i<Qi.
Len(); i++) {
 
  120     SumQiLogQi += Qi[i] * logqi;
 
  121     SumQiSumPAlphaLogQiSumPAlpha += (Qi[i] + SumPAlpha)*log(Qi[i] + SumPAlpha);
 
  123   return (SumQi*log(SumQi) - 2 * SumQiLogQi - SumPAlphaLogPAlpha +
 
  124           SumQiSumPAlphaLogQiSumPAlpha);
 
  128   for (
int i = 0; i<a.
Len(); i++) {
 
  129     for (
int j = 0; j<b.
Len(); j++) {
 
  130       if (graph->
IsEdge(a[i], b[j]))
 
  140   for (
int i = 0; i<a.
Len(); i++) {
 
  141     for (
int j = 0; j<b.
Len(); j++) {
 
  161     if (inCompCount.
IsKey(
id)) {
 
  162       inComp = inCompCount.
GetDat(
id);
 
  164     if (inCompCount.
IsKey(neigh)) {
 
  165       inCompN = inCompCount.
GetDat(neigh);
 
  168     if (inCompN < neighDeg && inComp < deg && (!g1->
IsNode(neigh) || Graph->
GetNI(neigh).
GetDeg() - neighDeg == 0)) {
 
  169       inCompCount.
AddDat(neigh, ++inCompN);
 
  170       inCompCount.
AddDat(
id, ++inComp);
 
  180   for (
int i = 0; i < a.
Len(); i++) {
 
  182     for (
int j = 0; j < b.
Len(); j++) {
 
  198   for (
int i = 0; i < a.
Len(); i++) {
 
  211   return (after && before);
 
  236   double oldAlphaN1 = 0.0;
 
  237   double oldAlphaN2 = 0.0;
 
  240     oldAlphaN1 = PAlpha.
GetDat(n1);
 
  243     oldAlphaN2 = PAlpha.
GetDat(n2);
 
  247   int nodeDeg = node.
GetDeg();
 
  248   float d = ((float)nodeDeg / (
float)(2 * e));
 
  252   SumPAlphaLogPAlpha = SumPAlphaLogPAlpha - oldAlphaN1 + d*log(d);
 
  261   node = Graph->
GetNI(n2);
 
  263   d = ((float)nodeDeg / (
float)(2 * e));
 
  267   SumPAlphaLogPAlpha = SumPAlphaLogPAlpha - oldAlphaN2 + d*log(d);
 
  279   double PrevIterationCodeLength = 0.0;
 
  282     PrevIterationCodeLength = MinCodeLength;
 
  283     int id[2] = { n1, n2 };
 
  284     for (
int k = 0; k<2; k++) {
 
  285       for (
int i = 0; i<Graph->
GetNI(
id[k]).
GetDeg(); i++) {
 
  287         int OldModule = Module.
GetDat(
id[k]);
 
  290         Module.
AddDat(
id[k], NewModule);
 
  294         if (NewCodeLength<MinCodeLength) {
 
  295           MinCodeLength = NewCodeLength;
 
  296           OldModule = NewModule;
 
  299           Module.
AddDat(
id[k], OldModule);
 
  303   } 
while (MinCodeLength<PrevIterationCodeLength);
 
  305   return MinCodeLength;
 
  313   PUNGraph LocalGraph = TSnap::ConvertGraph<PUNGraph>(Graph, 
false);
 
  316   const int NEdges = LocalGraph->
GetEdges();
 
  318     OutDegH.AddDat(NI.GetId(), NI.GetOutDeg());
 
  330       CmtyV.
Swap(CurCmtyV);
 
  332     if (Cmty1.
Len() == 0 || Cmty2.
Len() == 0) { 
break; }
 
  345   double SumPAlphaLogPAlpha = 0.0;
 
  351     int nodeId = NI.GetId();
 
  352     int nodeDeg = NI.GetDeg();
 
  353     float d = ((float)nodeDeg / (
float)(2 * e));
 
  355     SumPAlphaLogPAlpha += d*log(d);
 
  356     Module.
AddDat(nodeId, Br);
 
  362   double NewCodeLength, PrevIterationCodeLength = 0.0;
 
  363   int OldModule, NewModule;
 
  367     nodes.
Add(NI.GetId());
 
  370     PrevIterationCodeLength = MinCodeLength;
 
  374     for (
int ndcounter = 0; ndcounter<nodes.
Len(); ndcounter++) {
 
  376       int nodeId = nodes[ndcounter];
 
  378       for (
int i = 0; i<NI.
GetDeg(); i++) {
 
  380         OldModule = Module.
GetDat(nodeId);
 
  383         if (OldModule != NewModule){
 
  385           Module.
AddDat(nodeId, NewModule);
 
  389           if (NewCodeLength<MinCodeLength) {
 
  390             MinCodeLength = NewCodeLength;
 
  391             OldModule = NewModule;
 
  394             Module.
AddDat(nodeId, OldModule);
 
  399   } 
while (MinCodeLength<PrevIterationCodeLength);
 
  404   for (
int i = 0; i<Module.
Len(); i++) {
 
  409         if (Module.
GetDat(NI.GetId()) == Mod)
 
  416   return MinCodeLength;
 
  426   for (
int i = 0; i<Module.
Len(); i++) {
 
  431         if (Module.
GetDat(NI.GetId()) == Mod)
 
  438   return MinCodeLength;
 
  447   for (
int i = 0; i < cCont.
Len(); i++){
 
  449       if (!uniqueId.
IsIn(it.GetKey()))
 
  450         uniqueId.
Add(it.GetKey());
 
  454   for (
int j = 0; j<uniqueId.
Len(); j++)
 
  457     for (
int i = 0; i<cCont.
Len(); i++)
 
  459       if (cCont[i].IsKey(uniqueId[j]))
 
  464     cContV.
AddDat(uniqueId[j], cV);
 
  468   for (
int i = 0; i < sizesCont.
Len(); i++){
 
  470       if (!uniqueC.
IsIn(it.GetKey()))
 
  471         uniqueC.
Add(it.GetKey());
 
  475   for (
int j = 0; j<uniqueC.
Len(); j++)
 
  478     for (
int i = 0; i<sizesCont.
Len(); i++)
 
  480       if (sizesCont[i].IsKey(uniqueC[j]))
 
  485     sizesContV.
AddDat(uniqueC[j], cV);
 
  516     if (Marker.
GetCh(0) == 
'#'){
 
  531         Graph->
AddEdge(SrcNId, DstNId);
 
  535       } 
while (Marker.
GetCh(0) != 
'#' && !Ss.
Eof());
 
  546           CmtyAlgStr = 
"Girvan-Newman";
 
  549         else if (CmtyAlg == 2) {
 
  550           CmtyAlgStr = 
"Clauset-Newman-Moore";
 
  553         else if (CmtyAlg == 3) {
 
  554           CmtyAlgStr = 
"Infomap";
 
  564           for (
int c = 0; c < CmtyV.
Len(); c++) {
 
  565             for (
int i = 0; i < CmtyV[c].
Len(); i++){
 
  566               prev.
AddDat(CmtyV[c][i].Val, c);
 
  569             prev_sizes.
AddDat(c, CmtyV[c].Len());
 
  581           int first_new_c_id = -1;
 
  585             if (it.GetKey() > first_new_c_id)
 
  586               first_new_c_id = it.
GetKey();
 
  587           if (CmtyV.
Len() - 1>first_new_c_id)
 
  588             first_new_c_id = CmtyV.
Len() - 1;
 
  591           for (
int c = 0; c < CmtyV.
Len(); c++) {
 
  599               dist.
AddDat(it.GetKey(), 0);
 
  603             for (
int i = 0; i < CmtyV[c].
Len(); i++) {
 
  604               int id = CmtyV[c][i].Val;
 
  607                 prev_comm = prev.
GetDat(CmtyV[c][i].Val);
 
  609               int pre_val = dist.
GetDat(prev_comm);
 
  610               dist.
AddDat(prev_comm, pre_val + 1);
 
  619                 if (prev_sizes.
IsKey(it.GetKey())){
 
  621                   double stat1_ = (double)d / (
double)prev_sizes.
GetDat(k);
 
  624                 double stat2_ = (double)d / (
double)CmtyV[c].
Len();
 
  640               if (sumstat2 > 0.98) 
break;
 
  643             int n_of_c_greater_than_half = 0;
 
  644             int id_of_c_greater_than_half = -1;
 
  645             TIntV ids_of_c_greater_than_half;
 
  648               if (it.GetDat()>alpha){
 
  649                 id_of_c_greater_than_half = it.GetKey();
 
  650                 ids_of_c_greater_than_half.
Add(it.GetKey());
 
  651                 n_of_c_greater_than_half++;
 
  656             if (n_of_c_greater_than_half == 1){
 
  657               map.
AddDat(c, id_of_c_greater_than_half);
 
  661               for (
int i = 0; i<ids_of_c_greater_than_half.
Len(); i++){
 
  662                 double H2 = statH2.
GetDat(ids_of_c_greater_than_half[i]);
 
  664                   h2part_id = ids_of_c_greater_than_half[i];
 
  670                 map.
AddDat(c, first_new_c_id);
 
  685           for (
int c = 0; c < CmtyV.
Len(); c++){
 
  686             for (
int i = 0; i < CmtyV[c].
Len(); i++){
 
  697             int b = it.GetDat()[1];
 
  698             int v = it.GetDat()[2];
 
  699             int d = it.GetDat()[3];
 
  700             int e = it.GetDat()[4];
 
  714         sizesCont.
AddDat(br, prev_sizes);
 
  731   Json.
InsStr(Json.
Len(), 
"{\n\"edges\":[\n");
 
  738     TInt n1 = it.GetDat()[1];
 
  740     TInt n2 = it.GetDat()[0];
 
  742     TInt w = it.GetDat()[2];
 
  744     TInt t0 = it.GetDat()[3];
 
  746     TInt t1 = it.GetDat()[4];
 
  762   Json.
InsStr(Json.
Len(), 
"],\n\"communities\":[\n");
 
  766   for (
int i = 0; i < sizesContV[0].
Len(); i++)
 
  771       TInt id = it.GetKey();
 
  773       TInt size = it.GetDat()[i];
 
  782         TInt size = it.GetDat()[i];
 
  851   int first = 429496729;
 
  859     if (it.GetDat()<first)
 
  861     if (it.GetDat()>last)
 
  868     if (it.GetDat() - (e / 2) >= first)
 
  869       timePoints.
Add(it.GetDat() - (e / 2) );
 
  870     timePoints.
Add(it.GetDat());
 
  871     if (it.GetDat() + (e / 2) <= last)
 
  872       timePoints.
Add(it.GetDat() + (e / 2) );
 
  877   for (
int i = 0; i<timePoints.
Len(); i++) {
 
  879     int focusTimePoint = timePoints[i];
 
  885       if ((it.GetDat() <= focusTimePoint + (e / 2)) && (it.GetDat() >= focusTimePoint - (e / 2)))
 
  886         fnodes.
Add(it.GetKey());
 
  891     for (
int i = 0; i<fnodes.
Len(); i++) {
 
  892       if (!g1->IsNode(fnodes[i]))
 
  893         g1->AddNode(fnodes[i]);
 
  895       for (
int j = 0; j<Graph->GetNI(fnodes[i]).GetInDeg(); j++) {
 
  896         int NeighId = Graph->GetNI(fnodes[i]).GetInNId(j);
 
  897         if (t.
GetDat(NeighId)<focusTimePoint - (e / 2)) {
 
  901           if (!g1->IsNode(NeighId))
 
  902             g1->AddNode(NeighId);
 
  903           g1->AddEdge(NeighId, fnodes[i]);
 
  907       for (
int j = 0; j<Graph->GetNI(fnodes[i]).GetOutDeg(); j++) {
 
  908         int NeighId = Graph->GetNI(fnodes[i]).GetOutNId(j);
 
  909         if (t.
GetDat(NeighId)>focusTimePoint + (e / 2)) {
 
  913           if (!g1->IsNode(NeighId))
 
  914             g1->AddNode(NeighId);
 
  915           g1->AddEdge(fnodes[i], NeighId);
 
  923     TIntV communitiesAtT;
 
  924     for (
int cc = 0; cc < CnComV.
Len(); cc++) {
 
  925       components.
AddDat(newId, CnComV[cc].NIdV);
 
  926       communitiesAtT.
Add(newId);
 
  929     if (CnComV.
Len() > 0)
 
  930       ct.
AddDat(focusTimePoint, communitiesAtT);
 
  937   while (it < prelast) {
 
  942     focusTimePoint = it.
GetKey();
 
  945     focusTimePoint1 = it.
GetKey();
 
  947     if (cms0.
Len()>0 && cms1.
Len() > 0) {
 
  948       for (
int i = 0; i < cms0.
Len(); i++) {
 
  949         for (
int j = 0; j < cms1.
Len(); j++) {
 
  953             if (!gFinal->IsNode(cms0[i])) {
 
  954               gFinal->AddNode(cms0[i]);
 
  955               tFinal.
AddDat(cms0[i], focusTimePoint);
 
  957             if (!gFinal->IsNode(cms1[j])) {
 
  958               gFinal->AddNode(cms1[j]);
 
  959               tFinal.
AddDat(cms1[j], focusTimePoint1);
 
  961             gFinal->AddEdge(cms0[i], cms1[j]);
 
  970     for (
TNGraph::TNodeI NI = gFinal->BegNI(); NI < gFinal->EndNI(); NI++) {
 
  971       if (NI.GetInDeg() == 1 && NI.GetOutDeg() == 1)
 
  972         if (gFinal->GetNI(NI.GetInNId(0)).GetOutDeg() == 1 && gFinal->GetNI(NI.GetOutNId(0)).GetInDeg() == 1)
 
  974         gFinal->AddEdge(NI.GetInNId(0), NI.GetOutNId(0));
 
  975         gFinal->DelEdge(NI.GetInNId(0), NI.GetId());
 
  976         tFinal.
DelKey(NI.GetId());
 
  977         gFinal->DelNode(NI.GetId());
 
  991   int first = 429496729;
 
  999     if (it.GetDat() < first)
 
 1001     if (it.GetDat() > last)
 
 1008     if (it.GetDat() - (e / 2) >= first)
 
 1009       timePoints.
Add(it.GetDat() - (e / 2) );
 
 1010     timePoints.
Add(it.GetDat());
 
 1011     if (it.GetDat() + (e / 2) <= last)
 
 1012       timePoints.
Add(it.GetDat() + (e / 2) );
 
 1015   TIntV timePointsUnique;
 
 1018   for (
int i = 0; i < timePoints.
Len(); i++){
 
 1019     if (timePoints[i] > prevtp)
 
 1020       timePointsUnique.
Add(timePoints[i]);
 
 1021     prevtp = timePoints[i];
 
 1025   timePoints = timePointsUnique;
 
 1028   for (
int i = 0; i < timePoints.
Len(); i++) {
 
 1030     int focusTimePoint = timePoints[i];
 
 1036       if ((it.GetDat() <= focusTimePoint + (e / 2)) && (it.GetDat() >= focusTimePoint - (e / 2)))
 
 1037         fnodes.
Add(it.GetKey());
 
 1042     for (
int i = 0; i < fnodes.
Len(); i++) {
 
 1043       if (!g1->IsNode(fnodes[i]))
 
 1044         g1->AddNode(fnodes[i]);
 
 1046       for (
int j = 0; j < Graph->GetNI(fnodes[i]).GetInDeg(); j++) {
 
 1047         int NeighId = Graph->GetNI(fnodes[i]).GetInNId(j);
 
 1048         if (t.
GetDat(NeighId) < focusTimePoint - (e / 2)) {
 
 1052           if (!g1->IsNode(NeighId))
 
 1053             g1->AddNode(NeighId);
 
 1054           g1->AddEdge(NeighId, fnodes[i]);
 
 1058       for (
int j = 0; j < Graph->GetNI(fnodes[i]).GetOutDeg(); j++) {
 
 1059         int NeighId = Graph->GetNI(fnodes[i]).GetOutNId(j);
 
 1060         if (t.
GetDat(NeighId) > focusTimePoint + (e / 2)) {
 
 1064           if (!g1->IsNode(NeighId))
 
 1065             g1->AddNode(NeighId);
 
 1066           g1->AddEdge(fnodes[i], NeighId);
 
 1077     int FTP = focusTimePoint;
 
 1083       int FTPNode = NI.GetId();
 
 1085       int FI, FO, RI, RO, I, O;
 
 1088       RO = NI.GetOutDeg();
 
 1090       FI = Graph->GetNI(FTPNode).GetInDeg() - RI;
 
 1091       FO = Graph->GetNI(FTPNode).GetOutDeg() - RO;
 
 1093       if (focusTimePoint + (e / 2) == t.
GetDat(NI.GetId())) { 
 
 1096       if (focusTimePoint - (e / 2) == t.
GetDat(NI.GetId())) { 
 
 1105       if (TEdges.
IsKey(FTP))
 
 1106         temp = TEdges.
GetDat(FTP);
 
 1107       TEdges.
AddDat(FTP, O + temp);
 
 1112       if (I > 1 && O > 1) {
 
 1120         for (
int i = 0; i < I; i++) {
 
 1124         for (
int i = 0; i < O; i++) {
 
 1128         for (
int j = 0; j < nn; j++) {
 
 1130           comps.
AddDat(compBr, nds);
 
 1136       else if (I == 1 && O > 1) {
 
 1137         for (
int i = 0; i < O; i++) {
 
 1142           comps.
AddDat(compBr, nds);
 
 1148       else if (I > 1 && O == 1) {
 
 1149         for (
int i = 0; i < I; i++) {
 
 1154           comps.
AddDat(compBr, nds);
 
 1160       else if (I == 0 && O > 1) {
 
 1161         for (
int i = 0; i < O; i++) {
 
 1165           comps.
AddDat(compBr, nds);
 
 1171       else if (I > 1 && O == 0) {
 
 1172         for (
int i = 0; i < I; i++) {
 
 1176           comps.
AddDat(compBr, nds);
 
 1182       else if (I == 1 && O == 1) {
 
 1187         comps.
AddDat(compBr, nds);
 
 1192       else if (I == 0 && O == 1) {
 
 1196         comps.
AddDat(compBr, nds);
 
 1201       else if (I == 1 && O == 0) {
 
 1205         comps.
AddDat(compBr, nds);
 
 1217     for (
int cc0 = 0; cc0 < comps.
Len(); cc0++) {
 
 1218       for (
int cc1 = cc0; cc1 < comps.
Len(); cc1++) {
 
 1219         int smaller = comps[cc0].
Len();
 
 1220         int smaller_id = cc0;
 
 1222           if (comps[cc1].Len() < smaller) {
 
 1223             smaller = comps[cc1].
Len();
 
 1227           if (vi == smaller && !nn_nodes.
IsKey(smaller_id)){
 
 1228             banned.
AddDat(smaller_id);
 
 1250     for (
int cc0 = 0; cc0 < comps.
Len(); cc0++) {
 
 1251       if (!banned.
IsKey(cc0) )
 
 1252         elements.
AddDat(cc0, comps[cc0]);
 
 1256     TIntV communitiesAtT;
 
 1257     for (
int cc = 0; cc < elements.
Len(); cc++) {
 
 1258       components.
AddDat(newId, elements[cc]);
 
 1259     communitiesAtT.
Add(newId);
 
 1262     if (elements.
Len() > 0)
 
 1263       ct.
AddDat(focusTimePoint, communitiesAtT);
 
 1271   while (it < prelast) {
 
 1275     int focusTimePoint1;
 
 1276     focusTimePoint = it.
GetKey();
 
 1279     focusTimePoint1 = it.
GetKey();
 
 1281     if (cms0.
Len() > 0 && cms1.
Len() > 0) {
 
 1282       for (
int i = 0; i < cms0.
Len(); i++) {
 
 1283         for (
int j = 0; j < cms1.
Len(); j++) {
 
 1286           int smaller = ids0.
Len();
 
 1287           if (ids1.
Len() < smaller)
 
 1288             smaller = ids1.
Len();
 
 1291             if (!gFinal->IsNode(cms0[i])) {
 
 1292               gFinal->AddNode(cms0[i]);
 
 1293               tFinal.
AddDat(cms0[i], focusTimePoint);
 
 1295             if (!gFinal->IsNode(cms1[j])) {
 
 1296               gFinal->AddNode(cms1[j]);
 
 1297               tFinal.
AddDat(cms1[j], focusTimePoint1);
 
 1299             gFinal->AddEdge(cms0[i], cms1[j]);
 
 1308     for (
TNGraph::TNodeI NI = gFinal->BegNI(); NI < gFinal->EndNI(); NI++) {
 
 1309       if (NI.GetInDeg() == 1 && NI.GetOutDeg() == 1)
 
 1310         if (gFinal->GetNI(NI.GetInNId(0)).GetOutDeg() == 1 && gFinal->GetNI(NI.GetOutNId(0)).GetInDeg() == 1)
 
 1312         gFinal->AddEdge(NI.GetInNId(0), NI.GetOutNId(0));
 
 1313         gFinal->DelEdge(NI.GetInNId(0), NI.GetId());
 
 1314         tFinal.
DelKey(NI.GetId());
 
 1315         gFinal->DelNode(NI.GetId());
 
 1322 namespace TSnapDetail {
 
 1333     TCmtyDat(
const double& NodeDegFrac, 
const int& OutDeg) : 
 
 1334       DegFrac(NodeDegFrac), NIdQH(OutDeg), MxQId(-1) { }
 
 1335     void AddQ(
const int& NId, 
const double& 
Q) {
 
 1337       if (MxQId == -1 || NIdQH[MxQId]<Q) { MxQId = NIdQH.
GetKeyId(NId); }
 
 1342         if (MxQId == -1 || NIdQH[MxQId]< NIdQH[i]) { MxQId = i; }
 
 1359     MxQHeap(Graph->GetNodes()), CmtyIdUF(Graph->GetNodes()) {
 
 1363     const double M = 0.5 / Graph->
GetEdges(); 
 
 1366       CmtyIdUF.
Add(NI.GetId());
 
 1367       const int OutDeg = NI.GetOutDeg();
 
 1368       if (OutDeg == 0) { 
continue; }
 
 1370       for (
int e = 0; e < NI.GetOutDeg(); e++) {
 
 1371         const int DstNId = NI.GetOutNId(e);
 
 1372         const double DstMod = 2 * M * (1.0 - OutDeg * Graph->
GetNI(DstNId).
GetOutDeg() * M);
 
 1373         Dat.
AddQ(DstNId, DstMod);
 
 1384       if (MxQHeap.
Empty()) { 
break; }
 
 1395     if (TopQ.
Val1 <= 0.0) { 
return false; }
 
 1397     const int I = TopQ.
Val3;
 
 1398     const int J = TopQ.
Val2;
 
 1399     CmtyIdUF.
Union(I, J); 
 
 1407       double NewQ = DatJ.
NIdQH[i];
 
 1439     CmtyV.
Gen(IdCmtyH.
Len());
 
 1440     for (
int j = 0; j < IdCmtyH.
Len(); j++) {
 
 1441       CmtyV[j].NIdV.
Swap(IdCmtyH[j]);
 
double CommunityGirvanNewman(PUNGraph &Graph, TCnComV &CmtyV)
 
static const T & Mn(const T &LVal, const T &RVal)
 
Main namespace for all the Snap global entities. 
 
int Add(const int &Key)
Adds an element Key to the structure. 
 
void Add(const int &NodeId)
 
int GetHops(const int &SrcNId, const int &DstNId) const 
 
void Union(const int &Key1, const int &Key2)
Merges sets with elements Key1 and Key2. 
 
bool Empty() const 
Tests whether the heap is empty. 
 
TFltIntIntTr FindMxQEdge()
 
void Add(const TVal &Val)
Adds an element to the data structure. Heap property is not maintained by Add() and thus after all th...
 
static const T & Mx(const T &LVal, const T &RVal)
 
static PNGraph New()
Static constructor that returns a pointer to the graph. Call: PNGraph Graph = TNGraph::New(). 
 
TNodeI GetNI(const int &NId) const 
Returns an iterator referring to the node of ID NId in the graph. 
 
bool IsIn(const TVal &Val) const 
Checks whether element Val is a member of the vector. 
 
void GetNodeWcc(const PGraph &Graph, const int &NId, TIntV &CnCom)
Returns (via output parameter CnCom) all nodes that are in the same connected component as node NId...
 
TCNMQMatrix(const PUNGraph &Graph)
 
int DoBfs(const int &StartNode, const bool &FollowOut, const bool &FollowIn, const int &TargetNId=-1, const int &MxDist=TInt::Mx)
Performs BFS from node id StartNode for at maps MxDist steps by only following in-links (parameter Fo...
 
int AddNode(int NId=-1)
Adds a node of ID NId to the graph. 
 
int GetEdges() const 
Returns the number of edges in the graph. 
 
TSizeTy Len() const 
Returns the number of elements in the vector. 
 
double InfomapOnline(PUNGraph &Graph, int n1, int n2, TIntFltH &PAlpha, double &SumPAlphaLogPAlpha, TIntFltH &Qi, TIntH &Module, int &Br, TCnComV &CmtyV)
 
void ReebSimplify(PNGraph &Graph, TIntH &t, int e, PNGraph &gFinal, TIntH &tFinal, bool collapse)
 
Node iterator. Only forward iteration (operator++) is supported. 
 
void GetBetweennessCentr(const PGraph &Graph, TIntFltH &NIdBtwH, const double &NodeFrac=1.0, const bool &IsDir=false)
 
bool GetInt(const int &FldN, int &Val) const 
If the field FldN is an integer its value is returned in Val and the function returns true...
 
TChA GetLnStr() const 
Returns the current line. 
 
const TDat & GetDat(const TKey &Key) const 
 
static double Sqr(const double &x)
 
int GetNodes() const 
Returns the number of nodes in the graph. 
 
const TKey & GetKey() const 
 
void Swap(TVec< TVal, TSizeTy > &Vec)
Swaps the contents of the vector with Vec. 
 
int GetDeg() const 
Returns degree of the current node. 
 
void DelKey(const TKey &Key)
 
bool Eof() const 
Checks for end of file. 
 
int GetOutDeg() const 
Returns out-degree of the current node (returns same as value GetDeg() since the graph is undirected)...
 
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector. 
 
int Find(const int &Key)
Returns the set that contains element Key. 
 
const TDat & GetDat() const 
 
bool IsEnd() const 
Tests whether the iterator is pointing to the past-end element. 
 
void CmtyEvolutionFileBatch(TStr InFNm, TIntIntHH &sizesCont, TIntIntHH &cCont, TIntIntVH &edges, double alpha, double beta, int CmtyAlg)
 
bool IsEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true) const 
Tests whether an edge from node IDs SrcNId to DstNId exists in the graph. 
 
const TVal & GetDat(const TVal &Val) const 
Returns reference to the first occurrence of element Val. 
 
bool inComp(PNGraph &g1, PNGraph &Graph, TIntH &inCompCount, int id, int neigh)
 
Simple heap data structure. 
 
Whitespace (space or tab) separated. 
 
TNodeI GetNI(const int &NId) const 
Returns an iterator referring to the node of ID NId in the graph. 
 
bool FNextKeyId(int &KeyId) const 
 
bool IsNode(const int &NId) const 
Tests whether ID NId is a node. 
 
bool chekIfCrossing(TIntV &a, TIntH &t, int f, int l, int TP)
 
static PUNGraph New()
Static constructor that returns a pointer to the graph. Call: PUNGraph Graph = TUNGraph::New(). 
 
void CmtyEvolutionFileBatchV(TStr InFNm, TIntIntVH &sizesContV, TIntIntVH &cContV, TIntIntVH &edges, double alpha, double beta, int CmtyAlg)
 
TStr CmtyTest(TStr InFNm, int CmtyAlg)
 
void DelEdge(const int &SrcNId, const int &DstNId)
Deletes an edge between node IDs SrcNId and DstNId from the graph. 
 
TSizeTy IntrsLen(const TVec< TVal, TSizeTy > &ValV) const 
Returns the size of the intersection of vectors this and ValV. Assumes the vectors are sorted! ...
 
char GetCh(const int &ChN) const 
 
int GetDeg() const 
Returns degree of the current node, the sum of in-degree and out-degree. 
 
THeap< TFltIntIntTr > MxQHeap
 
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge between node IDs SrcNId and DstNId to the graph. 
 
void DelLink(const int &K)
 
int GetKeyId(const TKey &Key) const 
 
void CmtyEvolutionJson(TStr &Json, TIntIntVH &sizesContV, TIntIntVH &cContV, TIntIntVH &edges)
 
void MapEquationNew2Modules(PUNGraph &Graph, TIntH &Module, TIntFltH &Qi, int a, int b)
 
double InfomapOnlineIncrement(PUNGraph &Graph, int n1, int n2, TIntFltH &PAlpha, double &SumPAlphaLogPAlpha, TIntFltH &Qi, TIntH &Module, int &Br)
 
void AddQ(const int &NId, const double &Q)
 
void transitiveTransform(TIntV &a, TIntV &b)
 
double CommunityCNM(const PUNGraph &Graph, TCnComV &CmtyV)
 
void PushHeap(const int &First, int HoleIdx, const int &Top, TVal Val)
 
void ReebRefine(PNGraph &Graph, TIntH &t, int e, PNGraph &gFinal, TIntH &tFinal, bool collapse)
 
void Shuffle(TRnd &Rnd)
Randomly shuffles the elements of the vector. 
 
Node iterator. Only forward iteration (operator++) is supported. 
 
void Init(const PUNGraph &Graph)
 
TNodeI EndNI() const 
Returns an iterator referring to the past-the-end node in the graph. 
 
int vectorIntersect(TIntV &a, TIntV &b)
 
int GetNbrNId(const int &NodeN) const 
Returns ID of NodeN-th neighboring node. 
 
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
 
bool IsNode(const int &NId) const 
Tests whether ID NId is a node. 
 
bool Next()
Loads next line from the input file. 
 
bool edgeIntersect(PNGraph &graph, TIntV &a, TIntV &b)
 
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements. 
 
TVal PopHeap()
Removes the top element from the heap. 
 
int GetId() const 
Returns ID of the current node. 
 
bool IsKey(const TKey &Key) const 
 
int GetInNId(const int &NodeN) const 
Returns ID of NodeN-th in-node (the node pointing to the current node). 
 
TCmtyDat(const double &NodeDegFrac, const int &OutDeg)
 
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element. 
 
TNodeI BegNI() const 
Returns an iterator referring to the first node in the graph. 
 
void DelSelfEdges(const PGraph &Graph)
Removes all the self-edges from the graph. 
 
double Equation(TIntFltH &PAlpha, double &SumPAlphaLogPAlpha, TIntFltH &Qi)
 
void InsStr(const int &BChN, const TStr &Str)
 
double Infomap(PUNGraph &Graph, TCnComV &CmtyV)
 
TDat & AddDat(const TKey &Key)
 
static double CmtyCMN(const PUNGraph &Graph, TCnComV &CmtyV)
 
void GetWccs(const PGraph &Graph, TCnComV &CnComV)
Returns all weakly connected components in a Graph. 
 
Union Find class (Disjoint-set data structure). 
 
int GetOutNId(const int &NodeN) const 
Returns ID of NodeN-th out-node (the node the current node points to). 
 
const TKey & GetKey(const int &KeyId) const 
 
TTriple< TFlt, TInt, TInt > TFltIntIntTr
 
double _GirvanNewmanGetModularity(const PUNGraph &G, const TIntH &OutDegH, const int &OrigEdges, TCnComV &CnComV)
 
Vector is a sequence TVal objects representing an array that can change in size. 
 
THash< TInt, TCmtyDat > CmtyQH
 
void CmtyGirvanNewmanStep(PUNGraph &Graph, TIntV &Cmty1, TIntV &Cmty2)
A single step of Girvan-Newman clustering procedure. 
 
void MakeHeap(const int &First, const int &Len)
 
void SortByDat(const bool &Asc=true)