SNAP Library 2.2, User Reference  2014-03-11 19:15:55
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TKronNoise Class Reference

#include <kronecker.h>

List of all members.

Public Member Functions

 TKronNoise ()

Static Public Member Functions

static int RemoveNodeNoise (PNGraph &Graph, const int &NNodes, const bool Random=true)
 !!!!! MYUNGHWAN, CHECK!
static int RemoveNodeNoise (PNGraph &Graph, const double &Rate, const bool Random=true)
static int FlipEdgeNoise (PNGraph &Graph, const int &NEdges, const bool Random=true)
static int FlipEdgeNoise (PNGraph &Graph, const double &Rate, const bool Random=true)
static int RemoveEdgeNoise (PNGraph &Graph, const int &NEdges)
static int RemoveEdgeNoise (PNGraph &Graph, const double &Rate)

Detailed Description

Definition at line 251 of file kronecker.h.


Constructor & Destructor Documentation

TKronNoise::TKronNoise ( ) [inline]

Definition at line 253 of file kronecker.h.

{};

Member Function Documentation

int TKronNoise::FlipEdgeNoise ( PNGraph Graph,
const int &  NEdges,
const bool  Random = true 
) [static]

Definition at line 2229 of file kronecker.cpp.

                                                                                  {
        IAssert(NEdges > 0 && NEdges < Graph->GetEdges());

        const int Nodes = Graph->GetNodes();
        const int Edges = Graph->GetEdges();
        int Src, Dst;

        TIntV NIdV, TempV;
        TIntPrV ToAdd, ToDel;
        Graph->GetNIdV(NIdV);

        ToAdd.Gen(NEdges / 2, 0);
        for(int i = 0; i < NEdges / 2; i++) {
                Src = NIdV[TKronMtx::Rnd.GetUniDevInt(Nodes)];
                Dst = NIdV[TKronMtx::Rnd.GetUniDevInt(Nodes)];
                if(Graph->IsEdge(Src, Dst)) {   i--;    continue;       }

                ToAdd.Add(TIntPr(Src, Dst));
        }

        ToDel.Gen(Edges, 0);
        for(TNGraph::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) {
                ToDel.Add(TIntPr(EI.GetSrcNId(), EI.GetDstNId()));
        }
        ToDel.Shuffle(TKronMtx::Rnd);

        for(int i = 0; i < NEdges / 2; i++) {
                Graph->DelEdge(ToDel[i].Val1, ToDel[i].Val2);
                Graph->AddEdge(ToAdd[i].Val1, ToAdd[i].Val2);
        }

        return Graph->GetEdges();
}
int TKronNoise::FlipEdgeNoise ( PNGraph Graph,
const double &  Rate,
const bool  Random = true 
) [static]

Definition at line 2263 of file kronecker.cpp.

                                                                                   {
        IAssert(Rate > 0 && Rate < 0.5);
        return TKronNoise::FlipEdgeNoise(Graph, (int) floor(Rate * double(Graph->GetEdges())), Random);
}
int TKronNoise::RemoveEdgeNoise ( PNGraph Graph,
const int &  NEdges 
) [static]

Definition at line 2268 of file kronecker.cpp.

                                                                 {
        IAssert(NEdges > 0 && NEdges < Graph->GetEdges());

        TIntPrV ToDel;

        ToDel.Gen(Graph->GetEdges(), 0);
        for(TNGraph::TEdgeI EI = Graph->BegEI(); EI < Graph->EndEI(); EI++) {
                if(EI.GetSrcNId() != EI.GetDstNId()) {
                        ToDel.Add(TIntPr(EI.GetSrcNId(), EI.GetDstNId()));
                }
        }
        ToDel.Shuffle(TKronMtx::Rnd);

        for(int i = 0; i < NEdges; i++) {
                Graph->DelEdge(ToDel[i].Val1, ToDel[i].Val2);
        }

        return Graph->GetEdges();
}
int TKronNoise::RemoveEdgeNoise ( PNGraph Graph,
const double &  Rate 
) [static]

Definition at line 2288 of file kronecker.cpp.

                                                                  {
        IAssert(Rate > 0 && Rate < 0.5);
        return TKronNoise::RemoveEdgeNoise(Graph, (int) floor(Rate * double(Graph->GetEdges())));
}
int TKronNoise::RemoveNodeNoise ( PNGraph Graph,
const int &  NNodes,
const bool  Random = true 
) [static]

!!!!! MYUNGHWAN, CHECK!

Definition at line 2204 of file kronecker.cpp.

                                                                                    {
        IAssert(NNodes > 0 && NNodes < (Graph->GetNodes() / 2));

        int i = 0;
        TIntV ShufflePerm;
        Graph->GetNIdV(ShufflePerm);
        if(Random) {
                ShufflePerm.Shuffle(TKronMtx::Rnd);
                for(i = 0; i < NNodes; i++) {
                        Graph->DelNode(int(ShufflePerm[i]));
                }
        } else {
                for(i = 0; i < NNodes; i++) {
                        Graph->DelNode(int(ShufflePerm[ShufflePerm.Len() - 1 - i]));
                }
        }

        return Graph->GetNodes();
}
int TKronNoise::RemoveNodeNoise ( PNGraph Graph,
const double &  Rate,
const bool  Random = true 
) [static]

Definition at line 2224 of file kronecker.cpp.

                                                                                     {
        IAssert(Rate > 0 && Rate < 0.5);
        return TKronNoise::RemoveNodeNoise(Graph, (int) floor(Rate * double(Graph->GetNodes())), Random);
}

The documentation for this class was generated from the following files: