49 for (
int u = 0; u <
F.Len(); u++) {
52 if (Mem > 10) { Mem = 10; }
53 for (
int c = 0; c < Mem; c++) {
58 for (
int u = 0; u <
H.Len(); u++) {
61 if (Mem > 10) { Mem = 10; }
62 for (
int c = 0; c < Mem; c++) {
68 for (
int c = 0; c <
SumFV.
Len(); c++) {
69 if (
SumFV[c] == 0.0) {
75 for (
int c = 0; c <
SumHV.
Len(); c++) {
76 if (
SumHV[c] == 0.0) {
87 TAGMFastUtil::GetNIdPhiV<PNGraph>(
G, NIdPhiV);
100 TIntV ChosenNIDV(InitComs, 0);
103 for (
int ui = 0; ui < NIdPhiV.
Len(); ui++) {
104 int UID = NIdPhiV[ui].Val2;
106 if (InvalidNIDS.IsKey(UID)) {
continue; }
114 for (
int e = 0; e < NI.
GetDeg(); e++) {
121 for (
int e = 0; e < NI.
GetDeg(); e++) {
126 if (CurCID >=
NumComs) {
break; }
129 printf(
"%d communities needed to fill randomly\n",
NumComs - CurCID);
132 for (
int c = 0; c <
SumFV.
Len(); c++) {
133 if (
SumFV[c] == 0.0) {
135 for (
int u = 0; u < ComSz; u++) {
142 for (
int c = 0; c <
SumHV.
Len(); c++) {
143 if (
SumHV[c] == 0.0) {
145 for (
int u = 0; u < ComSz; u++) {
158 for (
int u = 0; u < NIDV.
Len(); u++) {
160 for (
int v = 0; v < NIDV.
Len(); v++) {
162 if (UID == VID) {
continue; }
180 for (
int u = 0; u <
NIDV.
Len(); u++) {
184 for (
int c = 0; c < CmtyVVOut.
Len(); c++) {
185 for (
int u = 0; u < CmtyVVOut[c].
Len(); u++) {
186 int UID = CmtyVVOut[c][u];
193 for (
int c = 0; c < CmtyVVIn.
Len(); c++) {
194 for (
int u = 0; u < CmtyVVIn[c].
Len(); u++) {
195 int UID = CmtyVVIn[c][u];
210 for (
int nid = 0; nid < GraphPt->
GetNodes(); nid++) {
211 if (! GraphPt->
IsNode(nid)) {
217 printf(
"rearrage nodes\n");
219 for (
int nid = 0; nid <
G->
GetNodes(); nid++) {
235 #pragma omp parallel for
236 for (
int u = 0; u <
F.Len(); u++) {
243 for (
int u = 0; u <
F.Len(); u++) {
264 for (
int e = 0; e <
HOVIDSV[UID].Len(); e++) {
265 for (
int c = 0; c <
SumHV.
Len(); c++) {
272 for (
int e = 0; e < Deg; e++) {
274 if (v == UID) {
continue; }
275 if (
HOVIDSV[UID].IsKey(v)) {
continue; }
283 double HOSum =
HOVIDSV[UID].Len() > 0? HOSumHV[HI.GetKey()].Val: 0.0;
284 L -=
NegWgt * (
GetSumVal(! IsRow, HI.GetKey()) - HOSum -
GetCom(! IsRow, UID, HI.GetKey())) * HI.GetDat();
383 for (
int e = 0; e <
HOVIDSV[UID].Len(); e++) {
384 for (
int c = 0; c <
SumHV.
Len(); c++) {
392 TFltV PredV(Deg), GradV(CIDSet.
Len());
394 for (
int e = 0; e < Deg; e++) {
396 if (VID == UID) {
continue; }
397 if (
HOVIDSV[UID].IsKey(VID)) {
continue; }
401 for (
int c = 0; c < CIDSet.
Len(); c++) {
402 int CID = CIDSet.
GetKey(c);
404 for (
int e = 0; e < Deg; e++) {
406 if (VID == UID) {
continue; }
407 if (
HOVIDSV[UID].IsKey(VID)) {
continue; }
408 Val += PredV[e] *
GetCom(! IsRow, VID, CID) / (1.0 - PredV[e]) +
NegWgt *
GetCom(! IsRow, VID, CID);
410 double HOSum =
HOVIDSV[UID].Len() > 0? HOSumHV[CID].Val: 0.0;
417 for (
int c = 0; c < GradV.Len(); c++) {
422 for (
int c = 0; c < GradV.Len(); c++) {
426 for (
int c = 0; c < GradV.Len(); c++) {
427 if (
GetCom(IsRow, UID, CIDV[c]) == 0.0 && GradV[c] < 0.0) {
continue; }
428 if (fabs(GradV[c]) < 0.0001) {
continue; }
429 GradU.
AddDat(CIDV[c], GradV[c]);
431 for (
int c = 0; c < GradU.
Len(); c++) {
432 if (GradU[c] >= 10) { GradU[c] = 10; }
433 if (GradU[c] <= -10) { GradU[c] = -10; }
507 TIntFltH NIDFucH(
F.Len() / 10), NIDHucH(
F.Len() / 10);
508 for (
int u = 0; u <
NIDV.
Len(); u++) {
511 if (
GetCom(
true, u, CID) >= Thres) { NIDFucH.AddDat(NID,
GetCom(
true, u, CID)); }
512 if (
GetCom(
false, u, CID) >= Thres) { NIDHucH.AddDat(NID,
GetCom(
false, u, CID)); }
514 NIDFucH.SortByDat(
false);
515 NIDHucH.SortByDat(
false);
516 NIDFucH.GetKeyV(CmtyVOut);
517 NIDHucH.GetKeyV(CmtyVIn);
523 if (IsAverage == 1) {
524 TIntV CmtyVIn, CmtyVOut;
526 if (CmtyVIn.
Len() == 0 || CmtyVOut.
Len() == 0) {
continue; }
527 if (CmtyVIn.
Len() < MinSz || CmtyVOut.
Len() < MinSz) {
continue; }
535 if (TopK < CIdFHH.
Len()) { CIdV.
Trunc(TopK); }
542 for (
int c = 0; c <
NumComs; c++) {
546 for (
int c = 0; c <
NumComs; c++) {
547 int CID = CIDSumFH.
GetKey(c);
548 TIntFltH NIDFucH, NIDHucH, NIDInOutH;
550 GetNIDValH(NIDInOutH, NIDFucH, NIDHucH, CID, Thres);
556 if (CmtyV.
Len() >= MinSz) { CmtyVV.
Add(CmtyV); }
558 if ( NumComs != CmtyVV.
Len()) {
559 printf(
"Community vector generated. %d communities are ommitted\n", NumComs.Val - CmtyVV.
Len());
565 for (
int c = 0; c <
NumComs; c++) {
567 for (
int u = 0; u <
G->
GetNodes(); u++) {
570 if (CmtyV.
Len() >= MinSz) { CmtyVV.
Add(CmtyV); }
572 if ( NumComs != CmtyVV.
Len()) {
573 printf(
"Community vector generated. %d communities are ommitted\n", NumComs.Val - CmtyVV.
Len());
581 int NIdx = NI.GetId();
582 int NID =
NIDV[NIdx];
585 for (
int e = 0; e < NI.GetOutDeg(); e++) {
586 int OutNID =
NIDV[NI.GetOutNId(e)];
601 for (
int u = 0; u <
NIDV.
Len(); u++) {
602 if (
GetCom(
true, u, CID) >= Thres &&
GetCom(
false, u, CID) >= Thres) {
605 if (
GetCom(
true, u, CID) >= Thres) {
608 if (
GetCom(
false, u, CID) >= Thres) {
619 FILE* FId = fopen(OutFNm.
CStr(),
"wt");
621 for (
int c = 0; c <
NumComs; c++) {
624 CIDSumFH.SortByDat(
false);
625 for (
int c = 0; c <
NumComs; c++) {
626 int CID = CIDSumFH.GetKey(c);
627 TIntFltH NIDOutFH, NIDInFH, NIDInOutFH;
628 GetNIDValH(NIDInOutFH, NIDOutFH, NIDInFH, CID, Thres);
629 if (NIDOutFH.
Len() == 0 || NIDInFH.
Len() == 0) {
continue; }
646 fprintf(FId,
"%d\t%d\t%d\t%f\t%f\t%f\t", NIDInOutFH.
Len(), NIDInFH.
Len() - NIDInOutFH.
Len(), NIDOutFH.
Len() - NIDInOutFH.
Len(), CIDSumFH.GetDat(CID).Val,
GetSumVal(
false, CID).
Val,
GetSumVal(
true, CID).
Val);
647 fprintf(FId,
"InOut:\t");
648 for (
int u = 0; u < NIDInOutFH.
Len(); u++) {
649 int NIdx = NIDInOutFH.
GetKey(u);
650 fprintf(FId,
"%s (%f)\t", NodeNameH.
GetKey(NIdx), NIDInOutFH[u].Val);
652 fprintf(FId,
"In:\t");
653 for (
int u = 0; u < NIDInFH.
Len(); u++) {
654 int NIdx = NIDInFH.
GetKey(u);
655 fprintf(FId,
"%s (%f)\t", NodeNameH.
GetKey(NIdx), NIDInFH[u].Val);
657 fprintf(FId,
"Out:\t");
658 for (
int u = 0; u < NIDOutFH.
Len(); u++) {
659 int NIdx = NIDOutFH.
GetKey(u);
660 fprintf(FId,
"%s (%f)\t", NodeNameH.
GetKey(NIdx), NIDOutFH[u].Val);
677 for (
int u = 0; u <
NIDV.
Len(); u++) {
678 if (
GetCom(
true, u, CID) > Thres) {
728 GetCmtyVV(
false, CmtyVVIn, ThresIn, MinSz);
729 GetCmtyVV(
true, CmtyVVOut, ThresOut, MinSz);
733 int TCoda::FindComsByCV(
const int NumThreads,
const int MaxComs,
const int MinComs,
const int DivComs,
const TStr OutFNm,
const int EdgesForCV,
const double StepAlpha,
const double StepBeta) {
734 double ComsGap = exp(
TMath::Log((
double) MaxComs / (
double) MinComs) / (
double) DivComs);
737 while (ComsV.
Len() < DivComs) {
738 int NewComs = int(ComsV.
Last() * ComsGap);
739 if (NewComs == ComsV.
Last().
Val) { NewComs++; }
742 if (ComsV.
Last() < MaxComs) { ComsV.
Add(MaxComs); }
743 return FindComsByCV(ComsV, 0.1, NumThreads, OutFNm, EdgesForCV, StepAlpha, StepBeta);
746 int TCoda::FindComsByCV(
TIntV& ComsV,
const double HOFrac,
const int NumThreads,
const TStr PlotLFNm,
const int EdgesForCV,
const double StepAlpha,
const double StepBeta) {
747 if (ComsV.
Len() == 0) {
750 while(ComsV.
Last() < MaxComs) { ComsV.
Add(ComsV.
Last() * 2); }
756 TAGMFastUtil::GetNIdPhiV<PNGraph>(
G, NIdPhiV);
758 if (G->GetEdges() > EdgesForCV) {
759 printf(
"generating hold out set\n");
763 for (
int IterCV = 0; IterCV < MaxIterCV; IterCV++) {
787 printf(
"hold out set generated\n");
792 for (
int c = 0; c < ComsV.
Len(); c++) {
793 const int Coms = ComsV[c];
794 printf(
"Try number of Coms:%d\n", Coms);
796 if (G->GetEdges() > EdgesForCV) {
797 for (
int IterCV = 0; IterCV < MaxIterCV; IterCV++) {
800 printf(
"Initialized\n");
802 if (NumThreads == 1) {
803 printf(
"MLE without parallelization begins\n");
804 MLEGradAscent(0.05, 10 * G->GetNodes(),
"", StepAlpha, StepBeta);
806 printf(
"MLE with parallelization begins\n");
817 double BIC = 2 *
Likelihood() - (double) G->GetNodes() * Coms * 2.0 * log ( (
double) G->GetNodes());
824 for (
int c = 0; c < ComsV.
Len(); c++) {
825 ComsLV.Add(
TIntFltPr(ComsV[c].Val, HOLV[c].Val));
826 printf(
"%d(%f)\t", ComsV[c].Val, HOLV[c].Val);
827 if (MaxL < HOLV[c]) {
835 if (! PlotLFNm.
Empty()) {
836 TGnuPlot::PlotValV(ComsLV, PlotLFNm,
"hold-out likelihood",
"communities",
"likelihood");
843 for (
int u = 0; u <
HOVIDSV.Len(); u++) {
844 for (
int e = 0; e <
HOVIDSV[u].Len(); e++) {
846 if (VID == u) {
continue; }
849 L += log(1.0 - Pred);
860 double StepSize = 1.0;
863 for(
int iter = 0; iter < MaxIter; iter++) {
864 for (
int i = 0; i < DeltaV.
Len(); i++){
865 int CID = DeltaV.
GetKey(i);
867 NewVal =
GetCom(IsRow, UID, CID) + StepSize * DeltaV.
GetDat(CID);
870 NewVarV.AddDat(CID, NewVal);
877 if (iter == MaxIter - 1) {
885 int TCoda::MLEGradAscent(
const double& Thres,
const int& MaxIter,
const TStr PlotNm,
const double StepAlpha,
const double StepBeta) {
886 time_t InitTime = time(NULL);
888 int iter = 0, PrevIter = 0;
891 double PrevL =
TFlt::Mn, CurL = 0.0;
893 for (
int i = 0; i <
F.Len(); i++) { NIdxV.
Add(i); }
896 while(iter < MaxIter) {
898 for (
int ui = 0; ui <
F.Len(); ui++, iter++) {
899 const bool IsRow = (ui % 2 == 0);
905 for (
int e = 0; e < Deg; e++) {
907 if (
HOVIDSV[u].IsKey(VID)) {
continue; }
910 CIDSet.
AddKey(CI.GetKey());
917 if (! CIDSet.
IsKey(CI.GetKey())) {
918 DelCom(IsRow, u, CI.GetKey());
921 if (CIDSet.
Empty()) {
continue; }
923 if (
Norm2(GradV) < 1e-4) {
continue; }
925 if (LearnRate == 0.0) {
continue; }
926 for (
int ci = 0; ci < GradV.Len(); ci++) {
927 int CID = GradV.GetKey(ci);
928 double Change = LearnRate * GradV.GetDat(CID);
929 double NewFuc =
GetCom(IsRow, u, CID) + Change;
933 AddCom(IsRow, u, CID, NewFuc);
940 printf(
"\r%d iterations (%f) [%lu sec]", iter, CurL, time(NULL) - InitTime);
942 if (iter - PrevIter >= 2 *
G->
GetNodes() && iter > 10000) {
946 printf(
"\r%d iterations, Likelihood: %f, Diff: %f", iter, CurL, CurL - PrevL);
949 if (CurL - PrevL <= Thres * fabs(PrevL)) {
break; }
950 else { PrevL = CurL; }
955 printf(
"MLE for Lambda completed with %d iterations(%s)\n", iter, ExeTm.
GetTmStr());
956 if (! PlotNm.
Empty()) {
962 int TCoda::MLEGradAscentParallel(
const double& Thres,
const int& MaxIter,
const int ChunkNum,
const int ChunkSize,
const TStr PlotNm,
const double StepAlpha,
const double StepBeta) {
964 time_t InitTime = time(NULL);
972 for (
int i = 0; i <
F.Len(); i++) { NIdxV.
Add(i); }
976 TIntV NewNIDV(ChunkNum * ChunkSize);
977 TBoolV IsRowV(ChunkNum * ChunkSize);
978 for (iter = 0; iter < MaxIter; iter++) {
980 for (
int i = 0; i <
F.Len(); i++) {
987 #pragma omp parallel for schedule(static, 1)
988 for (
int TIdx = 0; TIdx < ChunkNum; TIdx++) {
990 for (
int ui = TIdx * ChunkSize; ui < (TIdx + 1) * ChunkSize; ui++) {
991 const bool IsRow = (ui % 2 == 0);
993 if (ui > NIdxV.Len()) {
continue; }
994 const int u = NIdxV[ui];
1000 for (
int e = 0; e < Deg; e++) {
1002 if (
HOVIDSV[u].IsKey(VID)) {
continue; }
1005 CIDSet.
AddKey(CI.GetKey());
1008 if (CIDSet.
Empty()) {
1013 if (! CIDSet.
IsKey(CI.GetKey())) {
1018 if (
Norm2(GradV) < 1e-4) { NIDOPTV[u] = 1;
continue; }
1020 if (LearnRate == 0.0) { NewNIDV[ui] = -2;
continue; }
1021 for (
int ci = 0; ci < GradV.
Len(); ci++) {
1022 int CID = GradV.
GetKey(ci);
1023 double Change = LearnRate * GradV.
GetDat(CID);
1024 double NewFuc = CurFU.
IsKey(CID)? CurFU.
GetDat(CID) + Change : Change;
1025 if (NewFuc <= 0.0) {
1028 CurFU.
AddDat(CID) = NewFuc;
1039 int NumNoChangeGrad = 0;
1040 int NumNoChangeStepSize = 0;
1041 for (
int ui = 0; ui < NewNIDV.
Len(); ui++) {
1042 int NewNID = NewNIDV[ui];
1043 if (NewNID == -1) { NumNoChangeGrad++;
continue; }
1044 if (NewNID == -2) { NumNoChangeStepSize++;
continue; }
1055 #pragma omp parallel for
1056 for (
int ui = 0; ui < NewNIDV.
Len(); ui++) {
1057 int NewNID = NewNIDV[ui];
1058 if (NewNID < 0) {
continue; }
1060 F[NewNID] = NewF[ui];
1062 H[NewNID] = NewF[ui];
1065 for (
int ui = 0; ui < NewNIDV.
Len(); ui++) {
1066 int NewNID = NewNIDV[ui];
1067 if (NewNID < 0) {
continue; }
1079 for (
int ui = 0; ui < NewNIDV.
Len(); ui++) {
1080 int NewNID = NewNIDV[ui];
1081 if (NewNID < 0) {
continue; }
1083 NIDOPTV[NewNID] = 0;
1084 for (
int e = 0; e < UI.
GetDeg(); e++) {
1089 for (
int i = 0; i < NIDOPTV.Len(); i++) {
if (NIDOPTV[i] == 1) { OPTCnt++; } }
1097 if ((iter - PrevIter) * ChunkSize * ChunkNum >=
G->
GetNodes()) {
1100 IterLV.
Add(
TIntFltPr(iter * ChunkSize * ChunkNum, CurL));
1101 printf(
"\r%d iterations, Likelihood: %f, Diff: %f [%lu secs]", iter, CurL, CurL - PrevL, time(NULL) - InitTime);
1103 if (CurL - PrevL <= Thres * fabs(PrevL)) {
1111 if (! PlotNm.
Empty()) {
1112 printf(
"\nMLE completed with %d iterations(%lu secs)\n", iter, time(NULL) - InitTime);
1115 printf(
"\rMLE completed with %d iterations(%lu secs)\n", iter, time(NULL) - InitTime);
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
void GetNIdV(TIntV &NIdV) const
Gets a vector IDs of all nodes in the graph.
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
double LikelihoodForNode(const bool IsRow, const int UID)
void AddComIn(const int &NID, const int &CID, const double &Val)
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.
void SetGraph(const PNGraph &GraphPt)
void Save(TSOut &SOut) const
void GetNIDValH(TIntFltH &NIdValInOutH, TIntFltH &NIdValOutH, TIntFltH &NIdValInH, const int CID, const double Thres)
double Likelihood(const bool DoParallel=false)
void NeighborComInit(const int InitComs)
int GetEdges() const
Returns the number of edges in the graph.
TSizeTy Len() const
Returns the number of elements in the vector.
void Gen(const int &ExpectVals)
void SetCmtyVV(const TVec< TIntV > &CmtyVVOut, const TVec< TIntV > &CmtyVVIn)
int GetNodes() const
Returns the number of nodes in the graph.
TFlt & GetSumVal(const bool IsOut, const int CID)
void Save(TSOut &SOut) const
int AddNode(int NId=-1)
Adds a node of ID NId to the graph.
void GetCmtyS(TIntSet &CmtySOut, TIntSet &CmtySIn, const int CID, const double Thres)
int FindComsByCV(TIntV &ComsV, const double HOFrac=0.2, const int NumThreads=20, const TStr PlotLFNm=TStr(), const int EdgesForCV=100, const double StepAlpha=0.3, const double StepBeta=0.1)
const TDat & GetDat(const TKey &Key) const
void GetTopCIDs(TIntV &CIdV, const int TopK, const int IsAverage=1, const int MinSz=1)
bool IsKey(const TKey &Key) const
const TKey & GetKey(const int &KeyId) const
double DotProduct(const TIntFltH &UV, const TIntFltH &VV)
void Save(TSOut &SOut) const
void GetCmtyVVUnSorted(const bool IsOut, TVec< TIntV > &CmtyVV, const double Thres, const int MinSz=3)
int MLEGradAscentParallel(const double &Thres, const int &MaxIter, const int ChunkNum, const int ChunkSize, const TStr PlotNm, const double StepAlpha=0.3, const double StepBeta=0.1)
TPair< TInt, TFlt > TIntFltPr
const char * GetTmStr() const
double GetStepSizeByLineSearch(const bool IsRow, const int UID, const TIntFltH &DeltaV, const TIntFltH &GradV, const double &Alpha, const double &Beta, const int MaxIter=10)
void AddComOut(const int &NID, const int &CID, const double &Val)
void GetCmtyVV(TVec< TIntV > &CmtyVVOut, TVec< TIntV > &CmtyVVIn, const int MinSz=3)
double LikelihoodHoldOut(const bool DoParallel=false)
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
void Gen(const int &ExpectVals)
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node IDs SrcNId to node DstNId to the graph.
void PutAll(const TVal &Val)
Sets all elements of the vector to value Val.
static PNGraph Load(TSIn &SIn)
Static constructor that loads the graph from a stream SIn and returns a pointer to it...
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.
PUNGraph GetSubGraph(const PUNGraph &Graph, const TIntV &NIdV, const bool &RenumberNodes)
Returns an induced subgraph of an undirected graph Graph with NIdV nodes with an optional node renumb...
const char * GetKey(const int &KeyId) const
int MLEGradAscent(const double &Thres, const int &MaxIter, const TStr PlotNm, const double StepAlpha=0.3, const double StepBeta=0.1)
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
int AddKey(const TKey &Key)
const TVal & Last() const
Returns a reference to the last element of the vector.
void Load(TSIn &SIn, const int &RndSeed=0)
double Prediction(const TIntFltH &FU, const TIntFltH &HV)
int GetDeg() const
Returns degree of the current node, the sum of in-degree and out-degree.
int AddKey(const char *Key)
void DelCom(const bool IsOut, const int &NID, const int &CID)
void Save(TSOut &SOut) const
Saves the graph to a (binary) stream SOut.
void GetNonEdgePairScores(TFltIntIntTrV &ScoreV)
void RandomInit(const int InitComs)
double Norm2(const TIntFltH &UV)
void PutSeed(const int &_Seed)
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
void GetKeyV(TVec< TKey > &KeyV) const
int GetOutDeg() const
Returns out-degree of the current node.
static TStr Fmt(const char *FmtStr,...)
Node iterator. Only forward iteration (operator++) is supported.
void DumpMemberships(const TStr &OutFNm, const TStrHash< TInt > &NodeNameH)
bool DelIfKey(const TKey &Key)
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
static void GenHoldOutPairs(const PGraph &G, TVec< TIntSet > &HoldOutSet, double HOFrac, TRnd &Rnd)
void AddCom(const bool IsOut, const int &NID, const int &CID, const double &Val)
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
static double Log(const double &Val)
int GetUniDevInt(const int &Range=0)
void GetCommunity(TIntV &CmtyVIn, TIntV &CmtyVOut, const int CID)
int GetInDeg() const
Returns in-degree 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).
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
void DelSelfEdges(const PGraph &Graph)
Removes all the self-edges from the graph.
void Trunc(const TSizeTy &_Vals=-1)
Truncates the vector's length and capacity to _Vals elements.
double Sum(const TIntFltH &UV)
double GetCom(const bool IsOut, const int &NID, const int &CID)
TDat & AddDat(const TKey &Key)
static void PlotValV(const TVec< TVal1 > &ValV, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const bool &PowerFit=false, const TGpSeriesTy &SeriesTy=gpwLinesPoints)
void GradientForNode(const bool IsRow, const int UID, TIntFltH &GradU, const TIntSet &CIDSet)
int GetOutNId(const int &NodeN) const
Returns ID of NodeN-th out-node (the node the current node points to).
void Save(TSOut &SOut) const
const TKey & GetKey(const int &KeyId) const
TTriple< TFlt, TInt, TInt > TFltIntIntTr
Vector is a sequence TVal objects representing an array that can change in size.
void SortByDat(const bool &Asc=true)