SNAP Library 6.0, Developer Reference
2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
Main namespace for all the Snap global entities. More...
Namespaces | |
TSnapDetail | |
Functions | |
template<class PGraph > | |
int | CntInDegNodes (const PGraph &Graph, const int &NodeInDeg) |
Returns the number of nodes with in-degree NodeInDeg. More... | |
template<class PGraph > | |
int | CntOutDegNodes (const PGraph &Graph, const int &NodeOutDeg) |
Returns the number of nodes with out-degree NodeOutDeg. More... | |
template<class PGraph > | |
int | CntDegNodes (const PGraph &Graph, const int &NodeDeg) |
Returns the number of nodes with degree NodeDeg. More... | |
template<class PGraph > | |
int | CntNonZNodes (const PGraph &Graph) |
Returns the number of nodes with degree greater than 0. More... | |
template<class PGraph > | |
int | CntEdgesToSet (const PGraph &Graph, const int &NId, const TIntSet &NodeSet) |
Returns the number of nodes in NodeSet that have an edge to the node NId. More... | |
template<class PGraph > | |
int | GetMxDegNId (const PGraph &Graph) |
Returns a randomly chosen node from all the nodes with the maximum degree. More... | |
template<class PGraph > | |
int | GetMxInDegNId (const PGraph &Graph) |
Returns a randomly chosen node from all the nodes with the maximum in-degree. More... | |
template<class PGraph > | |
int | GetMxOutDegNId (const PGraph &Graph) |
Returns a randomly chosen node from all the nodes with the maximum out-degree. More... | |
template<class PGraph > | |
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) More... | |
template<class PGraph > | |
void | GetInDegCnt (const PGraph &Graph, TFltPrV &DegToCntV) |
Returns an in-degree histogram: a set of pairs (in-degree, number of nodes of such in-degree) More... | |
template<class PGraph > | |
void | GetOutDegCnt (const PGraph &Graph, TIntPrV &DegToCntV) |
Returns an out-degree histogram: a set of pairs (out-degree, number of nodes of such out-degree) More... | |
template<class PGraph > | |
void | GetOutDegCnt (const PGraph &Graph, TFltPrV &DegToCntV) |
Returns an out-degree histogram: a set of pairs (out-degree, number of nodes of such out-degree) More... | |
template<class PGraph > | |
void | GetDegCnt (const PGraph &Graph, TIntPrV &DegToCntV) |
Returns a degree histogram: a set of pairs (degree, number of nodes of such degree) More... | |
template<class PGraph > | |
void | GetDegCnt (const PGraph &Graph, TFltPrV &DegToCntV) |
Returns a degree histogram: a set of pairs (degree, number of nodes of such degree) More... | |
template<class PGraph > | |
void | GetDegSeqV (const PGraph &Graph, TIntV &DegV) |
Returns a degree sequence vector. More... | |
template<class PGraph > | |
void | GetDegSeqV (const PGraph &Graph, TIntV &InDegV, TIntV &OutDegV) |
Returns an in- and out-degree sequence vectors. More... | |
template<class PGraph > | |
void | GetNodeInDegV (const PGraph &Graph, TIntPrV &NIdInDegV) |
Returns a vector of pairs (node id, node in-degree) More... | |
template<class PGraph > | |
void | GetNodeOutDegV (const PGraph &Graph, TIntPrV &NIdOutDegV) |
Returns a vector of pairs (node id, node out-degree) More... | |
template<class PGraph > | |
int | CntUniqUndirEdges (const PGraph &Graph) |
Counts unique undirected edges in the graph Graph . Nodes (u,v) (where u!=v ) are connected via an undirected edge if there exists an edge in either direction (u,v) or (v,u) . More... | |
template<class PGraph > | |
int | CntUniqDirEdges (const PGraph &Graph) |
Counts unique directed edges in the graph Graph . Nodes (u,v) (where u!=v ) are connected via a directed edge if there exists a directed edge from node u to node v . More... | |
template<class PGraph > | |
int | CntUniqBiDirEdges (const PGraph &Graph) |
Counts unique bidirectional edges in the graph Graph . Edge is bidirectional if there exist directed edges in both directions: (u,v) and (v,u) More... | |
template<class PGraph > | |
int | CntSelfEdges (const PGraph &Graph) |
Counts the number of self-edges in a graph. Edge (u,u) is a self-edge. More... | |
template<class PGraph > | |
PGraph | GetUnDir (const PGraph &Graph) |
Returs an undirected version of the graph. For every edge (u,v) an edge (v,u) is added (if it does not yet exist). More... | |
template<class PGraph > | |
void | MakeUnDir (const PGraph &Graph) |
Makes the graph undirected. For every edge (u,v) an edge (v,u) is added (if it does not yet exist). More... | |
template<class PGraph > | |
void | AddSelfEdges (const PGraph &Graph) |
Adds a self-edge to every node in the graph. More... | |
template<class PGraph > | |
void | DelSelfEdges (const PGraph &Graph) |
Removes all the self-edges from the graph. More... | |
template<class PGraph > | |
void | DelNodes (PGraph &Graph, const TIntV &NIdV) |
Removes nodes with ids stored in NIdV from the graph. More... | |
template<class PGraph > | |
void | DelZeroDegNodes (PGraph &Graph) |
Removes all the zero-degree nodes, that isolated nodes, from the graph. More... | |
template<class PGraph > | |
void | DelDegKNodes (PGraph &Graph, const int &OutDegK, const int &InDegK) |
Removes all the node of out-degree OutDegK and all the nodes of in-degree InDegK from the graph. More... | |
template<class PGraph > | |
bool | IsTree (const PGraph &Graph, int &RootNIdX) |
template<class PGraph > | |
int | GetTreeRootNId (const PGraph &Graph) |
template<class PGraph > | |
void | GetTreeSig (const PGraph &Graph, const int &RootNId, TIntV &Sig) |
template<class PGraph > | |
void | GetTreeSig (const PGraph &Graph, const int &RootNId, TIntV &Sig, TIntPrV &NodeMap) |
template<class PGraph > | |
void | GetAnf (const PGraph &Graph, const int &SrcNId, TIntFltKdV &DistNbrsV, const int &MxDist, const bool &IsDir, const int &NApprox=32) |
template<class PGraph > | |
void | GetAnf (const PGraph &Graph, TIntFltKdV &DistNbrsV, const int &MxDist, const bool &IsDir, const int &NApprox=32) |
template<class PGraph > | |
double | GetAnfEffDiam (const PGraph &Graph, const bool &IsDir, const double &Percentile, const int &NApprox) |
template<class PGraph > | |
double | GetAnfEffDiam (const PGraph &Graph, const int NRuns=1, int NApprox=-1) |
template<class PGraph > | |
void | TestAnf () |
template<class PGraph > | |
PNGraph | GetBfsTree (const PGraph &Graph, const int &StartNId, const bool &FollowOut, const bool &FollowIn) |
Returns a directed Breadth-First-Search tree rooted at StartNId. More... | |
template<class PGraph > | |
int | GetSubTreeSz (const PGraph &Graph, const int &StartNId, const bool &FollowOut, const bool &FollowIn, int &TreeSzX, int &TreeDepthX) |
Returns the BFS tree size (number of nodes) and depth (number of levels) by following in-links (parameter FollowIn = true) and/or out-links (parameter FollowOut = true) of node StartNId. More... | |
template<class PGraph > | |
int | GetNodesAtHop (const PGraph &Graph, const int &StartNId, const int &Hop, TIntV &NIdV, const bool &IsDir=false) |
Finds IDs of all nodes that are at distance Hop from node StartNId. More... | |
template<class PGraph > | |
int | GetNodesAtHops (const PGraph &Graph, const int &StartNId, TIntPrV &HopCntV, const bool &IsDir=false) |
Returns the number of nodes at each hop distance from the starting node StartNId. More... | |
template<class PGraph > | |
int | GetShortPath (const PGraph &Graph, const int &SrcNId, const int &DstNId, const bool &IsDir=false) |
Returns the length of the shortest path from node SrcNId to node DstNId. More... | |
template<class PGraph > | |
int | GetShortPath (const PGraph &Graph, const int &SrcNId, TIntH &NIdToDistH, const bool &IsDir=false, const int &MaxDist=TInt::Mx) |
Returns the length of the shortest path from node SrcNId to all other nodes in the network. More... | |
template<class PGraph > | |
int | GetBfsFullDiam (const PGraph &Graph, const int &NTestNodes, const bool &IsDir=false) |
Returns the (approximation of the) Diameter (maximum shortest path length) of a graph (by performing BFS from NTestNodes random starting nodes). More... | |
template<class PGraph > | |
double | GetBfsEffDiam (const PGraph &Graph, const int &NTestNodes, const bool &IsDir=false) |
Returns the (approximation of the) Effective Diameter (90-th percentile of the distribution of shortest path lengths) of a graph (by performing BFS from NTestNodes random starting nodes). More... | |
template<class PGraph > | |
double | GetBfsEffDiam (const PGraph &Graph, const int &NTestNodes, const bool &IsDir, double &EffDiamX, int &FullDiamX) |
Returns the (approximation of the) Effective Diameter and the Diameter of a graph (by performing BFS from NTestNodes random starting nodes). More... | |
template<class PGraph > | |
double | GetBfsEffDiam (const PGraph &Graph, const int &NTestNodes, const bool &IsDir, double &EffDiamX, int &FullDiamX, double &AvgSPLX) |
Returns the (approximation of the) Effective Diameter, the Diameter and the Average Shortest Path length in a graph (by performing BFS from NTestNodes random starting nodes). More... | |
template<class PGraph > | |
double | GetBfsEffDiamAll (const PGraph &Graph, const int &NTestNodes, const bool &IsDir, double &EffDiamX, int &FullDiamX, double &AvgSPLX) |
Returns the (approximation of the) Effective Diameter, the Diameter and the Average Shortest Path length in a graph (by performing BFS from NTestNodes random starting nodes). More... | |
template<class PGraph > | |
double | GetBfsEffDiam (const PGraph &Graph, const int &NTestNodes, const TIntV &SubGraphNIdV, const bool &IsDir, double &EffDiamX, int &FullDiamX) |
Use the whole graph (all edges) to measure the shortest path lengths but only report the path lengths between nodes in the SubGraphNIdV. More... | |
template<class PGraph > | |
int | GetShortestDistances (const PGraph &Graph, const int &StartNId, const bool &FollowOut, const bool &FollowIn, TIntV &ShortestDists) |
template<class PGraph > | |
int | GetShortestDistancesMP2 (const PGraph &Graph, const int &StartNId, const bool &FollowOut, const bool &FollowIn, TIntV &ShortestDists) |
PNGraph | CascGraphSource (PTable P, const TStr C1, const TStr C2, const TStr C3, const TStr C4, const TInt W) |
Takes as input the column names of the PTable P as C1 , C2 ,C3 and C4 and returns a directed graph of W-adjacent events. For graph generation events are sorted by C1 . More... | |
PNGraph | CascGraphTime (PTable P, const TStr C1, const TStr C2, const TStr C3, const TStr C4, const TInt W) |
Takes as input the column names of the PTable P as C1 , C2 ,C3 and C4 and returns a directed graph of W-adjacent events. For graph generation events are sorted by C3 . More... | |
PNGraph | CascGraph (PTable P, const TStr C1, const TStr C2, const TStr C3, const TStr C4, const TInt W, bool SortParam=true) |
Takes as input the column names of the PTable P as C1 , C2 , C3 and C4 and returns a directed graph of W-adjacent events. By default calls CascGraphSource. Toggle SortParam to use CascGraphTime. More... | |
void | CascFind (PNGraph Graph, PTable P, const TStr C1, const TStr C2, const TStr C3, const TStr C4, TVec< TIntV > &TopCascVV, bool Print=false) |
Takes as input a directed graph and returns all the top cascades in TopCascVV . More... | |
void | CascFindMP (PNGraph Graph, PTable P, const TStr C1, const TStr C2, const TStr C3, const TStr C4, TVec< TIntV > &TopCascVV) |
Parallel implementaion of CascFind takes as input a directed graph and returns all the top cascades in TopCascVV . More... | |
double | GetDegreeCentr (const PUNGraph &Graph, const int &NId) |
void | GetEigenVectorCentr (const PUNGraph &Graph, TIntFltH &NIdEigenH, const double &Eps, const int &MaxIter) |
double | GetGroupDegreeCentr (const PUNGraph &Graph, const PUNGraph &Group) |
double | GetGroupDegreeCentr0 (const PUNGraph &Graph, const TIntH &GroupNodes) |
double | GetGroupDegreeCentr (const PUNGraph &Graph, const TIntH &GroupNodes) |
double | GetGroupFarnessCentr (const PUNGraph &Graph, const TIntH &GroupNodes) |
PUNGraph * | AllGraphsWithNNodes (int n) |
TIntH * | AllCombinationsMN (int m, int n) |
double | GetGroupClosenessCentr (const PUNGraph &Graph, const TIntH &GroupNodes) |
TIntH | MaxCPGreedyBetter (const PUNGraph &Graph, const int k) |
Returns centrality Maximum k group. More... | |
TIntH | MaxCPGreedyBetter1 (const PUNGraph &Graph, const int k) |
Returns centrality Maximum k group. More... | |
TIntH | MaxCPGreedyBetter2 (const PUNGraph &Graph, const int k) |
Returns centrality Maximum k group. More... | |
TIntH | MaxCPGreedyBetter3 (const PUNGraph &Graph, const int k) |
Returns centrality Maximum k group. More... | |
int | GetWeightedPageRank (const PNEANet Graph, TIntFltH &PRankH, const TStr &Attr, const double &C=0.85, const double &Eps=1e-4, const int &MaxIter=100) |
Weighted PageRank (TODO: Use template) More... | |
int | GetWeightedPageRankMP (const PNEANet Graph, TIntFltH &PRankH, const TStr &Attr, const double &C, const double &Eps, const int &MaxIter) |
TIntFltH | EventImportance (const PNGraph &Graph, const int k) |
Event importance. More... | |
TIntFltH | EventImportance1 (const PNGraph &Graph, const int k) |
int | Intersect (TUNGraph::TNodeI Node, TIntH NNodes) |
Intersect. More... | |
int | Intersect (TUNGraph::TNodeI Node, TStr NNodes) |
Intersect. More... | |
int | Intersect (TUNGraph::TNodeI Node, int *NNodes, int NNodes_br) |
Intersect. More... | |
int | Intersect1 (TUNGraph::TNodeI Node, TStr NNodes) |
TIntH | LoadNodeList (TStr InFNmNodes) |
int | findMinimum (TIntV &Frontier, TIntFltH &NIdDistH) |
int | GetWeightedShortestPath (const PNEANet Graph, const int &SrcNId, TIntFltH &NIdDistH, const TFltV &Attr) |
double | GetWeightedFarnessCentr (const PNEANet Graph, const int &NId, const TFltV &Attr, const bool &Normalized, const bool &IsDir) |
double | GetWeightedClosenessCentr (const PNEANet Graph, const int &NId, const TFltV &Attr, const bool &Normalized, const bool &IsDir) |
void | GetWeightedBetweennessCentr (const PNEANet Graph, const TIntV &BtwNIdV, TIntFltH &NodeBtwH, const bool &DoNodeCent, TIntPrFltH &EdgeBtwH, const bool &DoEdgeCent, const TFltV &Attr, const bool &IsDir) |
Computes (approximate) weighted Beetweenness Centrality of all nodes and all edges of the network. More... | |
void | GetWeightedBetweennessCentr (const PNEANet Graph, TIntFltH &NodeBtwH, TIntPrFltH &EdgeBtwH, const TFltV &Attr, const double &NodeFrac, const bool &IsDir) |
void | GetWeightedBetweennessCentr (const PNEANet Graph, TIntFltH &NodeBtwH, const TFltV &Attr, const double &NodeFrac, const bool &IsDir) |
void | GetWeightedBetweennessCentr (const PNEANet Graph, TIntPrFltH &EdgeBtwH, const TFltV &Attr, const double &NodeFrac, const bool &IsDir) |
TTableIterator | GetMapPageRank (const TVec< PNEANet > &GraphSeq, TTableContext *Context, const double &C=0.85, const double &Eps=1e-4, const int &MaxIter=100) |
Gets sequence of PageRank tables from given GraphSeq . More... | |
TTableIterator | GetMapHitsIterator (const TVec< PNEANet > &GraphSeq, TTableContext *Context, const int &MaxIter=20) |
Gets sequence of Hits tables from given GraphSeq . More... | |
template<class PGraph > | |
double | GetFarnessCentr (const PGraph &Graph, const int &NId, const bool &Normalized=true, const bool &IsDir=false) |
template<class PGraph > | |
double | GetFarnessCentrMP (const PGraph &Graph, const int &NId, const bool &Normalized=true, const bool &IsDir=false) |
template<class PGraph > | |
double | GetClosenessCentr (const PGraph &Graph, const int &NId, const bool &Normalized=true, const bool &IsDir=false) |
template<class PGraph > | |
double | GetClosenessCentrMP (const PGraph &Graph, const int &NId, const bool &Normalized=true, const bool &IsDir=false) |
template<class PGraph > | |
int | GetNodeEcc (const PGraph &Graph, const int &NId, const bool &IsDir=false) |
template<class PGraph > | |
void | GetBetweennessCentr (const PGraph &Graph, TIntFltH &NIdBtwH, const double &NodeFrac=1.0, const bool &IsDir=false) |
template<class PGraph > | |
void | GetBetweennessCentr (const PGraph &Graph, TIntPrFltH &EdgeBtwH, const double &NodeFrac=1.0, const bool &IsDir=false) |
template<class PGraph > | |
void | GetBetweennessCentr (const PGraph &Graph, TIntFltH &NIdBtwH, TIntPrFltH &EdgeBtwH, const double &NodeFrac=1.0, const bool &IsDir=false) |
template<class PGraph > | |
void | GetBetweennessCentr (const PGraph &Graph, const TIntV &BtwNIdV, TIntFltH &NodeBtwH, const bool &DoNodeCent, TIntPrFltH &EdgeBtwH, const bool &DoEdgeCent, const bool &IsDir) |
template<class PGraph > | |
void | GetPageRank (const PGraph &Graph, TIntFltH &PRankH, const double &C=0.85, const double &Eps=1e-4, const int &MaxIter=100) |
template<class PGraph > | |
void | GetPageRank_v1 (const PGraph &Graph, TIntFltH &PRankH, const double &C=0.85, const double &Eps=1e-4, const int &MaxIter=100) |
template<class PGraph > | |
void | GetPageRankMP (const PGraph &Graph, TIntFltH &PRankH, const double &C=0.85, const double &Eps=1e-4, const int &MaxIter=100) |
template<class PGraph > | |
void | GetHits (const PGraph &Graph, TIntFltH &NIdHubH, TIntFltH &NIdAuthH, const int &MaxIter=20) |
template<class PGraph > | |
void | GetHitsMP (const PGraph &Graph, TIntFltH &NIdHubH, TIntFltH &NIdAuthH, const int &MaxIter=20) |
template<class PGraph > | |
void | MapPageRank (const TVec< PGraph > &GraphSeq, TVec< PTable > &TableSeq, TTableContext *Context, const double &C, const double &Eps, const int &MaxIter) |
Gets sequence of PageRank tables from given GraphSeq into TableSeq . More... | |
template<class PGraph > | |
void | MapHits (const TVec< PGraph > &GraphSeq, TVec< PTable > &TableSeq, TTableContext *Context, const int &MaxIter) |
Gets sequence of Hits tables from given GraphSeq into TableSeq . More... | |
double | CommunityGirvanNewman (PUNGraph &Graph, TCnComV &CmtyV) |
double | Infomap (PUNGraph &Graph, TCnComV &CmtyV) |
double | InfomapOnline (PUNGraph &Graph, int n1, int n2, TIntFltH &PAlpha, double &SumPAlphaLogPAlpha, TIntFltH &Qi, TIntH &Module, int &Br, TCnComV &CmtyV) |
void | CmtyEvolutionFileBatchV (TStr InFNm, TIntIntVH &sizesContV, TIntIntVH &cContV, TIntIntVH &edges, double alpha, double beta, int CmtyAlg) |
void | CmtyEvolutionFileBatch (TStr InFNm, TIntIntHH &sizesCont, TIntIntHH &cCont, TIntIntVH &edges, double alpha, double beta, int CmtyAlg) |
void | CmtyEvolutionJson (TStr &Json, TIntIntVH &sizesContV, TIntIntVH &cContV, TIntIntVH &edges) |
TStr | CmtyTest (TStr InFNm, int CmtyAlg) |
void | ReebSimplify (PNGraph &Graph, TIntH &t, int e, PNGraph &gFinal, TIntH &tFinal, bool collapse) |
void | ReebRefine (PNGraph &Graph, TIntH &t, int e, PNGraph &gFinal, TIntH &tFinal, bool collapse) |
double | CommunityCNM (const PUNGraph &Graph, TCnComV &CmtyV) |
template<typename PGraph > | |
double | GetModularity (const PGraph &G, const TIntV &NIdV, int GEdges=-1) |
template<typename PGraph > | |
double | GetModularity (const PGraph &G, const TCnComV &CmtyV, int GEdges=-1) |
template<typename PGraph > | |
void | GetEdgesInOut (const PGraph &Graph, const TIntV &NIdV, int &EdgesInX, int &EdgesOutX) |
void | GetBiConSzCnt (const PUNGraph &Graph, TIntPrV &SzCntV) |
Returns a distribution of bi-connected component sizes. More... | |
void | GetBiCon (const PUNGraph &Graph, TCnComV &BiCnComV) |
Returns all bi-connected components of a Graph. More... | |
void | GetArtPoints (const PUNGraph &Graph, TIntV &ArtNIdV) |
Returns articulation points of a Graph. More... | |
void | GetEdgeBridges (const PUNGraph &Graph, TIntPrV &EdgeV) |
Returns bridge edges of a Graph. More... | |
void | Get1CnComSzCnt (const PUNGraph &Graph, TIntPrV &SzCntV) |
Distribution of sizes of 1-components, maximal number of components that can be disconnected from the Graph by removing a single edge. More... | |
void | Get1CnCom (const PUNGraph &Graph, TCnComV &Cn1ComV) |
Returns 1-components: maximal connected components of that can be disconnected from the Graph by removing a single edge. More... | |
PUNGraph | GetMxBiCon (const PUNGraph &Graph, const bool &RenumberNodes=false) |
Returns a graph representing the largest bi-connected component on an undirected Graph. More... | |
template<class PGraph > | |
void | GetNodeWcc (const PGraph &Graph, const int &NId, TIntV &CnCom) |
Returns (via output parameter CnCom) all nodes that are in the same connected component as node NId. More... | |
template<class PGraph > | |
bool | IsConnected (const PGraph &Graph) |
Tests whether the Graph is (weakly) connected. More... | |
template<class PGraph > | |
bool | IsWeaklyConn (const PGraph &Graph) |
Tests whether the Graph is weakly connected. More... | |
template<class PGraph > | |
void | GetWccSzCnt (const PGraph &Graph, TIntPrV &WccSzCnt) |
Returns a distribution of weakly connected component sizes. More... | |
template<class PGraph > | |
void | GetWccs (const PGraph &Graph, TCnComV &CnComV) |
Returns all weakly connected components in a Graph. More... | |
template<class PGraph > | |
void | GetSccSzCnt (const PGraph &Graph, TIntPrV &SccSzCnt) |
Returns a distribution of strongly connected component sizes. More... | |
template<class PGraph > | |
void | GetSccs (const PGraph &Graph, TCnComV &CnComV) |
Returns all strongly connected components in a Graph. More... | |
template<class PGraph > | |
double | GetMxWccSz (const PGraph &Graph) |
Returns the fraction of nodes in the largest weakly connected component of a Graph. More... | |
template<class PGraph > | |
double | GetMxSccSz (const PGraph &Graph) |
Returns the fraction of nodes in the largest strongly connected component of a Graph. More... | |
template<class PGraph > | |
PGraph | GetMxWcc (const PGraph &Graph) |
Returns a graph representing the largest weakly connected component on an input Graph. More... | |
template<class PGraph > | |
PGraph | GetMxScc (const PGraph &Graph) |
Returns a graph representing the largest strongly connected component on an input Graph. More... | |
template<class PGraph > | |
PGraph | GetMxBiCon (const PGraph &Graph) |
Returns a graph representing the largest bi-connected component on an input Graph. More... | |
int | LoadModeNetToNet (PMMNet Graph, const TStr &Name, PTable Table, const TStr &NCol, TStrV &NodeAttrV) |
Loads a mode, with name Name, into the PMMNet from the TTable. NCol specifies the node id column and NodeAttrV the node attributes. More... | |
int | LoadMode (TModeNet &Graph, PTable Table, const TStr &NCol, TStrV &NodeAttrV) |
Loads the nodes specified in column NCol from the TTable with the attributes specified in NodeAttrV. More... | |
int | LoadCrossNetToNet (PMMNet Graph, const TStr &Mode1, const TStr &Mode2, const TStr &CrossName, PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &EdgeAttrV) |
Loads a crossnet from Mode1 to Mode2, with name CrossName, from the provided TTable. EdgeAttrV specifies edge attributes. More... | |
int | LoadCrossNet (TCrossNet &Graph, PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &EdgeAttrV) |
Loads the edges from the TTable and EdgeAttrV specifies columns containing edge attributes. More... | |
template<class PGraph > | |
PGraph | ToGraph (PTable Table, const TStr &SrcCol, const TStr &DstCol, TAttrAggr AggrPolicy) |
Sequentially converts the table into a graph with links from nodes in SrcCol to those in DstCol . More... | |
template<class PGraph > | |
PGraph | ToNetwork (PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &SrcAttrV, TStrV &DstAttrV, TStrV &EdgeAttrV, TAttrAggr AggrPolicy) |
Converts the Table into a graph with edges from SrcCol to DstCol , and attribute vector defined by the arguments. More... | |
template<class PGraph > | |
PGraph | ToNetwork (PTable Table, const TStr &SrcCol, const TStr &DstCol, TAttrAggr AggrPolicy) |
Calls ToNetwork with an empty attribute vector. Convenience wrapper. More... | |
template<class PGraphMP > | |
PGraphMP | ToGraphMP (PTable Table, const TStr &SrcCol, const TStr &DstCol) |
Performs table to graph conversion in parallel using the sort-first algorithm. This is the recommended method to use. More... | |
template<class PGraphMP > | |
PGraphMP | ToGraphMP3 (PTable Table, const TStr &SrcCol, const TStr &DstCol) |
Performs table to graph conversion in parallel. Uses the hash-first method, which is less optimal, use ToGraphMP instead. More... | |
template<class PGraphMP > | |
PGraphMP | ToNetworkMP (PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &SrcAttrV, TStrV &DstAttrV, TStrV &EdgeAttrV, TAttrAggr AggrPolicy) |
Does Table to Network conversion in parallel using the sort-first algorithm. This is the recommended method to use. More... | |
template<class PGraphMP > | |
PGraphMP | ToNetworkMP (PTable Table, const TStr &SrcCol, const TStr &DstCol, TAttrAggr AggrPolicy) |
Calls ToNetworkMP with empty attribute vector. Convenience wrapper. More... | |
template<class PGraphMP > | |
PGraphMP | ToNetworkMP2 (PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &SrcAttrV, TStrV &DstAttrV, TStrV &EdgeAttrV, TAttrAggr AggrPolicy) |
Implements table to network conversion in parallel. Not the recommended algorithm, using ToNetworkMP instead. More... | |
template<class PGraphMP > | |
PGraphMP | ToNetworkMP2 (PTable Table, const TStr &SrcCol, const TStr &DstCol, TAttrAggr AggrPolicy) |
Calls ToNetworkMP2 with an empty attribute vector. Convenience wrapper. More... | |
template<class PGraph > | |
PGraph | ToNetwork (PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &EdgeAttrV, TAttrAggr AggrPolicy) |
Converts table to a network sequentially. Use if network has only edge attributes. More... | |
template<class PGraphMP > | |
PGraphMP | ToNetworkMP (PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &EdgeAttrV, TAttrAggr AggrPolicy) |
Converts table to network in parallel. Use if network has only edge attributes. More... | |
template<class PGraph > | |
PGraph | ToNetwork (PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &EdgeAttrV, PTable NodeTable, const TStr &NodeCol, TStrV &NodeAttrV, TAttrAggr AggrPolicy) |
Converts table to network sequentially. Takes edges from Table and nodes explicitly from NodeCol in NodeTable , with attribute vectors passed as columns in corresponding tables. More... | |
template<class PGraphMP > | |
PGraphMP | ToNetworkMP (PTable Table, const TStr &SrcCol, const TStr &DstCol, TStrV &EdgeAttrV, PTable NodeTable, const TStr &NodeCol, TStrV &NodeAttrV, TAttrAggr AggrPolicy) |
Converts table to network in parallel. Takes edges from Table and nodes explicitly from NodeCol in NodeTable , with attribute vectors passed as columns in corresponding tables. More... | |
int | FastCorePeriphery (PUNGraph &Graph, TIntIntH &out) |
int | FastCorePeripheryGC (PUNGraph &Graph, TIntIntH &out) |
double | BorgattiEverettMeasure (PUNGraph &Graph, TIntIntH &out, double coresize, int type) |
double | PearsonCorrelation (PUNGraph &Graph, TIntIntH &out, int coresize) |
int | IntFlowBiDBFS (const PNEANet &Net, const int &CapIndex, TIntV &Flow, TIntQ &FwdNodeQ, TIntH &PredEdgeH, TIntQ &BwdNodeQ, TIntH &SuccEdgeH, const int &SrcNId, const int &SnkNId) |
int | FindAugV (const PNEANet &Net, const int &CapIndex, TIntV &Flow, TIntQ &FwdNodeQ, TIntH &PredEdgeH, TIntQ &BwdNodeQ, TIntH &SuccEdgeH, TIntV &MidToSrcAugV, TIntV &MidToSnkAugV, const int &SrcNId, const int &SnkNId) |
Returns the amount the flow can be augmented over the paths, 0 if no path can be found. More... | |
int | GetMaxFlowIntEK (PNEANet &Net, const int &SrcNId, const int &SnkNId) |
Returns the maximum integer valued flow in the network Net from source SrcNId to sink SnkNId . More... | |
void | PushToOutNbr (TPRManager &PRM, const int &NId, const int &OutNId, const int &EId) |
Pushes flow from a node NId to a neighbor OutNId over edge EId . More... | |
void | PushToInNbr (TPRManager &PRM, const int &NId, const int &InNId, const int &EId) |
Returns flow from a node NId to a neighbor InNId over edge EId . More... | |
void | Relabel (TPRManager &PRM, const int &NId, const TNEANet::TNodeI &NI) |
Increases the label of a node NId to allow valid pushes to some neighbor. More... | |
int | PushRelabel (TPRManager &PRM, const int &NId, const TNEANet::TNodeI &NI) |
Returns the ID of the neighbor that NId pushes to, -1 if no push was made. More... | |
void | GlobalRelabel (PNEANet &Net, TPRManager &PRM, const int &SrcNId, const int &SnkNId) |
Implements the Global Relabeling heuristic. More... | |
int | GetMaxFlowIntPR (PNEANet &Net, const int &SrcNId, const int &SnkNId) |
Returns the maximum integer valued flow in the network Net from source SrcNId to sink SnkNId . More... | |
TStr | GetFlagStr (const TGraphFlag &GraphFlag) |
Returns a string representation of a flag. More... | |
template<class PGraph > | |
void | PrintInfo (const PGraph &Graph, const TStr &Desc="", const TStr &OutFNm="", const bool &Fast=true) |
Prints basic graph statistics. More... | |
template<class PGraph > | |
int64 | GetTriads (const PGraph &Graph, int64 &ClosedTriadsX, int64 &OpenTriadsX, int SampleNodes) |
Computes the number of Closed and Open triads. More... | |
template<class PGraph > | |
int | GetKCoreNodes (const PGraph &Graph, TIntPrV &CoreIdSzV) |
Returns the number of nodes in each core of order K (where K=0, 1, ...) More... | |
template<class PGraph > | |
int | GetKCoreEdges (const PGraph &Graph, TIntPrV &CoreIdSzV) |
Returns the number of edges in each core of order K (where K=0, 1, ...) More... | |
PBPGraph | GenRndBipart (const int &LeftNodes, const int &RightNodes, const int &Edges, TRnd &Rnd=TInt::Rnd) |
Generates a random bipartite graph. More... | |
PUNGraph | GenRndDegK (const int &Nodes, const int &NodeDeg, const int &NSwitch=100, TRnd &Rnd=TInt::Rnd) |
Generates a random graph where each node has degree exactly NodeDeg. More... | |
PUNGraph | GenRndPowerLaw (const int &Nodes, const double &PowerExp, const bool &ConfModel=true, TRnd &Rnd=TInt::Rnd) |
Generates a random scale-free graph with power-law degree distribution. More... | |
PUNGraph | GenDegSeq (const TIntV &DegSeqV, TRnd &Rnd=TInt::Rnd) |
Generates a random graph with exact degree sequence. More... | |
PUNGraph | GenConfModel (const TIntV &DegSeqV, TRnd &Rnd=TInt::Rnd) |
Generates a random undirect graph with a given degree sequence. More... | |
PUNGraph | GenRewire (const PUNGraph &Graph, const int &NSwitch=100, TRnd &Rnd=TInt::Rnd) |
Rewire a random undirected graph. Keeps node degrees the same, but randomly rewires the edges. More... | |
PNGraph | GenRewire (const PNGraph &Graph, const int &NSwitch=100, TRnd &Rnd=TInt::Rnd) |
Rewire a random directed graph. Keeps node degrees the same, but randomly rewires the edges. More... | |
PBPGraph | GenRewire (const PBPGraph &Graph, const int &NSwitch=100, TRnd &Rnd=TInt::Rnd) |
Rewire a random bipartite graph. Keeps node degrees the same, but randomly rewires the edges. More... | |
PUNGraph | GenPrefAttach (const int &Nodes, const int &NodeOutDeg, TRnd &Rnd=TInt::Rnd) |
Generates a power-law degree distribution using Barabasi-Albert model of scale-free graphs. More... | |
PUNGraph | GenConfModel (const PUNGraph &G) |
Generate a random graph using (approximately) the same node degrees as in G using the configuration model. More... | |
PUNGraph | GenGeoPrefAttach (const int &Nodes, const int &OutDeg, const double &Beta, TRnd &Rnd=TInt::Rnd) |
Generates a random scale-free graph using the Geometric Preferential model. More... | |
PUNGraph | GenSmallWorld (const int &Nodes, const int &NodeOutDeg, const double &RewireProb, TRnd &Rnd=TInt::Rnd) |
Generates a randomly small-world graph using the Watts-Strogatz model. More... | |
PNGraph | GenForestFire (const int &Nodes, const double &FwdProb, const double &BckProb) |
Generates a random Forest Fire, directed graph with given probabilities. More... | |
PNGraph | GenCopyModel (const int &Nodes, const double &Beta, TRnd &Rnd=TInt::Rnd) |
Generates a random scale-free network using the Copying Model. More... | |
PNGraph | GenRMat (const int &Nodes, const int &Edges, const double &A, const double &B, const double &C, TRnd &Rnd=TInt::Rnd) |
Generates a R-MAT graph using recursive descent into a 2x2 matrix [A,B; C, 1-(A+B+C)]. More... | |
PNGraph | GenRMatEpinions () |
Generates a R-Mat graph, with a synthetic copy of the Epinions social network. More... | |
template<class PGraph > | |
PGraph | GenGrid (const int &Rows, const int &Cols, const bool &IsDir=true) |
Generates a 2D-grid graph of Rows rows and Cols columns. More... | |
template<class PGraph > | |
PGraph | GenStar (const int &Nodes, const bool &IsDir=true) |
Generates a graph with star topology. Node id 0 is in the center and then links to all other nodes. More... | |
template<class PGraph > | |
PGraph | GenCircle (const int &Nodes, const int &NodeOutDeg=1, const bool &IsDir=true) |
Generates a circle graph where every node creates out-links to NodeOutDeg forward nodes. More... | |
template<class PGraph > | |
PGraph | GenFull (const int &Nodes) |
Generates a complete graph on Nodes nodes. Graph has no self-loops. More... | |
template<class PGraph > | |
PGraph | GenTree (const int &Fanout, const int &Levels, const bool &IsDir=true, const bool &ChildPointsToParent=true) |
Generates a tree graph of Levels levels with every parent having Fanout children. More... | |
template<class PGraph > | |
PGraph | GenBaraHierar (const int &Levels, const bool &IsDir=true) |
Generates a Ravasz-Barabasi deterministic scale-free graph. More... | |
template<class PGraph > | |
PGraph | GenRndGnm (const int &Nodes, const int &Edges, const bool &IsDir=true, TRnd &Rnd=TInt::Rnd) |
Generates an Erdos-Renyi random graph. More... | |
int | ReadEdgeSchemaFromFile (TSsParser &Ss, const char &Separator, int &SrcColId, int &DstColId, TStrIntH &IntAttrEVals, TStrIntH &FltAttrEVals, TStrIntH &StrAttrEVals) |
bool | ReadEdgesFromFile (TSsParser &Ss, const char &Separator, PNEANet &Graph, int &SrcColId, int &DstColId, TStrIntH &IntAttrEVals, TStrIntH &FltAttrEVals, TStrIntH &StrAttrEVals) |
int | ReadNodeSchemaFromFile (TSsParser &Ss, const char &Separator, int &NId, TStrIntH &IntAttrNVals, TStrIntH &FltAttrNVals, TStrIntH &StrAttrNVals) |
bool | ReadNodesFromFile (TSsParser &Ss, const char &Separator, PNEANet &Graph, int &NColId, TStrIntH &IntAttrNVals, TStrIntH &FltAttrNVals, TStrIntH &StrAttrNVals) |
PNEANet | LoadEdgeListNet (const TStr &InFNm, const char &Separator) |
Loads a network from the text file InFNm with 1 node/edge per line ('Separator' separated columns, integer node id(s) + node/edge attributes). More... | |
void | WriteNodeSchemaToFile (FILE *F, TStrV &IntAttrNNames, TStrV &FltAttrNNames, TStrV &StrAttrNNames) |
void | WriteNodesToFile (FILE *F, const PNEANet &Graph, TStrV &IntAttrNNames, TStrV &FltAttrNNames, TStrV &StrAttrNNames) |
void | WriteEdgeSchemaToFile (FILE *F, TStrV &IntAttrENames, TStrV &FltAttrENames, TStrV &StrAttrENames) |
void | WriteEdgesToFile (FILE *F, const PNEANet &Graph, TStrV &IntAttrENames, TStrV &FltAttrENames, TStrV &StrAttrENames) |
void | SaveEdgeListNet (const PNEANet &Graph, const TStr &OutFNm, const TStr &Desc) |
Saves a network into a text file. Each line encodes either an edge or a node, along with its attributes. More... | |
PNGraph | LoadDyNet (const TStr &FNm) |
For more info see ORA Network Analysis Data (http://www.casos.cs.cmu.edu/computational_tools/data2.php) More... | |
TVec< PNGraph > | LoadDyNetGraphV (const TStr &FNm) |
For more info see ORA Network Analysis Data (http://www.casos.cs.cmu.edu/computational_tools/data2.php) More... | |
template<class PGraph > | |
PGraph | LoadEdgeList (const TStr &InFNm, const int &SrcColId=0, const int &DstColId=1) |
Loads a (directed, undirected or multi) graph from a text file InFNm with 1 edge per line (whitespace separated columns, integer node ids). More... | |
template<class PGraph > | |
PGraph | LoadEdgeList (const TStr &InFNm, const int &SrcColId, const int &DstColId, const char &Separator) |
Loads a (directed, undirected or multi) graph from a text file InFNm with 1 edge per line ('Separator' separated columns, integer node ids). More... | |
template<class PGraph > | |
PGraph | LoadEdgeListStr (const TStr &InFNm, const int &SrcColId=0, const int &DstColId=1) |
Loads a (directed, undirected or multi) graph from a text file InFNm with 1 edge per line (whitespace separated columns, arbitrary string node ids). More... | |
template<class PGraph > | |
PGraph | LoadEdgeListStr (const TStr &InFNm, const int &SrcColId, const int &DstColId, TStrHash< TInt > &StrToNIdH) |
Loads a (directed, undirected or multi) graph from a text file InFNm with 1 edge per line (whitespace separated columns, arbitrary string node ids). More... | |
template<class PGraph > | |
PGraph | LoadConnList (const TStr &InFNm) |
Loads a (directed, undirected or multi) graph from a text file InFNm with 1 node and all its edges in a single line. More... | |
template<class PGraph > | |
PGraph | LoadConnListStr (const TStr &InFNm, TStrHash< TInt > &StrToNIdH) |
Loads a (directed, undirected or multi) graph from a text file InFNm with 1 node and all its edges in a single line. More... | |
template<class PGraph > | |
PGraph | LoadPajek (const TStr &InFNm) |
Loads a (directed, undirected or multi) graph from Pajek .PAJ format file. More... | |
template<class PGraph > | |
void | SaveEdgeList (const PGraph &Graph, const TStr &OutFNm, const TStr &Desc=TStr()) |
Saves a graph into a text file. Each line contains two columns and encodes a single edge: <source node="" id>=""><tab><destination node="" id>=""> More... | |
template<class PGraph > | |
void | SavePajek (const PGraph &Graph, const TStr &OutFNm) |
Saves a graph in a Pajek .NET format. More... | |
template<class PGraph > | |
void | SavePajek (const PGraph &Graph, const TStr &OutFNm, const TIntStrH &NIdColorH) |
Saves a graph in a Pajek .NET format. More... | |
template<class PGraph > | |
void | SavePajek (const PGraph &Graph, const TStr &OutFNm, const TIntStrH &NIdColorH, const TIntStrH &NIdLabelH) |
Saves a graph in a Pajek .NET format. More... | |
template<class PGraph > | |
void | SavePajek (const PGraph &Graph, const TStr &OutFNm, const TIntStrH &NIdColorH, const TIntStrH &NIdLabelH, const TIntStrH &EIdColorH) |
Saves a graph in a Pajek .NET format. More... | |
template<class PGraph > | |
void | SaveMatlabSparseMtx (const PGraph &Graph, const TStr &OutFNm) |
Saves a graph in a MATLAB sparse matrix format. More... | |
template<class PGraph > | |
void | SaveGViz (const PGraph &Graph, const TStr &OutFNm, const TStr &Desc=TStr(), const bool &NodeLabels=false, const TIntStrH &NIdColorH=TIntStrH()) |
Save a graph in GraphVizp .DOT format. More... | |
template<class PGraph > | |
void | SaveGViz (const PGraph &Graph, const TStr &OutFNm, const TStr &Desc, const TIntStrH &NIdLabelH) |
Save a graph in GraphVizp .DOT format. More... | |
void | SetAllInvertSign (TFltV &ValV, const double &Val) |
bool | IsAllValVNeg (TFltV &ValV, const bool &InvertSign) |
void | GetSngVals (const PNGraph &Graph, const int &SngVals, TFltV &SngValV) |
Computes largest SngVals singular values of the adjacency matrix representing a directed Graph. More... | |
void | GetSngVec (const PNGraph &Graph, TFltV &LeftSV, TFltV &RightSV) |
Computes the leading left and right singular vector of the adjacency matrix representing a directed Graph. More... | |
void | GetSngVec (const PNGraph &Graph, const int &SngVecs, TFltV &SngValV, TFltVFltV &LeftSV, TFltVFltV &RightSV) |
void | GetEigVals (const PUNGraph &Graph, const int &EigVals, TFltV &EigValV) |
Computes top EigVals eigenvalues of the adjacency matrix representing a given undirected Graph. More... | |
void | GetEigVec (const PUNGraph &Graph, TFltV &EigVecV) |
Computes the leading eigenvector of the adjacency matrix representing a given undirected Graph. More... | |
void | GetEigVec (const PUNGraph &Graph, const int &EigVecs, TFltV &EigValV, TFltVFltV &EigVecV) |
Computes top EigVecs eigenvalues and eigenvectors of the adjacency matrix representing a given undirected Graph. More... | |
void | GetInvParticipRat (const PUNGraph &Graph, int MaxEigVecs, int TimeLimit, TFltPrV &EigValIprV) |
template<class PGraph > | |
void | DrawGViz (const PGraph &Graph, const TGVizLayout &Layout, const TStr &PltFNm, const TStr &Desc=TStr(), const bool &NodeLabels=false, const TIntStrH &NIdColorH=TIntStrH()) |
Draws a given Graph using a selected GraphViz Layout engine with nodes colored. More... | |
template<class PGraph > | |
void | DrawGViz (const PGraph &Graph, const TGVizLayout &Layout, const TStr &PltFNm, const TStr &Desc, const TIntStrH &NodeLabelH) |
Draws a given Graph using a selected GraphViz Layout engine with nodes labeled. More... | |
template<class PGraph > | |
PGraph | GetKCore (const PGraph &Graph, const int &K) |
void | TIntVToNumpy (TIntV &IntV, int *IntNumpyVecOut, int n) |
Converts TIntV to Numpy array. More... | |
void | TFltVToNumpy (TFltV &FltV, float *FltNumpyVecOut, int n) |
Converts TFltV to Numpy array. More... | |
void | NumpyToTIntV (TIntV &IntV, int *IntNumpyVecIn, int n) |
Converts NumpyArray to TIntV. More... | |
void | NumpyToTFltV (TFltV &FltV, float *FltNumpyVecIn, int n) |
Converts NumpyArray to TFltV. More... | |
template<class PGraph > | |
int | SamplePersonalizedPageRank (const PGraph &Graph, double JumpProb, const TIntV &StartNIdV, TRnd &Rnd) |
template<class PGraph > | |
double | GetPersonalizedPageRankBidirectional (const PGraph &Graph, double JumpProb, const TIntV &StartNIdV, int TargetNId, double MinProbability=-1.0, double RelativeError=0.1, bool provableRelativeError=false, bool PrintTimeForTuning=false) |
template<class PGraph > | |
double | GetRndWalkRestartBidirectional (const PGraph &Graph, double JumpProb, int StartNId, int TargetNId, double minProbability=-1.0, double relativeError=0.1, bool proveRelativeError=false, bool PrintTimeForTuning=false) |
void | PlotEigValRank (const PUNGraph &Graph, const int &EigVals, const TStr &FNmPref, TStr DescStr=TStr()) |
Plots the eigen-value rank distribution of the Graph adjacency matrix. Plots first EigVals eigenvalues. More... | |
void | PlotEigValDistr (const PUNGraph &Graph, const int &EigVals, const TStr &FNmPref, TStr DescStr=TStr()) |
Plots the distribution of components of the leading eigen-vector of the Graph adjacency matrix. Plots first EigVals values. More... | |
void | PlotInvParticipRat (const PUNGraph &Graph, const int &MaxEigVecs, const int &TimeLimit, const TStr &FNmPref, TStr DescStr) |
void | PlotSngValRank (const PNGraph &Graph, const int &SngVals, const TStr &FNmPref, TStr DescStr=TStr()) |
Plots the rank distribution of singular values of the Graph adjacency matrix. Plots first SngVals values. More... | |
void | PlotSngValDistr (const PNGraph &Graph, const int &SngVals, const TStr &FNmPref, TStr DescStr=TStr()) |
Plots the rank distribution of singular values of the Graph adjacency matrix. Plots first SngVals values. More... | |
void | PlotSngVec (const PNGraph &Graph, const TStr &FNmPref, TStr DescStr=TStr()) |
Plots the distribution of the values of the leading left singular vector of the Graph adjacency matrix. Plots first SngVals values. More... | |
template<class PGraph > | |
void | PlotInDegDistr (const PGraph &Graph, const TStr &FNmPref, TStr DescStr=TStr(), const bool &PlotCCdf=false, const bool &PowerFit=false) |
template<class PGraph > | |
void | PlotOutDegDistr (const PGraph &Graph, const TStr &FNmPref, TStr DescStr=TStr(), const bool &PlotCCdf=false, const bool &PowerFit=false) |
template<class PGraph > | |
void | PlotWccDistr (const PGraph &Graph, const TStr &FNmPref, TStr DescStr=TStr()) |
Plots the distribution of sizes of weakly connected components of a Graph. More... | |
template<class PGraph > | |
void | PlotSccDistr (const PGraph &Graph, const TStr &FNmPref, TStr DescStr=TStr()) |
Plots the distribution of sizes of strongly connected components of a Graph. More... | |
template<class PGraph > | |
void | PlotClustCf (const PGraph &Graph, const TStr &FNmPref, TStr DescStr=TStr()) |
Plots the distribution of clustering coefficient of a Graph. More... | |
template<class PGraph > | |
void | PlotHops (const PGraph &Graph, const TStr &FNmPref, TStr DescStr=TStr(), const bool &IsDir=false, const int &NApprox=32) |
template<class PGraph > | |
void | PlotShortPathDistr (const PGraph &Graph, const TStr &FNmPref, TStr DescStr=TStr(), int TestNodes=TInt::Mx) |
Plots the distribution of the shortest path lengths of a Graph. Implementation is based on BFS. More... | |
template<class PGraph > | |
void | PlotKCoreNodes (const PGraph &Graph, const TStr &FNmPref, TStr DescStr=TStr()) |
Plots the k-Core node-size distribution: Core k vs. number of nodes in k-core. More... | |
template<class PGraph > | |
void | PlotKCoreEdges (const PGraph &Graph, const TStr &FNmPref, TStr DescStr=TStr()) |
Plots the k-Core edge-size distribution: Core k vs. number of edges in k-core. More... | |
PUNGraph | GetSubGraph (const PUNGraph &Graph, const TIntV &NIdV, const bool &RenumberNodes=false) |
Returns an induced subgraph of an undirected graph Graph with NIdV nodes with an optional node renumbering. More... | |
PNGraph | GetSubGraph (const PNGraph &Graph, const TIntV &NIdV, const bool &RenumberNodes) |
PUNGraph | GetEgonet (const PUNGraph &Graph, const int CtrNId, int &ArndEdgesX) |
Returns the egonet of node CtrNId as center in undirected graph Graph. And returns number of edges around the egonet. More... | |
PNGraph | GetEgonet (const PNGraph &Graph, const int CtrNId, int &InEgoEdgesX, int &OutEgoEdgesX) |
Returns the egonet of node CtrNId as center in directed graph Graph. And returns number of edges go in and out the egonet. More... | |
void | AddNodeWithAttributes (const PNEANet &Graph1, PNEANet &Graph2, const int NId) |
void | AddEdgeWithAttributes (const PNEANet &Graph1, PNEANet &Graph2, const int EId) |
void | AddEdgeWithAttributes (const PNEANet &Graph1, PNEANet &Graph2, const int NId, const int NbrId) |
PNEANet | GetEgonetAttr (const PNEANet &Graph, const int CtrNId, const int Radius) |
Returns the complete egonet of at given radius and copies node and edge attributes. More... | |
PNEANet | GetInEgonetAttr (const PNEANet &Graph, const int CtrNId, const int Radius) |
Returns the in-egonet of at given radius and copies node and edge attributes. More... | |
PNEANet | GetOutEgonetAttr (const PNEANet &Graph, const int CtrNId, const int Radius) |
Returns the out-egonet of at given radius and copies node and edge attributes. More... | |
PNEANet | GetInEgonetSubAttr (const PNEANet &Graph, const int CtrNId, const int Radius, const int MaxNum, const float percent) |
Returns the randomly sampled egonet with nodes sampled based on percentage or raw number, copying attributes. More... | |
PNEANet | GetGraphUnionAttr (PNEANet &DstGraph, const PNEANet &SrcGraph) |
template<class PGraph > | |
PGraph | GetSubGraph (const PGraph &Graph, const TIntV &NIdV) |
Returns an induced subgraph of graph Graph with NIdV nodes. More... | |
template<class PGraph > | |
PGraph | GetSubGraphRenumber (const PGraph &Graph, const TIntV &NIdV) |
Returns an induced subgraph of graph Graph with NIdV nodes with an node renumbering. More... | |
template<class PGraph > | |
PGraph | GetESubGraph (const PGraph &Graph, const TIntV &EIdV) |
Returns a subgraph of graph Graph with EIdV edges. More... | |
template<class PGraph > | |
PGraph | GetESubGraph (const PGraph &Graph, const TIntPrV &EdgeV) |
template<class PGraph , class TEdgeDat > | |
PGraph | GetEDatSubGraph (const PGraph &Graph, const TEdgeDat &EDat, const int &Cmp) |
Returns a subgraph of graph Graph with edges where edge data matches the parameters. More... | |
template<class PGraph , class TEdgeDat > | |
PGraph | GetEDatSubGraph (const PGraph &Graph, const TIntV &NIdV, const TEdgeDat &EDat, const int &Cmp) |
Returns a subgraph of graph Graph with NIdV nodes and edges where edge data matches the parameters. More... | |
template<class POutGraph , class PInGraph > | |
POutGraph | ConvertGraph (const PInGraph &InGraph, const bool &RenumberNodes=false) |
Performs conversion of graph InGraph with an optional node renumbering. More... | |
template<class POutGraph , class PInGraph > | |
POutGraph | ConvertSubGraph (const PInGraph &InGraph, const TIntV &NIdV, const bool &RenumberNodes=false) |
Returns an induced subgraph of graph InGraph with NIdV nodes with an optional node renumbering. More... | |
template<class POutGraph , class PInGraph > | |
POutGraph | ConvertESubGraph (const PInGraph &InGraph, const TIntV &EIdV, const bool &RenumberNodes=false) |
Returns a subgraph of graph InGraph with EIdV edges with an optional node renumbering. More... | |
template<class PGraph > | |
PGraph | GetRndSubGraph (const PGraph &Graph, const int &NNodes) |
Returns an induced random subgraph of graph Graph with NNodes nodes. More... | |
template<class PGraph > | |
PGraph | GetRndESubGraph (const PGraph &Graph, const int &NEdges) |
Returns a random subgraph of graph Graph with NEdges edges. More... | |
template<class PGraph > | |
PGraph | GetEgonetHop (const PGraph &Graph, const int CtrNId, const int Radius) |
Returns the egonet of node CtrNId as center for a Graph for a given radius. More... | |
template<class PGraph > | |
PGraph | GetInEgonetHop (const PGraph &Graph, const int CtrNId, const int Radius) |
Returns the in-egonet of node CtrNId as center in directed graph Graph for a given radius. More... | |
template<class PGraph > | |
PGraph | GetOutEgonetHop (const PGraph &Graph, const int CtrNId, const int Radius) |
Returns the out-egonet of node CtrNId as center in directed graph Graph for a given radius. More... | |
template<class PGraph > | |
PGraph | GetInEgonetSub (const PGraph &Graph, const int CtrNId, const int Radius, const int MaxNum=2, const float percent=-1.0) |
Returns the randomly sampled in-egonet with nodes sampled based on percentage, if percent != -1.0, or MaxNum nodes otherwise. More... | |
template<class PGraph > | |
PGraph | GetGraphUnion (PGraph &DstGraph, const PGraph &SrcGraph) |
int | GetCommon (TIntV &A, TIntV &B) |
Returns the number of common elements in two sorted TInt vectors. More... | |
template<class PGraph > | |
double | GetClustCf (const PGraph &Graph, int SampleNodes=-1) |
Computes the average clustering coefficient as defined in Watts and Strogatz, Collective dynamics of 'small-world' networks. More... | |
template<class PGraph > | |
double | GetClustCf (const PGraph &Graph, TFltPrV &DegToCCfV, int SampleNodes=-1) |
Computes the distribution of average clustering coefficient. More... | |
template<class PGraph > | |
double | GetClustCf (const PGraph &Graph, TFltPrV &DegToCCfV, int64 &ClosedTriads, int64 &OpenTriads, int SampleNodes=-1) |
Computes the distribution of average clustering coefficient as well as the number of open and closed triads in the graph. More... | |
template<class PGraph > | |
double | GetClustCfAll (const PGraph &Graph, TFltPrV &DegToCCfV, int64 &ClosedTriadsX, int64 &OpenTriadsX, int SampleNodes=-1) |
Computes the distribution of average clustering coefficient as well as the number of open and closed triads in the graph. More... | |
template<class PGraph > | |
double | GetNodeClustCf (const PGraph &Graph, const int &NId) |
Returns clustering coefficient of a particular node. More... | |
template<class PGraph > | |
void | GetNodeClustCf (const PGraph &Graph, TIntFltH &NIdCCfH) |
Computes clustering coefficient of each node of the Graph. More... | |
template<class PGraph > | |
int64 | GetTriads (const PGraph &Graph, int SampleNodes=-1) |
Returns the number of triangles in a graph. More... | |
template<class PGraph > | |
int64 | GetTriadsAll (const PGraph &Graph, int64 &ClosedTriadsX, int64 &OpenTriadsX, int SampleNodes=-1) |
Computes the number of Closed and Open triads. More... | |
template<class PGraph > | |
void | GetTriads (const PGraph &Graph, TIntTrV &NIdCOTriadV, int SampleNodes=-1) |
Computes the number of open and close triads for every node of the network. More... | |
template<class PGraph > | |
int | GetTriadEdges (const PGraph &Graph, int SampleEdges=-1) |
Counts the number of edges that participate in at least one triad. More... | |
template<class PGraph > | |
int | GetNodeTriads (const PGraph &Graph, const int &NId) |
Returns the number of undirected triads a node NId participates in. More... | |
template<class PGraph > | |
int | GetNodeTriads (const PGraph &Graph, const int &NId, int &ClosedNTriadsX, int &OpenNTriadsX) |
Returns number of Open and Closed triads a node NId participates in. More... | |
template<class PGraph > | |
int | GetNodeTriadsAll (const PGraph &Graph, const int &NId, int &ClosedNTriadsX, int &OpenNTriadsX) |
Returns number of Open and Closed triads a node NId participates in. More... | |
template<class PGraph > | |
int | GetNodeTriads (const PGraph &Graph, const int &NId, const TIntSet &GroupSet, int &InGroupEdgesX, int &InOutGroupEdgesX, int &OutGroupEdgesX) |
Returns the number of triads between a node NId and a subset of its neighbors GroupSet . More... | |
template<class PGraph > | |
void | GetTriadParticip (const PGraph &Graph, TIntPrV &TriadCntV) |
Triangle Participation Ratio: For each node counts how many triangles it participates in and then returns a set of pairs (number of triangles, number of such nodes). More... | |
template<class PGraph > | |
int | GetCmnNbrs (const PGraph &Graph, const int &NId1, const int &NId2) |
Returns a number of shared neighbors between a pair of nodes NId1 and NId2. More... | |
template<class PGraph > | |
int | GetCmnNbrs (const PGraph &Graph, const int &NId1, const int &NId2, TIntV &NbrV) |
Returns the shared neighbors between a pair of nodes NId1 and NId2. More... | |
template<class PGraph > | |
int | GetLen2Paths (const PGraph &Graph, const int &NId1, const int &NId2) |
Returns the number of length 2 directed paths between a pair of nodes NId1, NId2 (NId1 –> U –> NId2). More... | |
template<class PGraph > | |
int | GetLen2Paths (const PGraph &Graph, const int &NId1, const int &NId2, TIntV &NbrV) |
Returns the 2 directed paths between a pair of nodes NId1, NId2 (NId1 –> U –> NId2). More... | |
template<class PGraph > | |
int64 | GetTriangleCnt (const PGraph &Graph) |
Returns the number of triangles in graph Graph . More... | |
template<class PGraph > | |
void | MergeNbrs (TIntV &NeighbourV, const typename PGraph::TObj::TNodeI &NI) |
Merges neighbors by removing duplicates and produces one sorted vector of neighbors. More... | |
template<class PGraph > | |
void | GetUniqueNbrV (const PGraph &Graph, const int &NId, TIntV &NbrV) |
Returns sorted vector NbrV containing unique in or out neighbors of node NId in graph Graph . More... | |
template<class PGraph > | |
void | GetTriads_v0 (const PGraph &Graph, TIntTrV &NIdCOTriadV, int SampleNodes) |
template<> | |
int | GetCmnNbrs< PUNGraph > (const PUNGraph &Graph, const int &NId1, const int &NId2, TIntV &NbrV) |
Variables | |
const TStr | CapAttrName = "capacity" |
const TStr | EDGES_START = ("#EDGES") |
const TStr | NODES_START = ("#NODES") |
const TStr | END_SENTINEL = ("#END") |
const TStr | SRC_ID_NAME = ("SrcNId") |
const TStr | DST_ID_NAME = ("DstNId") |
const TStr | NID_NAME = ("NId") |
const TStr | INT_TYPE_PREFIX = ("Int") |
const TStr | FLT_TYPE_PREFIX = ("Flt") |
const TStr | STR_TYPE_PREFIX = ("Str") |
const TStr | NULL_VAL = ("__null__") |
Main namespace for all the Snap global entities.
The name of the friend is not found by simple name lookup until a matching declaration is provided in that namespace scope (either before or after the class declaration granting friendship).
Definition at line 179 of file subgraph.cpp.
References TVec< TVal, TSizeTy >::Len().
Referenced by GetEgonetAttr(), GetGraphUnionAttr(), GetInEgonetAttr(), GetInEgonetSubAttr(), and GetOutEgonetAttr().
void TSnap::AddEdgeWithAttributes | ( | const PNEANet & | Graph1, |
PNEANet & | Graph2, | ||
const int | NId, | ||
const int | NbrId | ||
) |
Definition at line 217 of file subgraph.cpp.
References TVec< TVal, TSizeTy >::Len().
Definition at line 143 of file subgraph.cpp.
References TVec< TVal, TSizeTy >::Len().
Referenced by GetEgonetAttr(), GetGraphUnionAttr(), GetInEgonetAttr(), GetInEgonetSubAttr(), and GetOutEgonetAttr().
void TSnap::AddSelfEdges | ( | const PGraph & | Graph | ) |
Adds a self-edge to every node in the graph.
Definition at line 369 of file alg.h.
References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Len().
PUNGraph* TSnap::AllGraphsWithNNodes | ( | int | n | ) |
Definition at line 138 of file centr.cpp.
References TUNGraph::AddEdge(), and TUNGraph::AddNode().
double TSnap::BorgattiEverettMeasure | ( | PUNGraph & | Graph, |
TIntIntH & | out, | ||
double | coresize, | ||
int | type | ||
) |
Definition at line 186 of file coreper.cpp.
References TUNGraph::BegEI(), TUNGraph::EndEI(), and THash< TKey, TDat, THashFunc >::GetDat().
void TSnap::CascFind | ( | PNGraph | Graph, |
PTable | P, | ||
const TStr | C1, | ||
const TStr | C2, | ||
const TStr | C3, | ||
const TStr | C4, | ||
TVec< TIntV > & | TopCascVV, | ||
bool | |||
) |
Takes as input a directed graph and returns all the top cascades in TopCascVV
.
Definition at line 135 of file casc.cpp.
References TVec< TVal, TSizeTy >::Add(), THashSet< TKey, THashFunc >::AddKey(), TVec< TVal, TSizeTy >::BegI(), TSnapQueue< TVal >::Empty(), TVec< TVal, TSizeTy >::EndI(), TNGraph::TNodeI::GetOutDeg(), TNGraph::TNodeI::GetOutNId(), TVec< TVal, TSizeTy >::GetVal(), THashSet< TKey, THashFunc >::IsKey(), TVec< TVal, TSizeTy >::Len(), THashSet< TKey, THashFunc >::Len(), TSnapQueue< TVal >::Pop(), TSnapQueue< TVal >::Push(), TVec< TVal, TSizeTy >::Sort(), TSnapQueue< TVal >::Top(), and TInt::Val.
void TSnap::CascFindMP | ( | PNGraph | Graph, |
PTable | P, | ||
const TStr | C1, | ||
const TStr | C2, | ||
const TStr | C3, | ||
const TStr | C4, | ||
TVec< TIntV > & | TopCascVV | ||
) |
Parallel implementaion of CascFind takes as input a directed graph and returns all the top cascades in TopCascVV
.
Definition at line 200 of file casc.cpp.
References TVec< TVal, TSizeTy >::Add(), THashSet< TKey, THashFunc >::AddKey(), TVec< TVal, TSizeTy >::BegI(), TSnapQueue< TVal >::Empty(), TVec< TVal, TSizeTy >::EndI(), TNGraph::TNodeI::GetOutDeg(), TNGraph::TNodeI::GetOutNId(), TVec< TVal, TSizeTy >::GetVal(), THashSet< TKey, THashFunc >::IsKey(), TVec< TVal, TSizeTy >::Len(), TSnapQueue< TVal >::Pop(), TSnapQueue< TVal >::Push(), TVec< TVal, TSizeTy >::Sort(), TSnapQueue< TVal >::Top(), and TInt::Val.
PNGraph TSnap::CascGraph | ( | PTable | P, |
const TStr | C1, | ||
const TStr | C2, | ||
const TStr | C3, | ||
const TStr | C4, | ||
const TInt | W, | ||
bool | SortParam | ||
) |
Takes as input the column names of the PTable P
as C1
, C2
, C3
and C4
and returns a directed graph of W-adjacent
events. By default calls CascGraphSource. Toggle SortParam to use CascGraphTime.
Definition at line 126 of file casc.cpp.
References CascGraphSource(), and CascGraphTime().
PNGraph TSnap::CascGraphSource | ( | PTable | P, |
const TStr | C1, | ||
const TStr | C2, | ||
const TStr | C3, | ||
const TStr | C4, | ||
const TInt | W | ||
) |
Takes as input the column names of the PTable P
as C1
, C2
,C3
and C4
and returns a directed graph of W-adjacent
events. For graph generation events are sorted by C1
.
Definition at line 3 of file casc.cpp.
References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::GetVal(), TVec< TVal, TSizeTy >::Len(), TNGraph::New(), and TInt::Val.
Referenced by CascGraph().
PNGraph TSnap::CascGraphTime | ( | PTable | P, |
const TStr | C1, | ||
const TStr | C2, | ||
const TStr | C3, | ||
const TStr | C4, | ||
const TInt | W | ||
) |
Takes as input the column names of the PTable P
as C1
, C2
,C3
and C4
and returns a directed graph of W-adjacent
events. For graph generation events are sorted by C3
.
Definition at line 59 of file casc.cpp.
References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::GetVal(), TVec< TVal, TSizeTy >::Len(), TNGraph::New(), and TInt::Val.
Referenced by CascGraph().
void TSnap::CmtyEvolutionFileBatch | ( | TStr | InFNm, |
TIntIntHH & | sizesCont, | ||
TIntIntHH & | cCont, | ||
TIntIntVH & | edges, | ||
double | alpha, | ||
double | beta, | ||
int | CmtyAlg | ||
) |
Definition at line 490 of file cmty.cpp.
References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), TUNGraph::AddEdge(), TUNGraph::AddNode(), THash< TKey, TDat, THashFunc >::BegI(), THash< TKey, TDat, THashFunc >::Clr(), DelSelfEdges(), edge, TSsParser::Eof(), Fail, TStr::GetCh(), THash< TKey, TDat, THashFunc >::GetDat(), TVec< TVal, TSizeTy >::GetDat(), TSsParser::GetInt(), THash< TKey, TDat, THashFunc >::GetKey(), TSsParser::GetLnStr(), TUNGraph::GetNodes(), THashKeyDatI< TKey, TDat >::IsEnd(), THash< TKey, TDat, THashFunc >::IsKey(), TUNGraph::IsNode(), THash< TKey, TDat, THashFunc >::Len(), TVec< TVal, TSizeTy >::Len(), TUNGraph::New(), TSsParser::Next(), and ssfWhiteSep.
Referenced by CmtyEvolutionFileBatchV().
void TSnap::CmtyEvolutionFileBatchV | ( | TStr | InFNm, |
TIntIntVH & | sizesContV, | ||
TIntIntVH & | cContV, | ||
TIntIntVH & | edges, | ||
double | alpha, | ||
double | beta, | ||
int | CmtyAlg | ||
) |
Definition at line 441 of file cmty.cpp.
References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), CmtyEvolutionFileBatch(), THash< TKey, TDat, THashFunc >::GetDat(), TVec< TVal, TSizeTy >::IsIn(), THash< TKey, TDat, THashFunc >::Len(), and TVec< TVal, TSizeTy >::Len().
Referenced by CmtyTest().
void TSnap::CmtyEvolutionJson | ( | TStr & | Json, |
TIntIntVH & | sizesContV, | ||
TIntIntVH & | cContV, | ||
TIntIntVH & | edges | ||
) |
Definition at line 725 of file cmty.cpp.
References THash< TKey, TDat, THashFunc >::BegI(), TInt::GetStr(), TStr::InsStr(), THashKeyDatI< TKey, TDat >::IsEnd(), THash< TKey, TDat, THashFunc >::Len(), and TStr::Len().
Referenced by CmtyTest().
Definition at line 827 of file cmty.cpp.
References CmtyEvolutionFileBatchV(), and CmtyEvolutionJson().
int TSnap::CntDegNodes | ( | const PGraph & | Graph, |
const int & | NodeDeg | ||
) |
Returns the number of nodes with degree NodeDeg.
Definition at line 105 of file alg.h.
Referenced by TTimeNet::LoadArxiv(), TTimeNet::LoadPatents(), and TGStat::TakeBasicStat().
int TSnap::CntEdgesToSet | ( | const PGraph & | Graph, |
const int & | NId, | ||
const TIntSet & | NodeSet | ||
) |
Returns the number of nodes in NodeSet that have an edge to the node NId.
Definition at line 123 of file alg.h.
References THashSet< TKey, THashFunc >::AddKey(), gfDirected, and THashSet< TKey, THashFunc >::IsKey().
int TSnap::CntInDegNodes | ( | const PGraph & | Graph, |
const int & | NodeInDeg | ||
) |
Returns the number of nodes with in-degree NodeInDeg.
Definition at line 87 of file alg.h.
Referenced by TTimeNet::LoadBipartite(), and TGStat::TakeBasicStat().
int TSnap::CntNonZNodes | ( | const PGraph & | Graph | ) |
Returns the number of nodes with degree greater than 0.
Definition at line 114 of file alg.h.
Referenced by TTimeNet::PlotMedianDegOverTm().
int TSnap::CntOutDegNodes | ( | const PGraph & | Graph, |
const int & | NodeOutDeg | ||
) |
Returns the number of nodes with out-degree NodeOutDeg.
Definition at line 96 of file alg.h.
Referenced by TTimeNet::LoadBipartite(), and TGStat::TakeBasicStat().
int TSnap::CntSelfEdges | ( | const PGraph & | Graph | ) |
Counts the number of self-edges in a graph. Edge (u,u)
is a self-edge.
int TSnap::CntUniqBiDirEdges | ( | const PGraph & | Graph | ) |
Counts unique bidirectional edges in the graph Graph
. Edge is bidirectional if there exist directed edges in both directions: (u,v)
and (v,u)
Definition at line 316 of file alg.h.
References CntUniqUndirEdges(), and gfDirected.
Referenced by TGStat::TakeBasicStat().
int TSnap::CntUniqDirEdges | ( | const PGraph & | Graph | ) |
Counts unique directed edges in the graph Graph
. Nodes (u,v)
(where u!=v
) are connected via a directed edge if there exists a directed edge from node u
to node v
.
Definition at line 301 of file alg.h.
References THashSet< TKey, THashFunc >::AddKey(), THashSet< TKey, THashFunc >::Clr(), and THashSet< TKey, THashFunc >::Len().
Referenced by TGStat::TakeBasicStat().
int TSnap::CntUniqUndirEdges | ( | const PGraph & | Graph | ) |
Counts unique undirected edges in the graph Graph
. Nodes (u,v)
(where u!=v
) are connected via an undirected edge if there exists an edge in either direction (u,v)
or (v,u)
.
Definition at line 279 of file alg.h.
References THashSet< TKey, THashFunc >::AddKey(), THashSet< TKey, THashFunc >::Clr(), and THashSet< TKey, THashFunc >::Len().
Referenced by CntUniqBiDirEdges().
Clauset-Newman-Moore community detection method for large networks. At every step of the algorithm two communities that contribute maximum positive value to global modularity are merged. See: Finding community structure in very large networks, A. Clauset, M.E.J. Newman, C. Moore, 2004
Definition at line 1449 of file cmty.cpp.
References TSnap::TSnapDetail::TCNMQMatrix::CmtyCMN().
Girvan-Newman community detection algorithm based on Betweenness centrality. See: Girvan M. and Newman M. E. J., Community structure in social and biological networks, Proc. Natl. Acad. Sci. USA 99, 7821-7826 (2002)
Definition at line 312 of file cmty.cpp.
References TSnap::TSnapDetail::_GirvanNewmanGetModularity(), TUNGraph::BegNI(), TVec< TVal, TSizeTy >::Clr(), TSnap::TSnapDetail::CmtyGirvanNewmanStep(), TUNGraph::EndNI(), TUNGraph::GetEdges(), TVec< TVal, TSizeTy >::Len(), and TVec< TVal, TSizeTy >::Swap().
POutGraph TSnap::ConvertESubGraph | ( | const PInGraph & | InGraph, |
const TIntV & | EIdV, | ||
const bool & | RenumberNodes = false |
||
) |
Returns a subgraph of graph InGraph with EIdV edges with an optional node renumbering.
Creates a subgraph of the input graph InGraph on EIdV edges and returns an output graph. Input and output graphs can have different types. Node and edge data is not copied, but it is shared by input and output graphs.
Parameter RenumberNodes determines, whether the node IDs are preserved or not. If RenumberNodes is false, then nodes in the resulting graph have the same node IDs as nodes in InGraph. If RenumberNodes is true, then nodes in the resulting graph are renumbered sequentially from 0 to N-1. By default, the nodes are not renumbered.
Definition at line 441 of file subgraph.h.
References CAssert, edge, gfMultiGraph, HasGraphFlag, IAssert, and TVec< TVal, TSizeTy >::Len().
POutGraph TSnap::ConvertGraph | ( | const PInGraph & | InGraph, |
const bool & | RenumberNodes = false |
||
) |
Performs conversion of graph InGraph with an optional node renumbering.
Takes an input graph InGraph and returns an output graph. Input and output graphs can have different types. Node and edge data is not copied, but it is shared by input and output graphs.
Parameter RenumberNodes determines, whether the node IDs are preserved or not. If RenumberNodes is false, then nodes in the resulting graph have the same node IDs as nodes in InGraph. If RenumberNodes is true, then nodes in the resulting graph are renumbered sequentially from 0 to N-1. By default, the nodes are not renumbered.
Definition at line 326 of file subgraph.h.
References THashSet< TKey, THashFunc >::AddKey(), gfDirected, and HasGraphFlag.
POutGraph TSnap::ConvertSubGraph | ( | const PInGraph & | InGraph, |
const TIntV & | NIdV, | ||
const bool & | RenumberNodes = false |
||
) |
Returns an induced subgraph of graph InGraph with NIdV nodes with an optional node renumbering.
Creates a subgraph of the input graph InGraph on NIdV nodes and returns an output graph. Input and output graphs can have different types. Node and edge data is not copied, but it is shared by input and output graphs.
Parameter RenumberNodes determines, whether the node IDs are preserved or not. If RenumberNodes is false, then nodes in the resulting graph have the same node IDs as nodes in InGraph. If RenumberNodes is true, then nodes in the resulting graph are renumbered sequentially from 0 to N-1. By default, the nodes are not renumbered.
Definition at line 436 of file subgraph.h.
void TSnap::DelDegKNodes | ( | PGraph & | Graph, |
const int & | OutDegK, | ||
const int & | InDegK | ||
) |
Removes all the node of out-degree OutDegK
and all the nodes of in-degree InDegK
from the graph.
Definition at line 445 of file alg.h.
References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Len().
void TSnap::DelNodes | ( | PGraph & | Graph, |
const TIntV & | NIdV | ||
) |
Removes nodes with ids stored in NIdV
from the graph.
Definition at line 425 of file alg.h.
References TVec< TVal, TSizeTy >::Len().
void TSnap::DelSelfEdges | ( | const PGraph & | Graph | ) |
Removes all the self-edges from the graph.
Definition at line 419 of file alg.h.
Referenced by CmtyEvolutionFileBatch(), ChibaNishizekiWeighter::Initialize(), TAGMFit::InitNodeData(), TAGMFast::SetGraph(), TCoda::SetGraph(), TCesna::SetGraph(), and TKronMomentsFit::Test().
void TSnap::DelZeroDegNodes | ( | PGraph & | Graph | ) |
Removes all the zero-degree nodes, that isolated nodes, from the graph.
Definition at line 432 of file alg.h.
References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Len().
Referenced by TKronMtx::PlotCmpGraphs(), and TMAGFitBern::PlotProperties().
void TSnap::DrawGViz | ( | const PGraph & | Graph, |
const TGVizLayout & | Layout, | ||
const TStr & | PltFNm, | ||
const TStr & | Desc = TStr() , |
||
const bool & | NodeLabels = false , |
||
const TIntStrH & | NIdColorH = TIntStrH() |
||
) |
Draws a given Graph using a selected GraphViz Layout engine with nodes colored.
Useful for drawing small (<100 node) graphs.
PltFNm | Output filename (extension .ps, .png, .gif) determines the output format. |
NIdColorH | Maps node ids to node colors (see GraphViz documentation for more details). |
Definition at line 34 of file gviz.h.
References TStr::GetFExt(), TStr::GetSubStr(), TSnap::TSnapDetail::GVizDoLayout(), TStr::Len(), and SaveGViz().
Referenced by TLocClust::DrawWhiskers(), and PlotRoles().
void TSnap::DrawGViz | ( | const PGraph & | Graph, |
const TGVizLayout & | Layout, | ||
const TStr & | PltFNm, | ||
const TStr & | Desc, | ||
const TIntStrH & | NodeLabelH | ||
) |
Draws a given Graph using a selected GraphViz Layout engine with nodes labeled.
Useful for drawing small (<100 node) graphs.
PltFNm | Output filename (extension .ps, .png, .gif) determines the output format. |
NIdColorH | Maps node ids to node colors (see GraphViz documentation for more details). |
Definition at line 42 of file gviz.h.
References TStr::GetFExt(), TStr::GetSubStr(), TSnap::TSnapDetail::GVizDoLayout(), TStr::Len(), and SaveGViz().
Event importance.
Definition at line 527 of file centr.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), THash< TKey, TDat, THashFunc >::BegI(), THash< TKey, TDat, THashFunc >::EndI(), and THash< TKey, TDat, THashFunc >::GetDat().
Definition at line 556 of file centr.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), THash< TKey, TDat, THashFunc >::BegI(), THash< TKey, TDat, THashFunc >::EndI(), and THash< TKey, TDat, THashFunc >::GetDat().
Girvan-Newman community detection algorithm based on Betweenness centrality. See: Girvan M. and Newman M. E. J., Community structure in social and biological networks, Proc. Natl. Acad. Sci. USA 99, 7821-7826 (2002)
Definition at line 12 of file coreper.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), THash< TKey, TDat, THashFunc >::BegI(), TUNGraph::BegNI(), TUNGraph::EndNI(), THashKeyDatI< TKey, TDat >::IsEnd(), THash< TKey, TDat, THashFunc >::Len(), and THash< TKey, TDat, THashFunc >::SortByDat().
Definition at line 56 of file coreper.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), THash< TKey, TDat, THashFunc >::BegI(), TUNGraph::BegNI(), THash< TKey, TDat, THashFunc >::EndI(), TUNGraph::EndNI(), TUNGraph::GetNI(), TUNGraph::GetNodes(), Intersect(), THashKeyDatI< TKey, TDat >::IsEnd(), THash< TKey, TDat, THashFunc >::IsKey(), THash< TKey, TDat, THashFunc >::Len(), and THash< TKey, TDat, THashFunc >::SortByDat().
int TSnap::FindAugV | ( | const PNEANet & | Net, |
const int & | CapIndex, | ||
TIntV & | Flow, | ||
TIntQ & | FwdNodeQ, | ||
TIntH & | PredEdgeH, | ||
TIntQ & | BwdNodeQ, | ||
TIntH & | SuccEdgeH, | ||
TIntV & | MidToSrcAugV, | ||
TIntV & | MidToSnkAugV, | ||
const int & | SrcNId, | ||
const int & | SnkNId | ||
) |
Returns the amount the flow can be augmented over the paths, 0 if no path can be found.
Find the augmenting path. Calls bidirectional BFS to find the path, and then builds the two path vectors.
MidToSrcAugV | Contains the path vector from the midpoint node where the bi-d search met back to the source node. |
MidToSnkAugV | Contains the path vector from the midpoint node where the bi-d search met back to the sink node. |
Definition at line 71 of file flow.cpp.
References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::GetDat(), TNEANet::TEdgeI::GetDstNId(), TNEANet::TEdgeI::GetSrcNId(), IntFlowBiDBFS(), and TInt::Mx.
Referenced by GetMaxFlowIntEK().
Definition at line 685 of file centr.cpp.
References TVec< TVal, TSizeTy >::Del(), THash< TKey, TDat, THashFunc >::GetDat(), TVec< TVal, TSizeTy >::GetVal(), TVec< TVal, TSizeTy >::Len(), and TInt::Mx.
Referenced by GetWeightedShortestPath().
PGraph TSnap::GenBaraHierar | ( | const int & | Levels, |
const bool & | IsDir | ||
) |
Generates a Ravasz-Barabasi deterministic scale-free graph.
Corners of the graph are recursively expanded with miniature copies of the base graph (below). The graph has power-law degree distribution with the exponent 1+ln(5)/ln(4) and clustering coefficient with power-law decay exponent -1. Base graph:
/// o---o /// |\ /| /// | o | /// |/ \| /// o---o ///
See: Hierarchical organization in complex networks. Ravasz and Barabasi. URL: http://arxiv.org/abs/cond-mat/0206130
Definition at line 174 of file ggen.h.
References TMath::Power(), and TMath::Round().
PGraph TSnap::GenCircle | ( | const int & | Nodes, |
const int & | NodeOutDeg = 1 , |
||
const bool & | IsDir = true |
||
) |
Generates a circle graph where every node creates out-links to NodeOutDeg forward nodes.
Definition at line 104 of file ggen.h.
References gfDirected.
Generates a random undirect graph with a given degree sequence.
Generates a random undirect graph with a given degree sequence DegSeqV. Configuration model operates as follows. For each node N, of degree DeqSeqV[N] we create DeqSeqV[N] spokes (half-edges). We then pick two spokes at random, and connect the spokes endpoints. We continue this process until no spokes are left. Generally this generates a multigraph (i.e., spokes out of same nodes can be chosen multiple times).We ignore (discard) self-loops and multiple edges. Thus, the generated graph will only approximate follow the given degree sequence. The method is very fast!
Definition at line 122 of file ggen.cpp.
References TUNGraph::AddEdge(), THashSet< TKey, THashFunc >::AddKey(), TUNGraph::AddNode(), TRnd::GetUniDevInt(), THashSet< TKey, THashFunc >::IsKey(), TVec< TVal, TSizeTy >::Len(), TMath::Mn(), TUNGraph::New(), TUNGraph::Reserve(), and Swap().
Referenced by GenConfModel(), GenRndPowerLaw(), and TTimeNet::PlotEffDiam().
Generate a random graph using (approximately) the same node degrees as in G using the configuration model.
Definition at line 338 of file ggen.cpp.
References GenConfModel(), GetDegSeqV(), and TUNGraph::GetNodes().
Generates a random scale-free network using the Copying Model.
Generates a random scale-free network using the Copying Model. The generating process operates as follows: Node u is added to a graph, it selects a random node v, and with prob Beta it links to v, with 1-Beta links u links to neighbor of v. The power-law degree exponent is -1/(1-Beta). See: Stochastic models for the web graph. Kumar, Raghavan, Rajagopalan, Sivakumar, Tomkins, Upfal. URL: http://snap.stanford.edu/class/cs224w-readings/kumar00stochastic.pdf
Definition at line 456 of file ggen.cpp.
References TNGraph::AddEdge(), TNGraph::AddNode(), TNGraph::GetNI(), TNGraph::TNodeI::GetOutDeg(), TNGraph::TNodeI::GetOutNId(), TNGraph::GetRndNId(), TRnd::GetUniDev(), TRnd::GetUniDevInt(), TNGraph::New(), and TNGraph::Reserve().
Generates a random graph with exact degree sequence.
Generates a random graph with exact degree sequence DegSeqV
. DegSeqV
must be sorted in descending order. The generated graph has no self loops. The graph generation process simulates the Configuration Model, but if a duplicate edge occurs, we find a random edge, break it and reconnect it with the duplicate.
Definition at line 61 of file ggen.cpp.
References TUNGraph::AddEdge(), TUNGraph::AddNode(), TUNGraph::DelEdge(), edge, TSnap::TSnapDetail::GetRndEdgeNonAdjNode(), IAssert, IAssertR, TUNGraph::IsEdge(), TVec< TVal, TSizeTy >::IsSorted(), TVec< TVal, TSizeTy >::Len(), TUNGraph::New(), TUNGraph::Reserve(), TPair< TVal1, TVal2 >::Val1, and TPair< TVal1, TVal2 >::Val2.
Referenced by GenRndDegK(), and GenRndPowerLaw().
PNGraph TSnap::GenForestFire | ( | const int & | Nodes, |
const double & | FwdProb, | ||
const double & | BckProb | ||
) |
Generates a random Forest Fire, directed graph with given probabilities.
Definition at line 445 of file ggen.cpp.
References TForestFire::GenGraph().
PGraph TSnap::GenFull | ( | const int & | Nodes | ) |
PUNGraph TSnap::GenGeoPrefAttach | ( | const int & | Nodes, |
const int & | OutDeg, | ||
const double & | Beta, | ||
TRnd & | Rnd | ||
) |
Generates a random scale-free graph using the Geometric Preferential model.
Generates a random scale-free graph using the Geometric Preferential Attachment model by Flexman, Frieze and Vera. See: A geometric preferential attachment model of networks by Flexman, Frieze and Vera. WAW 2004. URL: http://math.cmu.edu/~af1p/Texfiles/GeoWeb.pdf
Definition at line 364 of file ggen.cpp.
References TVec< TVal, TSizeTy >::Add(), TUNGraph::AddEdge(), TUNGraph::AddNode(), TVec< TVal, TSizeTy >::Clr(), TVec< TVal, TSizeTy >::Del(), TUNGraph::TNodeI::GetDeg(), TUNGraph::GetNI(), TSnap::TSnapDetail::GetSphereDev(), TRnd::GetUniDevInt(), TUNGraph::IsNode(), TVec< TVal, TSizeTy >::Last(), TVec< TVal, TSizeTy >::Len(), TUNGraph::New(), TMath::Pi, TMath::Sqr(), TTriple< TVal1, TVal2, TVal3 >::Val1, TTriple< TVal1, TVal2, TVal3 >::Val2, and TTriple< TVal1, TVal2, TVal3 >::Val3.
PGraph TSnap::GenGrid | ( | const int & | Rows, |
const int & | Cols, | ||
const bool & | IsDir = true |
||
) |
Generates a 2D-grid graph of Rows rows and Cols columns.
Definition at line 65 of file ggen.h.
References gfDirected.
Generates a power-law degree distribution using Barabasi-Albert model of scale-free graphs.
Barabasi-Albert model of scale-free graphs. The graph has power-law degree distribution. See: Emergence of scaling in random networks by Barabasi and Albert. URL: http://arxiv.org/abs/cond-mat/9910332
Definition at line 313 of file ggen.cpp.
References TVec< TVal, TSizeTy >::Add(), TUNGraph::AddEdge(), THashSet< TKey, THashFunc >::AddKey(), TUNGraph::AddNode(), THashSet< TKey, THashFunc >::Clr(), TRnd::GetUniDevInt(), TVec< TVal, TSizeTy >::Len(), THashSet< TKey, THashFunc >::Len(), TPt< TRec >::New(), and TUNGraph::Reserve().
Rewire a random undirected graph. Keeps node degrees the same, but randomly rewires the edges.
Rewire the network. Keeps node degrees as is but randomly rewires the edges. Use this function to generate a random graph with the same degree sequence as the OrigGraph. See: On the uniform generation of random graphs with prescribed degree sequences by R. Milo, N. Kashtan, S. Itzkovitz, M. E. J. Newman, U. Alon URL: http://arxiv.org/abs/cond-mat/0312028
Definition at line 168 of file ggen.cpp.
References TUNGraph::AddEdge(), THashSet< TKey, THashFunc >::AddKey(), TUNGraph::AddNode(), TUNGraph::BegNI(), THashSet< TKey, THashFunc >::DelKeyId(), TUNGraph::EndNI(), TUNGraph::GetEdges(), TUNGraph::GetNodes(), THashSet< TKey, THashFunc >::GetRndKeyId(), TExeTm::GetSecs(), TExeTm::GetStr(), THashSet< TKey, THashFunc >::IsKey(), THashSet< TKey, THashFunc >::Len(), TUNGraph::New(), TUNGraph::Reserve(), Swap(), TPair< TVal1, TVal2 >::Val1, and TPair< TVal1, TVal2 >::Val2.
Referenced by GenRndDegK(), GenRndPowerLaw(), and TLocClust::PlotNCP().
Rewire a random directed graph. Keeps node degrees the same, but randomly rewires the edges.
Rewire the network. Keeps node degrees as is but randomly rewires the edges. Use this function to generate a random graph with the same degree sequence as the OrigGraph. See: On the uniform generation of random graphs with prescribed degree sequences by R. Milo, N. Kashtan, S. Itzkovitz, M. E. J. Newman, U. Alon. URL: http://arxiv.org/abs/cond-mat/0312028
Definition at line 219 of file ggen.cpp.
References TNGraph::AddEdge(), THashSet< TKey, THashFunc >::AddKey(), TNGraph::AddNode(), THashSet< TKey, THashFunc >::DelKeyId(), THashSet< TKey, THashFunc >::GetRndKeyId(), TExeTm::GetSecs(), TExeTm::GetStr(), THashSet< TKey, THashFunc >::IsKey(), THashSet< TKey, THashFunc >::Len(), TNGraph::New(), TNGraph::Reserve(), TPair< TVal1, TVal2 >::Val1, and TPair< TVal1, TVal2 >::Val2.
Rewire a random bipartite graph. Keeps node degrees the same, but randomly rewires the edges.
Rewire a bipartite graph. Keeps node degrees as is but randomly rewires the edges. Use this function to generate a random graph with the same degree sequence as the OrigGraph. See: On the uniform generation of random graphs with prescribed degree sequences by R. Milo, N. Kashtan, S. Itzkovitz, M. E. J. Newman, U. Alon URL: http://arxiv.org/abs/cond-mat/0312028
Definition at line 266 of file ggen.cpp.
References TBPGraph::AddEdge(), THashSet< TKey, THashFunc >::AddKey(), TBPGraph::AddNode(), THashSet< TKey, THashFunc >::DelKeyId(), THashSet< TKey, THashFunc >::GetRndKeyId(), TExeTm::GetSecs(), TExeTm::GetStr(), IAssert, THashSet< TKey, THashFunc >::IsKey(), THashSet< TKey, THashFunc >::Len(), TBPGraph::New(), TBPGraph::Reserve(), TPair< TVal1, TVal2 >::Val1, and TPair< TVal1, TVal2 >::Val2.
PNGraph TSnap::GenRMat | ( | const int & | Nodes, |
const int & | Edges, | ||
const double & | A, | ||
const double & | B, | ||
const double & | C, | ||
TRnd & | Rnd | ||
) |
Generates a R-MAT graph using recursive descent into a 2x2 matrix [A,B; C, 1-(A+B+C)].
R-MAT Generator. The modes is based on the recursive descent into a 2x2 matrix [A,B; C, 1-(A+B+C)]. See: R-MAT Generator: A Recursive Model for Graph Mining. D. Chakrabarti, Y. Zhan and C. Faloutsos, in SIAM Data Mining 2004. URL: http://www.cs.cmu.edu/~deepay/mywww/papers/siam04.pdf
Definition at line 481 of file ggen.cpp.
References TVec< TVal, TSizeTy >::Add(), TNGraph::AddEdge(), TNGraph::AddNode(), TNGraph::Defrag(), edge, Fail, TRnd::GetUniDev(), IAssert, TNGraph::IsEdge(), TNGraph::New(), and TNGraph::Reserve().
Referenced by GenRMatEpinions().