SNAP Library 3.0, Developer Reference
2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
Undirected graph. More...
#include <graph.h>
Classes | |
class | TEdgeI |
Edge iterator. Only forward iteration (operator++) is supported. More... | |
class | TNode |
class | TNodeI |
Node iterator. Only forward iteration (operator++) is supported. More... | |
Public Types | |
typedef TUNGraph | TNet |
typedef TPt< TUNGraph > | PNet |
Public Member Functions | |
TUNGraph () | |
TUNGraph (const int &Nodes, const int &Edges) | |
Constructor that reserves enough memory for a graph of Nodes nodes and Edges edges. More... | |
TUNGraph (const TUNGraph &Graph) | |
TUNGraph (TSIn &SIn) | |
Constructor that loads the graph from a (binary) stream SIn. More... | |
void | Save (TSOut &SOut) const |
Saves the graph to a (binary) stream SOut. More... | |
bool | HasFlag (const TGraphFlag &Flag) const |
Allows for run-time checking the type of the graph (see the TGraphFlag for flags). More... | |
TUNGraph & | operator= (const TUNGraph &Graph) |
int | GetNodes () const |
Returns the number of nodes in the graph. More... | |
int | AddNode (int NId=-1) |
Adds a node of ID NId to the graph. More... | |
int | AddNodeUnchecked (int NId=-1) |
Adds a node of ID NId to the graph without performing checks. More... | |
int | AddNode (const TNodeI &NodeI) |
Adds a node of ID NodeI.GetId() to the graph. More... | |
int | AddNode (const int &NId, const TIntV &NbrNIdV) |
Adds a node of ID NId to the graph and create edges to all nodes in vector NbrNIdV. More... | |
int | AddNode (const int &NId, const TVecPool< TInt > &Pool, const int &NIdVId) |
Adds a node of ID NId to the graph and create edges to all nodes in vector NIdVId in the vector pool Pool. More... | |
void | DelNode (const int &NId) |
Deletes node of ID NId from the graph. More... | |
void | DelNode (const TNode &NodeI) |
Deletes node of ID NodeI.GetId() from the graph. More... | |
bool | IsNode (const int &NId) const |
Tests whether ID NId is a node. More... | |
TNodeI | BegNI () const |
Returns an iterator referring to the first node in the graph. More... | |
TNodeI | EndNI () const |
Returns an iterator referring to the past-the-end node in the graph. More... | |
TNodeI | GetNI (const int &NId) const |
Returns an iterator referring to the node of ID NId in the graph. More... | |
int | GetMxNId () const |
Returns an ID that is larger than any node ID in the graph. More... | |
int | GetEdges () const |
Returns the number of edges in the graph. More... | |
int | AddEdge (const int &SrcNId, const int &DstNId) |
Adds an edge between node IDs SrcNId and DstNId to the graph. More... | |
int | AddEdgeUnchecked (const int &SrcNId, const int &DstNId) |
Adds an edge from node IDs SrcNId to node DstNId to the graph without performing checks. More... | |
int | AddEdge2 (const int &SrcNId, const int &DstNId) |
Adds an edge between node IDs SrcNId and DstNId to the graph. If nodes do not exists, create them. More... | |
int | AddEdge (const TEdgeI &EdgeI) |
Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph. More... | |
void | DelEdge (const int &SrcNId, const int &DstNId) |
Deletes an edge between node IDs SrcNId and DstNId from the graph. More... | |
bool | IsEdge (const int &SrcNId, const int &DstNId) const |
Tests whether an edge between node IDs SrcNId and DstNId exists in the graph. More... | |
TEdgeI | BegEI () const |
Returns an iterator referring to the first edge in the graph. More... | |
TEdgeI | EndEI () const |
Returns an iterator referring to the past-the-end edge in the graph. More... | |
TEdgeI | GetEI (const int &EId) const |
Not supported/implemented! More... | |
TEdgeI | GetEI (const int &SrcNId, const int &DstNId) const |
Returns an iterator referring to edge (SrcNId, DstNId) in the graph. More... | |
int | GetRndNId (TRnd &Rnd=TInt::Rnd) |
Returns an ID of a random node in the graph. More... | |
TNodeI | GetRndNI (TRnd &Rnd=TInt::Rnd) |
Returns an interator referring to a random node in the graph. More... | |
void | GetNIdV (TIntV &NIdV) const |
Gets a vector IDs of all nodes in the graph. More... | |
bool | Empty () const |
Tests whether the graph is empty (has zero nodes). More... | |
void | Clr () |
Deletes all nodes and edges from the graph. More... | |
void | SortNodeAdjV () |
Sorts the adjacency lists of each node. More... | |
void | Reserve (const int &Nodes, const int &Edges) |
Reserves memory for a graph of Nodes nodes and Edges edges. More... | |
void | ReserveNIdDeg (const int &NId, const int &Deg) |
Reserves memory for node ID NId having Deg edges. More... | |
void | Defrag (const bool &OnlyNodeLinks=false) |
Defragments the graph. More... | |
bool | IsOk (const bool &ThrowExcept=true) const |
Checks the graph data structure for internal consistency. More... | |
void | Dump (FILE *OutF=stdout) const |
Print the graph in a human readable form to an output stream OutF. More... | |
Static Public Member Functions | |
static PUNGraph | New () |
Static constructor that returns a pointer to the graph. Call: PUNGraph Graph = TUNGraph::New(). More... | |
static PUNGraph | New (const int &Nodes, const int &Edges) |
Static constructor that returns a pointer to the graph and reserves enough memory for Nodes nodes and Edges edges. More... | |
static PUNGraph | Load (TSIn &SIn) |
Static constructor that loads the graph from a stream SIn and returns a pointer to it. More... | |
static PUNGraph | GetSmallGraph () |
Returns a small graph on 5 nodes and 5 edges. More... | |
Private Member Functions | |
TNode & | GetNode (const int &NId) |
const TNode & | GetNode (const int &NId) const |
Private Attributes | |
TCRef | CRef |
TInt | MxNId |
TInt | NEdges |
THash< TInt, TNode > | NodeH |
Friends | |
class | TUNGraphMtx |
class | TPt< TUNGraph > |
Undirected graph.
Node IDs can be arbitrary non-negative integers. Nodes and edges have no attributes/data associated with them. There is at most one undirected edge between a pair of nodes. Self loops (one per node) are allowed but multiple (parallel) edges are not. The undirected graph data structure is implemented using sorted adjacency lists. This means adding a node takes constant time, while adding an edge takes linear time (since adjacency list is kept sorted) in the node degree. Accessing arbitrary node takes constant time and accessing any edge takes logarithmic time in the node degree.
typedef TPt<TUNGraph> TUNGraph::PNet |
typedef TUNGraph TUNGraph::TNet |
|
inline |
|
inlineexplicit |
Constructor that reserves enough memory for a graph of Nodes nodes and Edges edges.
Definition at line 148 of file graph.h.
References Reserve().
|
inline |
int TUNGraph::AddEdge | ( | const int & | SrcNId, |
const int & | DstNId | ||
) |
Adds an edge between node IDs SrcNId and DstNId to the graph.
If the edge already exists return -2. If the edge was successfully added return -1. Normally the function should return an ID of the edge added but since edges in TUNGraph have no IDs we return -1. The function aborts if SrcNId or DstNId are not nodes in the graph.
Definition at line 92 of file graph.cpp.
References TVec< TVal, TSizeTy >::AddSorted(), TStr::Fmt(), GetNode(), IAssertR, IsEdge(), IsNode(), NEdges, and TUNGraph::TNode::NIdV.
Referenced by TUndirFFire::AddNodes(), BuildFeatureGraph(), TCliqueOverlap::CalculateOverlapMtx(), TSnap::GenConfModel(), TSnap::GenDegSeq(), TSnap::GenPrefAttach(), TSnap::GenRewire(), TSnap::GenSmallWorld(), TSnap::GetEgonet(), GetSmallGraph(), TSnap::GetSubGraph(), TTimeNENet::GetTriadEdges(), TSnap::TSnapDetail::InfomapOnlineIncrement(), TAGM::RndConnectInsideCommunity(), TNetConstraint< PGraph >::Test(), and UnweightedGraphRepresentation().
|
inline |
Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph.
Definition at line 230 of file graph.h.
References AddEdge(), TUNGraph::TEdgeI::GetDstNId(), and TUNGraph::TEdgeI::GetSrcNId().
Referenced by AddEdge().
int TUNGraph::AddEdge2 | ( | const int & | SrcNId, |
const int & | DstNId | ||
) |
Adds an edge between node IDs SrcNId and DstNId to the graph. If nodes do not exists, create them.
Definition at line 112 of file graph.cpp.
References AddNode(), TVec< TVal, TSizeTy >::AddSorted(), GetNode(), IsNode(), NEdges, and TUNGraph::TNode::NIdV.
int TUNGraph::AddEdgeUnchecked | ( | const int & | SrcNId, |
const int & | DstNId | ||
) |
Adds an edge from node IDs SrcNId to node DstNId to the graph without performing checks.
Definition at line 103 of file graph.cpp.
References TVec< TVal, TSizeTy >::Add(), GetNode(), NEdges, and TUNGraph::TNode::NIdV.
int TUNGraph::AddNode | ( | int | NId = -1 | ) |
Adds a node of ID NId to the graph.
Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.
Definition at line 8 of file graph.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), TStr::Fmt(), IAssertR, IsNode(), TMath::Mx(), MxNId, and NodeH.
Referenced by AddEdge2(), TUndirFFire::AddNodes(), BuildFeatureGraph(), TCliqueOverlap::CalculateOverlapMtx(), TAGM::GenAGM(), TSnap::GenConfModel(), TSnap::GenDegSeq(), TSnap::GenPrefAttach(), TSnap::GenRewire(), TSnap::GenSmallWorld(), TSnap::GetEgonet(), GetSmallGraph(), TSnap::GetSubGraph(), TTimeNENet::GetTriadEdges(), TSnap::TSnapDetail::InfomapOnlineIncrement(), ChibaNishizekiWeighter::Initialize(), TNetConstraint< PGraph >::Test(), and UnweightedGraphRepresentation().
|
inline |
Adds a node of ID NodeI.GetId() to the graph.
Definition at line 178 of file graph.h.
References AddNode(), and TUNGraph::TNodeI::GetId().
Referenced by AddNode().
int TUNGraph::AddNode | ( | const int & | NId, |
const TIntV & | NbrNIdV | ||
) |
Adds a node of ID NId to the graph and create edges to all nodes in vector NbrNIdV.
Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.
The operation can create inconsistent graphs when the neighboring nodes in NbrNIdV vector do not exist. Use TUNGraph::IsOk to check that the resulting graph is consistent after the operation.
Definition at line 28 of file graph.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), TVec< TVal, TSizeTy >::AddSorted(), TStr::Fmt(), TUNGraph::TNode::GetDeg(), GetNode(), IAssertR, TUNGraph::TNode::Id, IsNode(), TVec< TVal, TSizeTy >::Len(), TMath::Mx(), MxNId, NEdges, TUNGraph::TNode::NIdV, NodeH, and TVec< TVal, TSizeTy >::Sort().
Adds a node of ID NId to the graph and create edges to all nodes in vector NIdVId in the vector pool Pool.
Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.
The operation can create inconsistent graphs when the neighboring nodes stored in the Pool vector are not explicitly added to the graph. Use TUNGraph::IsOk to check that the resulting graph is consistent.
Definition at line 49 of file graph.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), TStr::Fmt(), TVec< TVal, TSizeTy >::GenExt(), TUNGraph::TNode::GetDeg(), TVecPool< TVal, TSizeTy >::GetValVPt(), TVecPool< TVal, TSizeTy >::GetVLen(), IAssertR, TUNGraph::TNode::Id, IsNode(), TMath::Mx(), MxNId, NEdges, TUNGraph::TNode::NIdV, NodeH, and TVec< TVal, TSizeTy >::Sort().
int TUNGraph::AddNodeUnchecked | ( | int | NId = -1 | ) |
Adds a node of ID NId to the graph without performing checks.
Definition at line 20 of file graph.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), IsNode(), TMath::Mx(), MxNId, and NodeH.
|
inline |
Returns an iterator referring to the first edge in the graph.
Definition at line 239 of file graph.h.
References BegNI(), EndNI(), TUNGraph::TNodeI::GetId(), GetNodes(), TUNGraph::TNodeI::GetOutDeg(), and TUNGraph::TNodeI::GetOutNId().
Referenced by MotifCluster::EdgeMotifAdjacency(), TAGMFast::FindComsByCV(), IsOk(), and TAGMUtil::SaveGephi().
|
inline |
Returns an iterator referring to the first node in the graph.
Definition at line 209 of file graph.h.
References THash< TKey, TDat, THashFunc >::BegI(), and NodeH.
Referenced by AddEgonetFeatures(), AddLocalFeatures(), BegEI(), TSnap::TSnapDetail::TCNMQMatrix::CmtyCMN(), CreateEmptyFeatures(), TLocClust::DrawWhiskers(), GenerateRecursiveFeatures(), TAGMFit::GetEdgeJointCom(), TCliqueOverlap::GetMaximalCliques(), TSnap::TSnapDetail::TCNMQMatrix::Init(), TAGMFit::InitNodeData(), TSnap::TSnapDetail::MapEquationNew2Modules(), TTimeNet::PlotEffDiam(), TTimeNet::PlotMedianDegOverTm(), TTimeNet::PlotMissingPast(), TAGMUtil::SaveGephi(), TLocClust::SavePajek(), MotifCluster::SemicliqueMotifAdjacency(), SortNodeAdjV(), and TKronMomentsFit::TKronMomentsFit().
|
inline |
Deletes all nodes and edges from the graph.
Definition at line 259 of file graph.h.
References THash< TKey, TDat, THashFunc >::Clr(), MxNId, NEdges, and NodeH.
void TUNGraph::Defrag | ( | const bool & | OnlyNodeLinks = false | ) |
Defragments the graph.
After performing many node and edge insertions and deletions to a graph, the graph data structure will be fragmented in memory. This function compacts down the graph data structure and frees unneeded memory.
Definition at line 160 of file graph.cpp.
References THash< TKey, TDat, THashFunc >::Defrag(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), THash< TKey, TDat, THashFunc >::IsKeyIdEqKeyN(), NodeH, and THash< TKey, TDat, THashFunc >::Pack().
Referenced by TAGM::GenAGM(), TSnap::GenSmallWorld(), and TTimeNet::PlotMissingPast().
void TUNGraph::DelEdge | ( | const int & | SrcNId, |
const int & | DstNId | ||
) |
Deletes an edge between node IDs SrcNId and DstNId from the graph.
If the edge (SrcNId, DstNId) does not exist in the graph function still completes. But the function aborts if SrcNId or DstNId are not nodes in the graph.
Definition at line 124 of file graph.cpp.
References TVec< TVal, TSizeTy >::Del(), TStr::Fmt(), GetNode(), IAssertR, IsNode(), NEdges, TUNGraph::TNode::NIdV, and TVec< TVal, TSizeTy >::SearchBin().
Referenced by TSnap::TSnapDetail::CmtyGirvanNewmanStep(), TSnap::GenDegSeq(), and TTimeNet::PlotMissingPast().
void TUNGraph::DelNode | ( | const int & | NId | ) |
Deletes node of ID NId from the graph.
If the node of ID NId does not exist the function aborts.
Definition at line 67 of file graph.cpp.
References AssertR, TVec< TVal, TSizeTy >::Del(), THash< TKey, TDat, THashFunc >::DelKey(), TStr::Fmt(), TUNGraph::TNode::GetDeg(), TUNGraph::TNode::GetNbrNId(), GetNode(), IAssert, IsNode(), NEdges, TUNGraph::TNode::NIdV, NodeH, and TVec< TVal, TSizeTy >::SearchBin().
|
inline |
Deletes node of ID NodeI.GetId() from the graph.
Definition at line 205 of file graph.h.
References DelNode(), and TUNGraph::TNode::GetId().
Referenced by DelNode().
void TUNGraph::Dump | ( | FILE * | OutF = stdout | ) | const |
Print the graph in a human readable form to an output stream OutF.
Definition at line 207 of file graph.cpp.
References edge, THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TUNGraph::TNode::GetDeg(), GetEdges(), TUNGraph::TNode::GetId(), TUNGraph::TNode::GetNbrNId(), GetNodes(), and NodeH.
|
inline |
Tests whether the graph is empty (has zero nodes).
Definition at line 257 of file graph.h.
References GetNodes().
|
inline |
Returns an iterator referring to the past-the-end edge in the graph.
Definition at line 241 of file graph.h.
References EndNI().
Referenced by MotifCluster::EdgeMotifAdjacency(), TAGMFast::FindComsByCV(), IsOk(), and TAGMUtil::SaveGephi().
|
inline |
Returns an iterator referring to the past-the-end node in the graph.
Definition at line 211 of file graph.h.
References THash< TKey, TDat, THashFunc >::EndI(), and NodeH.
Referenced by AddEgonetFeatures(), AddLocalFeatures(), BegEI(), TSnap::TSnapDetail::TCNMQMatrix::CmtyCMN(), CreateEmptyFeatures(), TLocClust::DrawWhiskers(), EndEI(), GenerateRecursiveFeatures(), TAGMFit::GetEdgeJointCom(), GetEI(), TCliqueOverlap::GetMaximalCliques(), TSnap::TSnapDetail::TCNMQMatrix::Init(), TAGMFit::InitNodeData(), TSnap::TSnapDetail::MapEquationNew2Modules(), TTimeNet::PlotEffDiam(), TTimeNet::PlotMedianDegOverTm(), TTimeNet::PlotMissingPast(), TAGMUtil::SaveGephi(), TLocClust::SavePajek(), MotifCluster::SemicliqueMotifAdjacency(), SortNodeAdjV(), and TKronMomentsFit::TKronMomentsFit().
int TUNGraph::GetEdges | ( | ) | const |
Returns the number of edges in the graph.
Definition at line 82 of file graph.cpp.
References NEdges.
Referenced by TLocClustStat::AddCut(), AddEgonetFeatures(), TUndirFFire::AddNodes(), TLocClustStat::AddToBestCutH(), TLocClust::DrawWhiskers(), Dump(), TAGMUtil::FindComsByAGM(), TAGMFast::FindComsByCV(), TAGM::GenAGM(), TAGMFast::GetCmtyVV(), TCesna::GetCmtyVV(), TCesna::GetCmtyVVUnSorted(), TAGMUtil::GetConductance(), TCliqueOverlap::GetCPMCommunities(), TLocClust::GetCutStat(), TAGMFit::GetEdgeJointCom(), TTimeNENet::GetTriadEdges(), TLocClustStat::ImposeNCP(), TSnap::TSnapDetail::InfomapOnlineIncrement(), TSnap::TSnapDetail::TCNMQMatrix::Init(), IsOk(), TAGMFit::MLEGradAscentGivenCAG(), TAGMFast::NeighborComInit(), TAGMFit::NeighborComInit(), TLocClustStat::ParamStr(), TLocClustStat::PlotBoltzmanCurve(), TTimeNet::PlotCCfOverTm(), TTimeNet::PlotEffDiam(), TTimeNet::PlotMedianDegOverTm(), TLocClustStat::PlotNCPModul(), TLocClustStat::Run(), TAGMFit::RunMCMC(), TLocClust::SavePajek(), TLocClustStat::SaveTxtInfo(), and TGStat::TakeStat().
TEdgeI TUNGraph::GetEI | ( | const int & | EId | ) | const |
Not supported/implemented!
TUNGraph::TEdgeI TUNGraph::GetEI | ( | const int & | SrcNId, |
const int & | DstNId | ||
) | const |
Returns an iterator referring to edge (SrcNId, DstNId) in the graph.
Note that since this is an undirected graph GetEI(SrcNId, DstNId) has the same effect as GetEI(DstNId, SrcNId).
Definition at line 143 of file graph.cpp.
References EndNI(), GetNI(), IAssert, TMath::Mn(), TMath::Mx(), MxNId, and TUNGraph::TNodeI::NodeHI.
|
inline |
Returns an ID that is larger than any node ID in the graph.
Definition at line 215 of file graph.h.
References MxNId.
Referenced by ChibaNishizekiWeighter::Initialize(), and MotifCluster::MotifAdjacency().
|
inline |
Returns an iterator referring to the node of ID NId in the graph.
Definition at line 213 of file graph.h.
References THash< TKey, TDat, THashFunc >::GetI(), and NodeH.
Referenced by TSnap::TSnapDetail::_GirvanNewmanGetModularity(), TLocClust::ApproxPageRank(), TLocClustStat::BagOfWhiskers(), TLocClustStat::BagOfWhiskers2(), TUndirFFire::BurnGeoFire(), TLocClust::DrawWhiskers(), TLocClust::FindBestCut(), TAGMUtil::GetConductance(), TLocClust::GetCutStat(), GetEI(), TLocClustStat::TCutInfo::GetFracDegOut(), TAGMUtil::GetNbhCom(), TCliqueOverlap::GetNbrs(), TCliqueOverlap::GetNodeIdWithMaxDeg(), GetRndNI(), TAGMFast::GradientForOneVar(), TAGMFast::GradientForRow(), TCesna::GradientForRow(), TAGMFast::HessianForOneVar(), TSnap::TSnapDetail::InfomapOnlineIncrement(), TSnap::TSnapDetail::TCNMQMatrix::Init(), ChibaNishizekiWeighter::Initialize(), TAGMFit::JoinCom(), TAGMFit::LeaveCom(), TAGMFast::LikelihoodForOneVar(), TAGMFast::LikelihoodForRow(), TCesna::LikelihoodForRow(), TSnap::TSnapDetail::MapEquationNew2Modules(), TCliqueOverlap::MaxNbrsInCANDNodeId(), TAGMFast::MLEGradAscent(), TAGMFast::MLEGradAscentParallel(), TCesna::MLEGradAscentParallel(), TAGMFast::MLENewton(), TAGMFast::NeighborComInit(), TAGMFit::NeighborComInit(), TCesna::NeighborComInit(), TAGMFast::RandomInit(), TAGMFit::RandomInit(), TCesna::RandomInit(), TAGMFit::SeekJoin(), TAGMFit::SeekLeave(), TAGMFit::SeekSwitch(), MotifCluster::SemicliqueMotifAdjacency(), and TLocClust::SupportSweep().
void TUNGraph::GetNIdV | ( | TIntV & | NIdV | ) | const |
Gets a vector IDs of all nodes in the graph.
Definition at line 153 of file graph.cpp.
References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TVec< TVal, TSizeTy >::Gen(), THash< TKey, TDat, THashFunc >::GetKey(), GetNodes(), and NodeH.
Referenced by TAGMFit::AddBaseCmty(), TAGMFit::CalcPNoComByCmtyVV(), TAGMFast::FindComsByCV(), TAGMUtil::GenCmtyVVFromPL(), TAGMFast::MLENewton(), TAGMFit::NeighborComInit(), TAGMFast::SetGraph(), and TCesna::SetGraph().
|
inlineprivate |
Definition at line 143 of file graph.h.
References THash< TKey, TDat, THashFunc >::GetDat(), and NodeH.
Referenced by AddEdge(), AddEdge2(), AddEdgeUnchecked(), AddNode(), DelEdge(), DelNode(), IsEdge(), and ReserveNIdDeg().
|
inlineprivate |
Definition at line 144 of file graph.h.
References THash< TKey, TDat, THashFunc >::GetDat(), and NodeH.
|
inline |
Returns the number of nodes in the graph.
Definition at line 168 of file graph.h.
References THash< TKey, TDat, THashFunc >::Len(), and NodeH.
Referenced by TGStatVec::Add(), TUndirFFire::AddNodes(), TLocClust::ApproxPageRank(), BegEI(), TAGMFit::CalcPNoComByCmtyVV(), TUNGraphMtx::CheckNodeIds(), TLocClust::DrawWhiskers(), Dump(), Empty(), TCesna::FindComs(), TAGMUtil::FindComsByAGM(), TAGMFast::FindComsByCV(), TAGM::GenAGM(), TCesna::GenHoldOutAttr(), TAGMFast::GetCmtyVV(), TAGMFit::GetCmtyVV(), TCesna::GetCmtyVV(), TCesna::GetCmtyVVUnSorted(), TCliqueOverlap::GetCPMCommunities(), TCliqueOverlap::GetMaximalCliques(), GetNIdV(), TLocClustStat::ImposeNCP(), ChibaNishizekiWeighter::Initialize(), TAGMFit::InitNodeData(), TAGMFast::MLEGradAscent(), TCesna::MLEGradAscent(), TAGMFast::MLEGradAscentParallel(), TCesna::MLEGradAscentParallel(), TAGMFast::MLENewton(), TAGMFast::NeighborComInit(), TAGMFit::NeighborComInit(), TCesna::NeighborComInit(), TLocClustStat::ParamStr(), TUNGraphMtx::PGetCols(), TUNGraphMtx::PGetRows(), TLocClustStat::PlotBoltzmanCurve(), TTimeNet::PlotCCfOverTm(), TTimeNet::PlotEffDiam(), TTimeNet::PlotMedianDegOverTm(), TLocClustStat::PlotNCP(), TLocClustStat::PlotNCPModul(), TLocClustStat::PlotNCPScatter(), TLocClustStat::PlotNcpTop10(), TLocClustStat::PlotPhiInOut(), TAGMFast::RandomInit(), TCesna::RandomInit(), TAGMFit::RandomInitCmtyVV(), TLocClustStat::Run(), TAGMFit::RunMCMC(), TAGMFit::SampleTransition(), TLocClust::SavePajek(), TLocClustStat::SaveTxtInfo(), TAGMFast::SetCmtyVV(), TCesna::SetCmtyVV(), TAGMFit::SetDefaultPNoCom(), TAGMFast::SetGraph(), TCesna::SetGraph(), TGStat::TakeStat(), TKronMomentsFit::Test(), and TUNGraphMtx::TUNGraphMtx().
Returns an interator referring to a random node in the graph.
Definition at line 252 of file graph.h.
References GetNI(), and GetRndNId().
Referenced by TAGMFit::NeighborComInit().
Returns an ID of a random node in the graph.
Definition at line 250 of file graph.h.
References THash< TKey, TDat, THashFunc >::GetKey(), THash< TKey, TDat, THashFunc >::GetRndKeyId(), and NodeH.
Referenced by GetRndNI(), TLocClustStat::Run(), and TAGMFit::SampleTransition().
|
static |
Returns a small graph on 5 nodes and 5 edges.
/// Graph: 3--0--4 /// /| /// 1-2 ///
Definition at line 221 of file graph.cpp.
References AddEdge(), AddNode(), and New().
bool TUNGraph::HasFlag | ( | const TGraphFlag & | Flag | ) | const |
Allows for run-time checking the type of the graph (see the TGraphFlag for flags).
Definition at line 3 of file graph.cpp.
References HasGraphFlag.
bool TUNGraph::IsEdge | ( | const int & | SrcNId, |
const int & | DstNId | ||
) | const |
Tests whether an edge between node IDs SrcNId and DstNId exists in the graph.
Definition at line 137 of file graph.cpp.
References GetNode(), TUNGraph::TNode::IsNbrNId(), and IsNode().
Referenced by AddEdge(), BuildFeatureGraph(), TAGMFit::CalcPNoComByCmtyVV(), TSnap::GenDegSeq(), TSnap::GetEgonet(), TTimeNENet::GetTriadEdges(), TCluster::Gradient(), TAGMFast::LikelihoodHoldOut(), TCesna::LikelihoodHoldOut(), TCluster::LogLikelihood(), TCluster::MCMC(), and MotifCluster::SemicliqueMotifAdjacency().
|
inline |
Tests whether ID NId is a node.
Definition at line 207 of file graph.h.
References THash< TKey, TDat, THashFunc >::IsKey(), and NodeH.
Referenced by AddEdge(), AddEdge2(), AddNode(), AddNodeUnchecked(), TUNGraphMtx::CheckNodeIds(), DelEdge(), DelNode(), TAGM::GenAGM(), TAGMUtil::GetConductance(), TLocClust::GetCutStat(), TSnap::GetEgonet(), TTimeNENet::GetTriadEdges(), TSnap::TSnapDetail::InfomapOnlineIncrement(), ChibaNishizekiWeighter::Initialize(), IsEdge(), IsOk(), TTimeNet::PlotMissingPast(), TAGMFit::SeekLeave(), TAGMFast::SetCmtyVV(), TAGMFit::SetCmtyVV(), TAGMFast::SetGraph(), TCesna::SetGraph(), and TGraphAttributes::TGraphAttributes().
bool TUNGraph::IsOk | ( | const bool & | ThrowExcept = true | ) | const |
Checks the graph data structure for internal consistency.
For each node in the graph check that its neighbors are also nodes in the graph.
Definition at line 170 of file graph.cpp.
References BegEI(), TStr::CStr(), EAssertR, EndEI(), ErrNotify(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), TStr::Fmt(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TUNGraph::TNode::GetDeg(), GetEdges(), TUNGraph::TNode::GetId(), TUNGraph::TNode::GetNbrNId(), IsNode(), TVec< TVal, TSizeTy >::IsSorted(), TUNGraph::TNode::NIdV, and NodeH.
Static constructor that loads the graph from a stream SIn and returns a pointer to it.
Definition at line 161 of file graph.h.
References TUNGraph().
Referenced by TAGMFit::Load(), TAGMFast::Load(), and TCesna::Load().
|
inlinestatic |
Static constructor that returns a pointer to the graph. Call: PUNGraph Graph = TUNGraph::New().
Definition at line 155 of file graph.h.
References TUNGraph().
Referenced by TCliqueOverlap::CalculateOverlapMtx(), TSnap::CmtyEvolutionFileBatch(), TAGM::GenAGM(), TSnap::GenConfModel(), TSnap::GenDegSeq(), TSnap::GenGeoPrefAttach(), TSnap::GenRewire(), TSnap::GenSmallWorld(), TSnap::Get1CnCom(), TSnap::Get1CnComSzCnt(), TSnap::GetEgonet(), GetSmallGraph(), TSnap::GetSubGraph(), TTimeNENet::GetTriadEdges(), TCesna::TCesna(), TNetConstraint< PGraph >::Test(), and UnweightedGraphRepresentation().
|
inlinestatic |
Static constructor that returns a pointer to the graph and reserves enough memory for Nodes nodes and Edges edges.
Call: PUNGraph Graph = TUNGraph::New(Nodes, Edges).
Definition at line 159 of file graph.h.
References TUNGraph().
|
inline |
Reserves memory for a graph of Nodes nodes and Edges edges.
Definition at line 263 of file graph.h.
References THash< TKey, TDat, THashFunc >::Gen(), and NodeH.
Referenced by TSnap::GenConfModel(), TSnap::GenDegSeq(), TSnap::GenPrefAttach(), TSnap::GenRewire(), TSnap::GenSmallWorld(), TSnap::GetSubGraph(), and TUNGraph().
|
inline |
Reserves memory for node ID NId having Deg edges.
Definition at line 265 of file graph.h.
References GetNode(), TUNGraph::TNode::NIdV, and TVec< TVal, TSizeTy >::Reserve().
|
inline |
Saves the graph to a (binary) stream SOut.
Definition at line 153 of file graph.h.
References MxNId, NEdges, NodeH, THash< TKey, TDat, THashFunc >::Save(), and TInt::Save().
Referenced by TAGMFit::Save(), TAGMFast::Save(), and TCesna::Save().
|
inline |
Sorts the adjacency lists of each node.
Definition at line 261 of file graph.h.
References BegNI(), and EndNI().
|
friend |
|
private |
Definition at line 140 of file graph.h.
Referenced by AddNode(), AddNodeUnchecked(), Clr(), GetEI(), GetMxNId(), operator=(), and Save().
|
private |
Definition at line 140 of file graph.h.
Referenced by AddEdge(), AddEdge2(), AddEdgeUnchecked(), AddNode(), Clr(), DelEdge(), DelNode(), GetEdges(), operator=(), and Save().
Definition at line 141 of file graph.h.
Referenced by AddNode(), AddNodeUnchecked(), BegNI(), Clr(), Defrag(), DelNode(), Dump(), EndNI(), GetNI(), GetNIdV(), GetNode(), GetNodes(), GetRndNId(), IsNode(), IsOk(), operator=(), TUNGraphMtx::PMultiply(), TUNGraphMtx::PMultiplyT(), Reserve(), and Save().