SNAP Library 2.0, User Reference
2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <kronecker.h>
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) |
Definition at line 251 of file kronecker.h.
TKronNoise::TKronNoise | ( | ) | [inline] |
Definition at line 253 of file kronecker.h.
{};
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); }