22   if (
IsNode(NId)) { 
return NId;}
 
   71   for (
int e = 0; e < Node.
GetOutDeg(); e++) {
 
   73   if (nbr == NId) { 
continue; }
 
   78   for (
int e = 0; e < Node.
GetInDeg(); e++) {
 
   80   if (nbr == NId) { 
continue; }
 
   92     edges+=
NodeH[N].GetOutDeg();
 
  100   if (
IsEdge(SrcNId, DstNId)) { 
return -2; }
 
  131   if (! 
IsNode(SrcNId) || ! 
IsNode(DstNId)) { 
return false; }
 
  138   const int NodeN = SrcNI.
NodeHI.GetDat().OutNIdV.SearchBin(DstNId);
 
  155   if (! OnlyNodeLinks && ! 
NodeH.IsKeyIdEqKeyN()) { 
NodeH.Defrag(); }
 
  165       const TStr Msg = 
TStr::Fmt(
"Out-neighbor list of node %d is not sorted.", Node.
GetId());
 
  169       const TStr Msg = 
TStr::Fmt(
"In-neighbor list of node %d is not sorted.", Node.
GetId());
 
  174     for (
int e = 0; e < Node.
GetOutDeg(); e++) {
 
  176         const TStr Msg = 
TStr::Fmt(
"Out-edge %d --> %d: node %d does not exist.",
 
  180       if (e > 0 && prevNId == Node.
GetOutNId(e)) {
 
  181         const TStr Msg = 
TStr::Fmt(
"Node %d has duplidate out-edge %d --> %d.",
 
  189     for (
int e = 0; e < Node.
GetInDeg(); e++) {
 
  191         const TStr Msg = 
TStr::Fmt(
"In-edge %d <-- %d: node %d does not exist.",
 
  195       if (e > 0 && prevNId == Node.
GetInNId(e)) {
 
  196         const TStr Msg = 
TStr::Fmt(
"Node %d has duplidate in-edge %d <-- %d.",
 
  207   const int NodePlaces = (int) ceil(log10((
double) 
GetNodes()));
 
  208   fprintf(OutF, 
"-------------------------------------------------\nDirected Node Graph: nodes: %d, edges: %d\n", 
GetNodes(), 
GetEdges());
 
  211     fprintf(OutF, 
"  %*d]\n", NodePlaces, Node.
GetId());
 
  212     fprintf(OutF, 
"    in [%d]", Node.
GetInDeg());
 
  214       fprintf(OutF, 
" %*d", NodePlaces, Node.
GetInNId(
edge)); }
 
  215     fprintf(OutF, 
"\n    out[%d]", Node.
GetOutDeg());
 
  225   for (
int i = 0; i < 5; i++) { G->AddNode(i); }
 
  226   G->AddEdge(0,1); G->AddEdge(1,2); G->AddEdge(0,2);
 
  286   NodeH[NodeKeyId].InNIdV.MoveFrom(InNIdV);
 
  287   NodeH[NodeKeyId].OutNIdV.MoveFrom(OutNIdV);  
 
int GetPrimHashCd() const 
 
void AddOutEdge2(const int &SrcNId, const int &DstNId)
 
#define IAssertR(Cond, Reason)
 
int GetOutNId(const int &NodeN) const 
 
int AddOutEdge1(int &SrcIdx, const int &SrcNId, const int &DstNId)
 
void Del(const TSizeTy &ValN)
Removes the element at position ValN. 
 
static const T & Mx(const T &LVal, const T &RVal)
 
TNodeI GetNI(const int &NId) const 
Returns an iterator referring to the node of ID NId in the graph. 
 
static PNGraphMP New()
Static constructor that returns a pointer to the graph. Call: PNGraphMP Graph = TNGraphMP::New(). 
 
void GenExt(TVal *_ValT, const TSizeTy &_Vals)
Constructs a vector of _Vals elements of memory array _ValT. 
 
void DelNode(const int &NId)
Deletes node of ID NId from the graph. 
 
void DelEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true)
Deletes an edge from node IDs SrcNId to DstNId from the graph. 
 
void Dump(FILE *OutF=stdout) const 
Print the graph in a human readable form to an output stream OutF. 
 
int GetEdges() const 
Returns the number of edges in the graph. 
 
TSizeTy AddSorted(const TVal &Val, const bool &Asc=true, const TSizeTy &_MxVals=-1)
Adds element Val to a sorted vector. 
 
void ErrNotify(const char *NotifyCStr)
 
int GetInNId(const int &NodeN) const 
 
int AddEdgeUnchecked(const int &SrcNId, const int &DstNId)
Adds an edge from node IDs SrcNId to node DstNId to the graph without performing checks. 
 
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the graph. 
 
TVal * GetValVPt(const int &VId) const 
Returns pointer to the first element of the vector with id VId. 
 
void Sort(const bool &Asc=true)
Sorts the elements of the vector. 
 
#define HasGraphFlag(TGraph, Flag)
For quick testing of the properties of the graph/network object (see TGraphFlag). ...
 
void AddInEdge2(const int &SrcNId, const int &DstNId)
 
TNodeI EndNI() const 
Returns an iterator referring to the past-the-end node in the graph. 
 
int GetVLen(const int &VId) const 
Returns the number of elements in the vector with id VId. 
 
bool IsNode(const int &NId) const 
Tests whether ID NId is a node. 
 
Directed graph for multi-threaded operations. 
 
TEdgeI GetEI(const int &SrcNId, const int &DstNId) const 
Returns an iterator referring to edge (SrcNId, DstNId) in the graph. 
 
int AddInEdge1(int &DstIdx, const int &SrcNId, const int &DstNId)
 
bool FNextKeyId(int &KeyId) const 
 
Edge iterator. Only forward iteration (operator++) is supported. 
 
Node iterator. Only forward iteration (operator++) is supported. 
 
TSizeTy SearchBin(const TVal &Val) const 
Returns the position of an element with value Val. 
 
void AddNodeWithEdges(const TInt &NId, TIntV &InNIdV, TIntV &OutNIdV)
Adds a node of ID NId to the graph, creates edges to the node from all nodes in vector InNIdV...
 
bool HasFlag(const TGraphFlag &Flag) const 
Allows for run-time checking the type of the graph (see the TGraphFlag for flags). 
 
THashMP< TInt, TNode > NodeH
 
bool IsOutNId(const int &NId) const 
 
bool IsOk(const bool &ThrowExcept=true) const 
Checks the graph data structure for internal consistency. 
 
void GetNIdV(TIntV &NIdV) const 
Gets a vector IDs of all nodes in the graph. 
 
static TStr Fmt(const char *FmtStr,...)
 
bool IsSorted(const bool &Asc=true) const 
Checks whether the vector is sorted in ascending (if Asc=true) or descending (if Asc=false) order...
 
void Pack()
Reduces vector capacity (frees memory) to match its size. 
 
enum TGraphFlag_ TGraphFlag
Graph Flags, used for quick testing of graph types. 
 
#define EAssertR(Cond, MsgStr)
 
int GetNodes() const 
Returns the number of nodes in the graph. 
 
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements. 
 
int AddKey12(const int &Idx, const TKey &Key, bool &Found)
 
int AddKey13(const int &Idx, const TKey &Key)
 
static PNGraphMP GetSmallGraph()
Returns a small graph on 5 nodes and 6 edges. 
 
int AddNode(int NId=-1)
Adds a node of ID NId to the graph. 
 
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element. 
 
TDat & AddDat(const TKey &Key)
 
int AddNodeUnchecked(int NId=-1)
Adds a node of ID NId to the graph without performing checks. 
 
int GetKeyId(const TKey &Key) const 
 
bool IsEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true) const 
Tests whether an edge from node IDs SrcNId to DstNId exists in the graph. 
 
TNode & GetNode(const int &NId)
 
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node IDs SrcNId to node DstNId to the graph. 
 
const TKey & GetKey(const int &KeyId) const