You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SNAP should support finding the NId(s) with the minimum degree. The following is the delta to add support:
--- snap-core/alg.h.old 2023-12-09 22:16:39.458539066 -0700
+++ snap-core/alg.h 2023-12-09 22:32:35.778365319 -0700
@@ -19,10 +19,17 @@
/// Returns a randomly chosen node from all the nodes with the maximum in-degree.
template int GetMxInDegNId(const PGraph& Graph);
/// Returns a randomly chosen node from all the nodes with the maximum out-degree.
template int GetMxOutDegNId(const PGraph& Graph);
+/// Returns a randomly chosen node from all the nodes with the minimum degree.
+template int GetMnDegNId(const PGraph& Graph);
+/// Returns a randomly chosen node from all the nodes with the minimum in-degree.
+template int GetMnInDegNId(const PGraph& Graph);
+/// Returns a randomly chosen node from all the nodes with the minimum out-degree.
+template int GetMnOutDegNId(const PGraph& Graph);
+
// degree histograms
/// Returns an in-degree histogram: a set of pairs (in-degree, number of nodes of such in-degree)
template void GetInDegCnt(const PGraph& Graph, TIntPrV& DegToCntV);
/// Returns an in-degree histogram: a set of pairs (in-degree, number of nodes of such in-degree)
template void GetInDegCnt(const PGraph& Graph, TFltPrV& DegToCntV);
@@ -174,10 +181,46 @@
EAssertR(! MxDegV.Empty(), "Input graph is empty!");
return MxDegV[TInt::Rnd.GetUniDevInt(MxDegV.Len())];
}
template
+int GetMnDegNId(const PGraph& Graph) {
TIntV MnDegV;
int MnDeg=INT_MAX;
for (typename PGraph::TObj::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
if (MnDeg > NI.GetDeg()) { MnDegV.Clr(); MnDeg = NI.GetDeg(); }
if (MnDeg == NI.GetDeg()) { MnDegV.Add(NI.GetId()); }
}
EAssertR(! MnDegV.Empty(), "Input graph is empty!");
SNAP should support finding the NId(s) with the minimum degree. The following is the delta to add support:
--- snap-core/alg.h.old 2023-12-09 22:16:39.458539066 -0700
+++ snap-core/alg.h 2023-12-09 22:32:35.778365319 -0700
@@ -19,10 +19,17 @@
/// Returns a randomly chosen node from all the nodes with the maximum in-degree.
template int GetMxInDegNId(const PGraph& Graph);
/// Returns a randomly chosen node from all the nodes with the maximum out-degree.
template int GetMxOutDegNId(const PGraph& Graph);
+/// Returns a randomly chosen node from all the nodes with the minimum degree.
+template int GetMnDegNId(const PGraph& Graph);
+/// Returns a randomly chosen node from all the nodes with the minimum in-degree.
+template int GetMnInDegNId(const PGraph& Graph);
+/// Returns a randomly chosen node from all the nodes with the minimum out-degree.
+template int GetMnOutDegNId(const PGraph& Graph);
+
// degree histograms
/// Returns an in-degree histogram: a set of pairs
(in-degree, number of nodes of such in-degree)
template void GetInDegCnt(const PGraph& Graph, TIntPrV& DegToCntV);
/// Returns an in-degree histogram: a set of pairs
(in-degree, number of nodes of such in-degree)
template void GetInDegCnt(const PGraph& Graph, TFltPrV& DegToCntV);
@@ -174,10 +181,46 @@
EAssertR(! MxDegV.Empty(), "Input graph is empty!");
return MxDegV[TInt::Rnd.GetUniDevInt(MxDegV.Len())];
}
template
+int GetMnDegNId(const PGraph& Graph) {
+}
+template
+int GetMnInDegNId(const PGraph& Graph) {
+}
+template
+int GetMnOutDegNId(const PGraph& Graph) {
+}
+template
void GetInDegCnt(const PGraph& Graph, TIntPrV& DegToCntV) {
TIntH DegToCntH;
for (typename PGraph::TObj::TNodeI NI = Graph->BegNI(); NI < Graph->EndNI(); NI++) {
DegToCntH.AddDat(NI.GetInDeg())++; }
DegToCntV.Gen(DegToCntH.Len(), 0);
The text was updated successfully, but these errors were encountered: