10 template<
class PGraph>
42 template<
class PGraph>
44 DegH.Gen(Graph->GetNodes());
45 for (
typename PGraph::TObj::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
47 DegH.AddDat(NI.GetId(), NI.GetDeg());
52 template<
class PGraph>
55 for (
int k = DegH.FFirstKeyId(); DegH.FNextKeyId(k); ) {
61 template<
class PGraph>
64 int NDel=-1, AllDeg=0;
70 for (
int k = DegH.FFirstKeyId(); DegH.FNextKeyId(k); ) {
71 const int NId = DegH.GetKey(k);
72 const int Deg = DegH[k];
74 const typename PGraph::TObj::TNodeI NI = Graph->GetNI(NId);
75 for (
int e = 0; e < NI.GetDeg(); e++) {
76 const int n = NI.GetNbrNId(e);
77 const int nk = DegH.GetKeyId(n);
78 if (nk != -1) { DegH[nk] -= 1; }
93 template<
class PGraph>
105 template<
class PGraph>
106 PGraph
GetKCore(
const PGraph& Graph,
const int& K) {
113 template<
class PGraph>
117 CoreIdSzV.
Add(
TIntPr(0, Graph->GetNodes()));
125 template<
class PGraph>
129 CoreIdSzV.
Add(
TIntPr(0, Graph->GetEdges()));
const TIntV & GetNIdV() const
Returns the IDs of the nodes in the current K-core.
TPair< TInt, TInt > TIntPr
Main namespace for all the Snap global entities.
int GetKCoreNodes(const PGraph &Graph, TIntPrV &CoreIdSzV)
Returns the number of nodes in each core of order K (where K=0, 1, ...)
int GetCoreK(const int &K)
TSizeTy Len() const
Returns the number of elements in the vector.
int GetCoreNodes() const
Gets the number of nodes in the K-core (for the current value of K).
PGraph GetCoreG() const
Returrns the graph of the current K-core.
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
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...
int GetKCoreEdges(const PGraph &Graph, TIntPrV &CoreIdSzV)
Returns the number of edges in each core of order K (where K=0, 1, ...)
int GetCoreEdges() const
Gets the number of edges in the K-core (for the current value of K).
PGraph GetKCore(const PGraph &Graph, const int &K)
TKCore(const PGraph &_Graph)
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.