SNAP Library 6.0, User Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
rolx.h
Go to the documentation of this file.
1 #ifndef snap_rolx_h
2 #define snap_rolx_h
3 #include "Snap.h"
4 
6 typedef TVec<TFlt> TFtr;
9 
11 void PrintFeatures(const TIntFtrH& Features);
15 TIntFtrH CreateEmptyFeatures(const TIntFtrH& Features);
17 int GetNumFeatures(const TIntFtrH& Features);
19 TFtr GetNthFeature(const TIntFtrH& Features, const int N);
21 TIntFtrH ExtractFeatures(const PUNGraph Graph);
23 void AddNeighborhoodFeatures(const PUNGraph Graph, TIntFtrH& Features);
25 void AddRecursiveFeatures(const PUNGraph Graph, TIntFtrH& Features);
27 void AddLocalFeatures(const PUNGraph Graph, TIntFtrH& Features);
29 void AddEgonetFeatures(const PUNGraph Graph, TIntFtrH& Features);
32  const TIntFtrH& CurrFeatures);
34 TIntFtrH PruneRecursiveFeatures(const PUNGraph Graph, const TIntFtrH& Features,
35  const TIntFtrH& NewFeatures, const int SimilarityThreshold);
37 void AppendFeatures(TIntFtrH& DstFeatures, const TIntFtrH& SrcFeatures,
38  const int ColIdx = -1);
41  const float BinFraction);
43 PUNGraph BuildFeatureGraph(const TIntFtrH& LogFeatures,
44  const int SimilarityThreshold);
47  const TIntFtrH& Features, const TIntFtrH& NewFeatures);
49 TVec<TInt> GetNIdSorted(const TIntFtrH& Feature, const int Idx);
51 void AssignBinValue(const TVec<TInt>& SortedNId, const float BinFraction,
52  TIntFtrH& LogBinFeatures);
54 bool IsSimilarFeature(const TFtr& F1, const TFtr& F2,
55  const int SimilarityThreshold);
57 TFltVV ConvertFeatureToMatrix(const TIntFtrH& Features,
58  const TIntIntH& NodeIdMtxIdxH);
60 void PrintMatrix(const TFltVV& Matrix);
62 TFltVV CreateRandMatrix(const int XDim, const int YDim);
64 bool FltIsZero(const TFlt Number);
66 void CalcNonNegativeFactorization(const TFltVV& V, const int NumRoles,
67  TFltVV& W, TFltVV& H, const double Threshold);
69 TFlt CalcDescriptionLength(const TFltVV& V, const TFltVV& G,
70  const TFltVV& F);
74 int GetMtxIdx(const TInt NodeId, const TIntIntH& NodeIdMtxIdxH);
76 TIntIntH FindRoles(const TFltVV& G, const TIntIntH& NodeIdMtxIdxH);
78 void PlotRoles(const PUNGraph Graph, const TIntIntH& Roles);
80 void PrintRoles(const TIntIntH& Roles);
82 void FPrintMatrix(const TFltVV& Matrix, const TStr& Path);
84 void FPrintNodeMappings(const TIntIntH& NodeIdMtxIdxH, const TStr& Path);
86 void FPrintRoles(const TIntIntH& Roles, const TStr& Path);
87 
88 #endif
TIntFtrH GenerateRecursiveFeatures(const PUNGraph Graph, const TIntFtrH &CurrFeatures)
Generates recursive features out of current features.
Definition: rolx.cpp:97
int GetNumFeatures(const TIntFtrH &Features)
Gets number of features from the node-feature mapping.
Definition: rolx.cpp:35
TIntFtrH ExtractFeatures(const PUNGraph Graph)
Performs feature extraction, the first step of RolX.
Definition: rolx.cpp:48
void PlotRoles(const PUNGraph Graph, const TIntIntH &Roles)
Plots found roles on a picture (.png).
Definition: rolx.cpp:415
void AssignBinValue(const TVec< TInt > &SortedNId, const float BinFraction, TIntFtrH &LogBinFeatures)
Assigns logarithmic binning value to features.
Definition: rolx.cpp:212
void AddRecursiveFeatures(const PUNGraph Graph, TIntFtrH &Features)
Adds recursive features to the node-feature mapping.
Definition: rolx.cpp:64
bool IsSimilarFeature(const TFtr &F1, const TFtr &F2, const int SimilarityThreshold)
Whether the two features are similar, given similarity threshold.
Definition: rolx.cpp:228
void PrintMatrix(const TFltVV &Matrix)
Prints feature matrix to stdout.
Definition: rolx.cpp:253
void AppendFeatures(TIntFtrH &DstFeatures, const TIntFtrH &SrcFeatures, const int ColIdx=-1)
Appends all src features to dst features.
Definition: rolx.cpp:131
TIntFtrH SummarizeConnectedComponents(const PUNGraph FeatureGraph, const TIntFtrH &Features, const TIntFtrH &NewFeatures)
Summarizes s-friend graph and return retained features.
Definition: rolx.cpp:178
TIntIntH FindRoles(const TFltVV &G, const TIntIntH &NodeIdMtxIdxH)
Gets matrix index of the node ID.
Definition: rolx.cpp:398
THash< TInt, TFtr > TIntFtrH
The node-feature mapping: .
Definition: rolx.h:8
TIntFtrH PruneRecursiveFeatures(const PUNGraph Graph, const TIntFtrH &Features, const TIntFtrH &NewFeatures, const int SimilarityThreshold)
Prunes recursive features.
Definition: rolx.cpp:119
Definition: dt.h:1386
PUNGraph BuildFeatureGraph(const TIntFtrH &LogFeatures, const int SimilarityThreshold)
Builds s-friend graph given similarity threshold.
Definition: rolx.cpp:158
TIntFtrH CalcVerticalLogBinning(const TIntFtrH &Features, const float BinFraction)
Calculates vertical logarithmic binning features from the given features.
Definition: rolx.cpp:147
void FPrintRoles(const TIntIntH &Roles, const TStr &Path)
Prints found roles to file.
Definition: rolx.cpp:462
TFltVV ConvertFeatureToMatrix(const TIntFtrH &Features, const TIntIntH &NodeIdMtxIdxH)
Converts node-feature mapping to matrix. (i, j): i-th node, j-th feature.
Definition: rolx.cpp:239
void PrintFeatures(const TIntFtrH &Features)
Prints all nodes' feature.
Definition: rolx.cpp:5
TIntFtrH CreateEmptyFeatures(const PUNGraph Graph)
Creates an empty node-feature mapping of all nodes in the given graph.
Definition: rolx.cpp:19
int GetMtxIdx(const TInt NodeId, const TIntIntH &NodeIdMtxIdxH)
Gets matrix index of the node ID.
Definition: rolx.cpp:383
void FPrintNodeMappings(const TIntIntH &NodeIdMtxIdxH, const TStr &Path)
Prints node mappings to file, feature line -> node ID.
Definition: rolx.cpp:451
bool FltIsZero(const TFlt Number)
Whether the float is zero.
Definition: rolx.cpp:282
void AddEgonetFeatures(const PUNGraph Graph, TIntFtrH &Features)
Adds egonet features to the node-feature mapping.
Definition: rolx.cpp:87
TFltVV CreateRandMatrix(const int XDim, const int YDim)
Creates a random matrix with specified dimension.
Definition: rolx.cpp:270
void AddLocalFeatures(const PUNGraph Graph, TIntFtrH &Features)
Adds local features to the node-feature mapping.
Definition: rolx.cpp:81
Definition: dt.h:1137
void CalcNonNegativeFactorization(const TFltVV &V, const int NumRoles, TFltVV &W, TFltVV &H, const double Threshold)
Performs non-negative factorization V = WH. 2nd dim of W == number of roles.
Definition: rolx.cpp:286
TFlt CalcDescriptionLength(const TFltVV &V, const TFltVV &G, const TFltVV &F)
Calculates the description length L = M + E.
Definition: rolx.cpp:352
Definition: dt.h:412
TIntIntH CreateNodeIdMtxIdxHash(const TIntFtrH &Features)
Creates the mapping of .
Definition: rolx.cpp:373
Definition: hash.h:97
TVec< TInt > GetNIdSorted(const TIntFtrH &Feature, const int Idx)
Sorts the Idx-th feature, return the list of corresponding node ID.
Definition: rolx.cpp:199
void FPrintMatrix(const TFltVV &Matrix, const TStr &Path)
Prints feature matrix to file.
Definition: rolx.cpp:434
Definition: bd.h:196
TVec< TFlt > TFtr
Feature of a node.
Definition: rolx.h:6
TFtr GetNthFeature(const TIntFtrH &Features, const int N)
Gets the n-th feature of all nodes.
Definition: rolx.cpp:39
void AddNeighborhoodFeatures(const PUNGraph Graph, TIntFtrH &Features)
Adds neighborhood features (local + egonet) to the node-feature mapping.
Definition: rolx.cpp:57
void PrintRoles(const TIntIntH &Roles)
Prints found roles on stdout.
Definition: rolx.cpp:425