|
SNAP Library 2.1, User Reference
2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <mag.h>
Public Member Functions | |
| TMAGParam () | |
| TMAGParam (const int &NumNodes, const int &NumAttrs) | |
| TMAGParam (const int &NumNodes, const TMAGAffMtxV &MtxV) | |
| TMAGParam (const int &NumNodes, const TStr &ConfFNm) | |
| TMAGParam (const TMAGParam< TNodeAttr > &MAGParam) | |
| TMAGParam (const int &NumNodes, const int &NumAttrs, const TNodeAttr &Dist) | |
| TMAGParam< TNodeAttr > & | operator= (const TMAGParam< TNodeAttr > &MAGParam) |
| void | Clr () |
| void | LoadTxt (const TStr &InFNm) |
| void | SaveTxt (const TStr &OutFNm) const |
| void | SetNodes (const int &Nodes) |
| const int | GetNodes () const |
| void | SetAttrs (const int &Attrs) |
| const int | GetAttrs () const |
| void | SetNodeAttr (const TNodeAttr &Dist) |
| const TNodeAttr & | GetNodeAttr () const |
| const int | GetDim (const int &Attr) const |
| void | GetDimV (TIntV &DimV) const |
| void | SetMtxVal (const int &Attr, const int &Row, const int &Col, const double &Val) |
| void | SetMtx (const int &Attr, const TMAGAffMtx &Mtx) |
| void | SetMtxV (const TMAGAffMtxV &MtxV) |
| void | SetMtxAll (const TMAGAffMtx &Mtx) |
| const double | GetMtxVal (const int &Attr, const int &Row, const int &Col) const |
| const TMAGAffMtx & | GetMtx (const int &Attr) const |
| void | GetMtxV (TMAGAffMtxV &MtxV) const |
| PNGraph | GenMAG (TIntVV &AttrVV, const bool &IsDir=false, const int &Seed=1) |
| PNGraph | GenAttrMAG (const TIntVV &AttrVV, const bool &IsDir=false, const int &Seed=1) |
Static Public Attributes | |
| static TRnd | Rnd |
Private Attributes | |
| TInt | NNodes |
| TInt | NAttrs |
| TNodeAttr | NodeAttr |
| TMAGAffMtxV | AffMtxV |
| TMAGParam< TNodeAttr >::TMAGParam | ( | const int & | NumNodes, |
| const TMAGAffMtxV & | MtxV | ||
| ) | [inline] |
| PNGraph TMAGParam< TNodeAttr >::GenAttrMAG | ( | const TIntVV & | AttrVV, |
| const bool & | IsDir = false, |
||
| const int & | Seed = 1 |
||
| ) |
Definition at line 250 of file mag.h.
{
PNGraph Graph = TNGraph::New(NNodes, -1);
for(int i = 0; i < NNodes; i++) {
Graph->AddNode(i);
}
if(Seed > 0) {
TNodeAttr::Rnd.PutSeed(Seed);
}
IAssert(AttrVV.GetYDim() == NAttrs);
for(int i = 0; i < NNodes; i++) {
for(int l = 0; l < NAttrs; l++) {
IAssert(AttrVV.At(i, l) < AffMtxV[l].GetDim());
}
}
for(int i = 0; i < NNodes; i++) {
for(int j = i; j < NNodes; j++) {
double Prob = 1.0;
for(int l = 0; l < NAttrs; l++) {
Prob *= AffMtxV[l].At(AttrVV.At(i, l), AttrVV.At(j, l));
}
if(TNodeAttr::Rnd.GetUniDev() < Prob) {
Graph->AddEdge(i, j);
if(! IsDir && i != j) { Graph->AddEdge(j, i); }
}
if(IsDir && i != j) {
Prob = 1.0;
for(int l = 0; l < NAttrs; l++) {
Prob *= AffMtxV[l].At(AttrVV.At(j, l), AttrVV.At(i, l));
}
if(TNodeAttr::Rnd.GetUniDev() < Prob) {
Graph->AddEdge(j, i);
}
}
}
}
return Graph;
};
| PNGraph TMAGParam< TNodeAttr >::GenMAG | ( | TIntVV & | AttrVV, |
| const bool & | IsDir = false, |
||
| const int & | Seed = 1 |
||
| ) |
Definition at line 295 of file mag.h.
{
TNodeAttr::Rnd.PutSeed(Seed);
NodeAttr.AttrGen(AttrVV, NNodes);
IAssert(AttrVV.GetYDim() == NAttrs);
for(int i = 0; i < NNodes; i++) {
for(int l = 0; l < NAttrs; l++) {
IAssert(AttrVV.At(i, l) < AffMtxV[l].GetDim());
}
}
PNGraph Graph = GenAttrMAG(AttrVV, IsDir, 0);
return Graph;
/*
for(int i = 0; i < NNodes; i++) {
for(int j = i; j < NNodes; j++) {
double Prob = 1.0;
for(int l = 0; l < NAttrs; l++) {
Prob *= AffMtxV[l].At(AttrVV.At(i, l), AttrVV.At(j, l));
}
if(TNodeAttr::Rnd.GetUniDev() < Prob) {
Graph->AddEdge(i, j);
if(! IsDir && i != j) { Graph->AddEdge(j, i); }
}
if(IsDir && i != j) {
Prob = 1.0;
for(int l = 0; l < NAttrs; l++) {
Prob *= AffMtxV[l].At(AttrVV.At(j, l), AttrVV.At(i, l));
}
if(TNodeAttr::Rnd.GetUniDev() < Prob) {
Graph->AddEdge(j, i);
}
}
}
}
return Graph;
*/
};
| const TMAGAffMtx& TMAGParam< TNodeAttr >::GetMtx | ( | const int & | Attr | ) | const [inline] |
| void TMAGParam< TNodeAttr >::GetMtxV | ( | TMAGAffMtxV & | MtxV | ) | const [inline] |
| const TNodeAttr& TMAGParam< TNodeAttr >::GetNodeAttr | ( | ) | const [inline] |
Definition at line 222 of file mag.h.
{
TStrV OutStrV;
NodeAttr.SaveTxt(OutStrV);
FILE *fp = fopen(OutFNm.CStr(), "w");
fprintf(fp, "# %d nodes with %d attributes\n", NNodes(), NAttrs());
for(int i = 0; i < NAttrs; i++) {
TStr MtxStr = AffMtxV[i].GetMtxStr();
fprintf(fp, "%s & %s\n", OutStrV[i].CStr(), MtxStr.GetSubStr(1, MtxStr.Len()-2).CStr());
}
fclose(fp);
};
| void TMAGParam< TNodeAttr >::SetMtx | ( | const int & | Attr, |
| const TMAGAffMtx & | Mtx | ||
| ) | [inline] |
| void TMAGParam< TNodeAttr >::SetMtxAll | ( | const TMAGAffMtx & | Mtx | ) | [inline] |
| void TMAGParam< TNodeAttr >::SetMtxV | ( | const TMAGAffMtxV & | MtxV | ) | [inline] |
| void TMAGParam< TNodeAttr >::SetNodeAttr | ( | const TNodeAttr & | Dist | ) | [inline] |
TMAGAffMtxV TMAGParam< TNodeAttr >::AffMtxV [private] |