45 template <
class PGraph>
int GetNodeEcc(
const PGraph& Graph,
const int& NId,
const bool& IsDir=
false);
73 template<
class PGraph>
void GetPageRank(
const PGraph& Graph,
TIntFltH& PRankH,
const double& C=0.85,
const double& Eps=1e-4,
const int& MaxIter=100);
76 template<
class PGraph>
void GetHits(
const PGraph& Graph,
TIntFltH& NIdHubH,
TIntFltH& NIdAuthH,
const int& MaxIter=20);
80 template <
class PGraph>
81 int GetNodeEcc(
const PGraph& Graph,
const int& NId,
const bool& IsDir) {
102 template<
class PGraph>
103 void GetPageRank(
const PGraph& Graph,
TIntFltH& PRankH,
const double& C,
const double& Eps,
const int& MaxIter) {
104 const int NNodes = Graph->GetNodes();
107 for (
typename PGraph::TObj::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
108 PRankH.
AddDat(NI.GetId(), 1.0/NNodes);
112 for (
int iter = 0; iter < MaxIter; iter++) {
114 for (
typename PGraph::TObj::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++, j++) {
116 for (
int e = 0; e < NI.GetInDeg(); e++) {
117 const int InNId = NI.GetInNId(e);
118 const int OutDeg = Graph->GetNI(InNId).GetOutDeg();
120 TmpV[j] += PRankH.
GetDat(InNId) / OutDeg; }
125 double diff=0, sum=0, NewVal;
126 for (
int i = 0; i < TmpV.
Len(); i++) { sum += TmpV[i]; }
127 const double Leaked = (1.0-sum) /
double(NNodes);
128 for (
int i = 0; i < PRankH.
Len(); i++) {
129 NewVal = TmpV[i] + Leaked;
131 diff += fabs(NewVal-PRankH[i]);
134 if (diff < Eps) {
break; }
138 template<
class PGraph>
140 const int NNodes = Graph->GetNodes();
142 NIdAuthH.
Gen(NNodes);
143 for (
typename PGraph::TObj::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
144 NIdHubH.
AddDat(NI.GetId(), 1.0);
145 NIdAuthH.
AddDat(NI.GetId(), 1.0);
148 for (
int iter = 0; iter < MaxIter; iter++) {
151 for (
typename PGraph::TObj::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
152 double& Auth = NIdAuthH.
GetDat(NI.GetId()).Val;
154 for (
int e = 0; e < NI.GetInDeg(); e++) {
155 Auth += NIdHubH.
GetDat(NI.GetInNId(e)); }
159 for (
int i = 0; i < NIdAuthH.
Len(); i++) { NIdAuthH[i] /= Norm; }
161 for (
typename PGraph::TObj::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
162 double& Hub = NIdHubH.
GetDat(NI.GetId()).Val;
164 for (
int e = 0; e < NI.GetOutDeg(); e++) {
165 Hub += NIdAuthH.
GetDat(NI.GetOutNId(e)); }
169 for (
int i = 0; i < NIdHubH.
Len(); i++) { NIdHubH[i] /= Norm; }
173 for (
int i = 0; i < NIdHubH.
Len(); i++) { Norm +=
TMath::Sqr(NIdHubH[i]); }
175 for (
int i = 0; i < NIdHubH.
Len(); i++) { NIdHubH[i] /= Norm; }
177 for (
int i = 0; i < NIdAuthH.
Len(); i++) { Norm +=
TMath::Sqr(NIdAuthH[i]); }
179 for (
int i = 0; i < NIdAuthH.
Len(); i++) { NIdAuthH[i] /= Norm; }
double GetGroupDegreeCentr(const PUNGraph &Graph, const PUNGraph &Group)
double GetDegreeCentr(const PUNGraph &Graph, const int &NId)
int Intersect(TUNGraph::TNodeI Node, TIntH NNodes)
Intersect.
void GetPageRank(const PGraph &Graph, TIntFltH &PRankH, const double &C=0.85, const double &Eps=1e-4, const int &MaxIter=100)
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...
TSizeTy Len() const
Returns the number of elements in the vector.
void GetBetweennessCentr(const PUNGraph &Graph, const TIntV &BtwNIdV, TIntFltH &NodeBtwH, const bool &DoNodeCent, TIntPrFltH &EdgeBtwH, const bool &DoEdgeCent)
Node iterator. Only forward iteration (operator++) is supported.
const TDat & GetDat(const TKey &Key) const
TIntFltH EventImportance(const PNGraph &Graph, const int k)
Event importance.
static double Sqr(const double &x)
void Gen(const int &ExpectVals)
TIntH MaxCPGreedyBetter(const PUNGraph &Graph, const int k)
Returns centrality Maximum k group.
double GetGroupClosenessCentr(const PUNGraph &Graph, const TIntH &GroupNodes)
double GetClosenessCentr(const PUNGraph &Graph, const int &NId)
int GetNodeEcc(const PGraph &Graph, const int &NId, const bool &IsDir=false)
void GetHits(const PGraph &Graph, TIntFltH &NIdHubH, TIntFltH &NIdAuthH, const int &MaxIter=20)
TIntH MaxCPGreedyBetter1(const PUNGraph &Graph, const int k)
Returns centrality Maximum k group.
int Intersect1(TUNGraph::TNodeI Node, TStr NNodes)
TIntH MaxCPGreedyBetter2(const PUNGraph &Graph, const int k)
Returns centrality Maximum k group.
double GetFarnessCentr(const PUNGraph &Graph, const int &NId)
TIntH LoadNodeList(TStr InFNmNodes)
void GetEigenVectorCentr(const PUNGraph &Graph, TIntFltH &NIdEigenH, const double &Eps, const int &MaxIter)
TDat & AddDat(const TKey &Key)
TIntH MaxCPGreedyBetter3(const PUNGraph &Graph, const int k)
Returns centrality Maximum k group.