21   if (
IsNode(NId)) { 
return -1;}
 
   42   for (
int i = 0; i < NbrNIdV.
Len(); i++) {
 
   71   for (
int e = 0; e < Node.
GetDeg(); e++) {
 
   73     if (nbr == NId) { 
continue; }
 
   94   if (
IsEdge(SrcNId, DstNId)) { 
return -2; } 
 
  105   if (SrcNId!=DstNId) { 
 
  115   if (
GetNode(SrcNId).IsNbrNId(DstNId)) { 
return -2; } 
 
  117   if (SrcNId!=DstNId) { 
 
  129   if (SrcNId != DstNId) { 
 
  144   const int MnNId = 
TMath::Mn(SrcNId, DstNId);
 
  147   const int NodeN = SrcNI.
NodeHI.GetDat().NIdV.SearchBin(MxNId);
 
  180     for (
int e = 0; e < Node.
GetDeg(); e++) {
 
  182         const TStr Msg = 
TStr::Fmt(
"Edge %d --> %d: node %d does not exist.",
 
  187       if (e > 0 && prevNId == Node.
GetNbrNId(e)) {
 
  188         const TStr Msg = 
TStr::Fmt(
"Node %d has duplicate edge %d --> %d.",
 
  199     const TStr Msg = 
TStr::Fmt(
"Number of edges counter is corrupted: GetEdges():%d, EdgeCount:%d.", 
GetEdges(), EdgeCnt);
 
  208   const int NodePlaces = (int) ceil(log10((
double) 
GetNodes()));
 
  209   fprintf(OutF, 
"-------------------------------------------------\nUndirected Node Graph: nodes: %d, edges: %d\n", 
GetNodes(), 
GetEdges());
 
  212     fprintf(OutF, 
"  %*d [%d] ", NodePlaces, Node.
GetId(), Node.
GetDeg());
 
  223   for (
int i = 0; i < 5; i++) { Graph->
AddNode(i); }
 
  248   if (
IsNode(NId)) { 
return NId;}
 
  296   for (
int e = 0; e < Node.
GetOutDeg(); e++) {
 
  298   if (nbr == NId) { 
continue; }
 
  303   for (
int e = 0; e < Node.
GetInDeg(); e++) {
 
  305   if (nbr == NId) { 
continue; }
 
  316     edges+=
NodeH[N].GetOutDeg();
 
  324   if (
IsEdge(SrcNId, DstNId)) { 
return -2; }
 
  339   if (
GetNode(SrcNId).IsOutNId(DstNId)) { 
return -2; } 
 
  364   if (! 
IsNode(SrcNId) || ! 
IsNode(DstNId)) { 
return false; }
 
  371   const int NodeN = SrcNI.
NodeHI.GetDat().OutNIdV.SearchBin(DstNId);
 
  396       const TStr Msg = 
TStr::Fmt(
"Out-neighbor list of node %d is not sorted.", Node.
GetId());
 
  400       const TStr Msg = 
TStr::Fmt(
"In-neighbor list of node %d is not sorted.", Node.
GetId());
 
  405     for (
int e = 0; e < Node.
GetOutDeg(); e++) {
 
  407         const TStr Msg = 
TStr::Fmt(
"Out-edge %d --> %d: node %d does not exist.",
 
  411       if (e > 0 && prevNId == Node.
GetOutNId(e)) {
 
  412         const TStr Msg = 
TStr::Fmt(
"Node %d has duplidate out-edge %d --> %d.",
 
  420     for (
int e = 0; e < Node.
GetInDeg(); e++) {
 
  422         const TStr Msg = 
TStr::Fmt(
"In-edge %d <-- %d: node %d does not exist.",
 
  426       if (e > 0 && prevNId == Node.
GetInNId(e)) {
 
  427         const TStr Msg = 
TStr::Fmt(
"Node %d has duplidate in-edge %d <-- %d.",
 
  438   const int NodePlaces = (int) ceil(log10((
double) 
GetNodes()));
 
  439   fprintf(OutF, 
"-------------------------------------------------\nDirected Node Graph: nodes: %d, edges: %d\n", 
GetNodes(), 
GetEdges());
 
  442     fprintf(OutF, 
"  %*d]\n", NodePlaces, Node.
GetId());
 
  443     fprintf(OutF, 
"    in [%d]", Node.
GetInDeg());
 
  445       fprintf(OutF, 
" %*d", NodePlaces, Node.
GetInNId(
edge)); }
 
  446     fprintf(OutF, 
"\n    out[%d]", Node.
GetOutDeg());
 
  456   for (
int i = 0; i < 5; i++) { G->
AddNode(i); }
 
  478   const TNode& Node = NodeHI.GetDat();
 
  499   for (
int out = 0; out < Node.
GetOutDeg(); out++) {
 
  506   for (
int in = 0; in < Node.
GetInDeg(); in++) {
 
  540   while (
IsEdge(SrcNId, DstNId, EId, IsDir)) {
 
  547 bool TNEGraph::IsEdge(
const int& SrcNId, 
const int& DstNId, 
int& EId, 
const bool& IsDir)
 const {
 
  552       EId = Edge.
GetId();  
return true; }
 
  558       EId = Edge.
GetId();  
return true; }
 
  600     for (
int e = 0; e < Node.
GetOutDeg(); e++) {
 
  605       if (e > 0 && prevEId == Node.
GetOutEId(e)) {
 
  613     for (
int e = 0; e < Node.
GetInDeg(); e++) {
 
  618       if (e > 0 && prevEId == Node.
GetInEId(e)) {
 
  640   const int NodePlaces = (int) ceil(log10((
double) 
GetNodes()));
 
  641   const int EdgePlaces = (int) ceil(log10((
double) 
GetEdges()));
 
  642   fprintf(OutF, 
"-------------------------------------------------\nDirected Node-Edge Graph: nodes: %d, edges: %d\n", 
GetNodes(), 
GetEdges());
 
  644     fprintf(OutF, 
"  %*d]\n", NodePlaces, NodeI.GetId());
 
  645     fprintf(OutF, 
"    in[%d]", NodeI.GetInDeg());
 
  647       fprintf(OutF, 
" %*d", EdgePlaces, NodeI.GetInEId(
edge)); }
 
  648     fprintf(OutF, 
"\n    out[%d]", NodeI.GetOutDeg());
 
  650       fprintf(OutF, 
" %*d", EdgePlaces, NodeI.GetOutEId(
edge)); }
 
  654     fprintf(OutF, 
"  %*d]  %*d  ->  %*d\n", EdgePlaces, EdgeI.GetId(), NodePlaces, EdgeI.GetSrcNId(), NodePlaces, EdgeI.GetDstNId());
 
  662   for (
int i = 0; i < 5; i++) { Graph->AddNode(i); }
 
  663   Graph->AddEdge(0,1);  Graph->AddEdge(0,2);
 
  664   Graph->AddEdge(0,3);  Graph->AddEdge(0,4);
 
  665   Graph->AddEdge(1,2);  Graph->AddEdge(1,2);
 
  673   else if (IsLNode(NId)) { 
IAssertR(LeftNode, 
TStr::Fmt(
"Node with id %s already exists on the 'left'.", NId));  
return NId; }
 
  674   else if (IsRNode(NId)) { 
IAssertR(! LeftNode, 
TStr::Fmt(
"Node with id %s already exists on the 'right'.", NId));  
return NId; }
 
  676   if (LeftNode) { LeftH.AddDat(NId, 
TNode(NId)); }
 
  677   else { RightH.AddDat(NId, 
TNode(NId)); }
 
  687   for (
int e = 0; e < Node.
GetOutDeg(); e++) {
 
  689     IAssertR(nbr != NId, 
"Bipartite graph has a loop!");
 
  700   for (
int N=LeftH.FFirstKeyId(); LeftH.FNextKeyId(N); ) {
 
  701     Edges += LeftH[N].GetDeg(); }
 
  706   const bool IsLL = IsLNode(LeftNId), IsLR = IsRNode(LeftNId);
 
  707   const bool IsRL = IsLNode(RightNId), IsRR = IsRNode(RightNId);
 
  708   IAssertR((IsLL||IsLR)&&(IsRL||IsRR), 
TStr::Fmt(
"%d or %d is not a node.", LeftNId, RightNId).CStr());
 
  709   IAssertR(LeftNId!=RightNId, 
"No self-edges are allowed."); 
 
  710   IAssertR((IsLL&&!IsLR&&!IsRL&&IsRR)||(!IsLL&&IsLR&&IsRL&&!IsRR), 
"One node should be on the 'left' and the other on the 'right'.");
 
  711   const int LNId = IsLL ? LeftNId : RightNId; 
 
  712   const int RNId = IsLL ? RightNId : LeftNId; 
 
  713   if (LeftH.GetDat(LNId).IsOutNId(RNId)) { 
return -2; } 
 
  714   LeftH.GetDat(LNId).NIdV.AddSorted(RNId);
 
  715   RightH.GetDat(RNId).NIdV.AddSorted(LNId);
 
  720   const bool IsLL = IsLNode(LeftNId), IsLR = IsRNode(LeftNId);
 
  721   const bool IsRL = IsLNode(RightNId), IsRR = IsRNode(RightNId);
 
  722   IAssertR((IsLL||IsLR)&&(IsRL||IsRR), 
TStr::Fmt(
"%d or %d is not a node.", LeftNId, RightNId).CStr());
 
  723   IAssertR(LeftNId!=RightNId, 
"No self-edges are allowed."); 
 
  724   IAssertR((IsLL&&!IsLR&&!IsRL&&IsRR)||(!IsLL&&IsLR&&IsRL&&!IsRR), 
"One node should be on the 'left' and the other on the 'right'.");
 
  725   const int LNId = IsLL ? LeftNId : RightNId; 
 
  726   const int RNId = IsLL ? RightNId : LeftNId; 
 
  729   if (n != -1) { NIdV.
Del(n); } }
 
  732   if (n != -1) { NIdV.
Del(n); } }
 
  736   if (! 
IsNode(LeftNId) || ! 
IsNode(RightNId)) { 
return false; }
 
  737   return IsLNode(LeftNId) ? LeftH.GetDat(LeftNId).IsOutNId(RightNId) : RightH.GetDat(LeftNId).IsOutNId(RightNId);
 
  741   const bool IsLL = IsLNode(LeftNId), IsLR = IsRNode(LeftNId);
 
  742   const bool IsRL = IsLNode(RightNId), IsRR = IsRNode(RightNId);
 
  743   IAssertR((IsLL||IsLR)&&(IsRL||IsRR), 
TStr::Fmt(
"%d or %d is not a node.", LeftNId, RightNId).CStr());
 
  744   IAssertR(LeftNId!=RightNId, 
"No self-edges are allowed."); 
 
  745   IAssertR((IsLL&&!IsLR&&!IsRL&&IsRR)||(!IsLL&&IsLR&&IsRL&&!IsRR), 
"One node should be on the 'left' and the other on the 'right'.");
 
  746   const int LNId = IsLL ? LeftNId : RightNId; 
 
  747   const int RNId = IsLL ? RightNId : LeftNId; 
 
  749   const int NodeN = SrcNI.
LeftHI.GetDat().NIdV.SearchBin(RNId);
 
  750   IAssertR(NodeN != -1, 
"Right edge endpoint does not exists!");
 
  757     return GetRndLNId(Rnd); }
 
  759     return GetRndRNId(Rnd); }
 
  763   return LeftH.GetKey(LeftH.GetRndKeyId(Rnd, 0.8)); 
 
  767   return RightH.GetKey(RightH.GetRndKeyId(Rnd, 0.8)); 
 
  772   for (
int N=LeftH.FFirstKeyId(); LeftH.FNextKeyId(N); ) {
 
  773     NIdV.
Add(LeftH.GetKey(N)); }
 
  774   for (
int N=RightH.FFirstKeyId(); RightH.FNextKeyId(N); ) {
 
  775     NIdV.
Add(RightH.GetKey(N)); }
 
  779   NIdV.
Gen(GetLNodes(), 0);
 
  780   for (
int N=LeftH.FFirstKeyId(); LeftH.FNextKeyId(N); ) {
 
  781     NIdV.
Add(LeftH.GetKey(N)); }
 
  785   NIdV.
Gen(GetRNodes(), 0);
 
  786   for (
int N=RightH.FFirstKeyId(); RightH.FNextKeyId(N); ) {
 
  787     NIdV.
Add(RightH.GetKey(N)); }
 
  791   if (Nodes>0) { LeftH.Gen(Nodes/2); RightH.Gen(Nodes/2); } 
 
  795   for (
int n = LeftH.FFirstKeyId(); LeftH.FNextKeyId(n); ) {
 
  796     LeftH[n].NIdV.Pack(); }
 
  797   for (
int n = RightH.FFirstKeyId(); RightH.FNextKeyId(n); ) {
 
  798     RightH[n].NIdV.Pack(); }
 
  799   if (! OnlyNodeLinks && ! LeftH.IsKeyIdEqKeyN()) { LeftH.Defrag(); }
 
  800   if (! OnlyNodeLinks && ! RightH.IsKeyIdEqKeyN()) { RightH.Defrag(); }
 
  806   for (
int n = LeftH.FFirstKeyId(); LeftH.FNextKeyId(n); ) {
 
  807     if (! LeftH[n].NIdV.IsSorted()) {
 
  808       const TStr Msg = 
TStr::Fmt(
"Neighbor list of node %d is not sorted.", LeftH[n].GetId());
 
  811   for (
int n = RightH.FFirstKeyId(); RightH.FNextKeyId(n); ) {
 
  812     if (! RightH[n].NIdV.IsSorted()) {
 
  813       const TStr Msg = 
TStr::Fmt(
"Neighbor list of node %d is not sorted.", RightH[n].GetId());
 
  817   for (
int n = LeftH.FFirstKeyId(); LeftH.FNextKeyId(n); ) {
 
  818     if (RightH.IsKey(LeftH[n].GetId())) {
 
  819       const TStr Msg = 
TStr::Fmt(
"'Left' node %d also appears on the 'right'.", LeftH[n].GetId());
 
  822   for (
int n = RightH.FFirstKeyId(); RightH.FNextKeyId(n); ) {
 
  823     if (LeftH.IsKey(RightH[n].GetId())) {
 
  824       const TStr Msg = 
TStr::Fmt(
"'Right' node %d also appears on the 'left'.", RightH[n].GetId());
 
  828   for (
int n = LeftH.FFirstKeyId(); LeftH.FNextKeyId(n); ) {
 
  829     for (
int e = 0; e < LeftH[n].NIdV.Len(); e++) {
 
  830       if (! RightH.IsKey(LeftH[n].NIdV[e]) || ! RightH.GetDat(LeftH[n].NIdV[e]).NIdV.IsIn(LeftH[n].GetId())) {
 
  831         const TStr Msg = 
TStr::Fmt(
"'Left' node %d does not point to the 'right' node %d.", LeftH[n].GetId(), LeftH[n].NIdV[e]());
 
  835   for (
int n = RightH.FFirstKeyId(); RightH.FNextKeyId(n); ) {
 
  836     for (
int e = 0; e < RightH[n].NIdV.Len(); e++) {
 
  837       if (! LeftH.IsKey(RightH[n].NIdV[e]) || ! LeftH.GetDat(RightH[n].NIdV[e]).NIdV.IsIn(RightH[n].GetId())) {
 
  838         const TStr Msg = 
TStr::Fmt(
"'Left' node %d does not point to the 'right' node %d.", RightH[n].GetId(), RightH[n].NIdV[e]());
 
  846   const int NodePlaces = (int) ceil(log10((
double) 
GetNodes()));
 
  847   fprintf(OutF, 
"-------------------------------------------------\nBipartite Graph: nodes: %d+%d=%d, edges: %d\n", GetLNodes(), GetRNodes(), 
GetNodes(), 
GetEdges());
 
  848   for (
int N = LeftH.FFirstKeyId(); LeftH.FNextKeyId(N); ) {
 
  849     const TNode& Node = LeftH[N];
 
  850     fprintf(OutF, 
"  %*d [%d] ", NodePlaces, Node.
GetId(), Node.
GetDeg());
 
  870   BP->AddNode(0, 
true);
 
  871   BP->AddNode(1, 
true);
 
  872   BP->AddNode(2, 
false);
 
  873   BP->AddNode(3, 
false);
 
  874   BP->AddNode(4, 
false);
 
bool HasFlag(const TGraphFlag &Flag) const 
Allows for run-time checking the type of the graph (see the TGraphFlag for flags). 
 
static PBPGraph GetSmallGraph()
Returns a small graph on 2 'left', 3 'right' nodes and 4 edges. 
 
static const T & Mn(const T &LVal, const T &RVal)
 
Edge iterator. Only forward iteration (operator++) is supported. 
 
bool DelIfIn(const TVal &Val)
Removes the first occurrence of element Val. 
 
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a biparite graph of Nodes nodes and Edges edges. 
 
bool IsKeyIdEqKeyN() const 
 
void GetNIdV(TIntV &NIdV) const 
Gets a vector IDs of all nodes in the graph. 
 
#define IAssertR(Cond, Reason)
 
bool IsInNId(const int &NId) const 
Tests whether node with ID NId points to the current node. 
 
void DelNode(const int &NId)
Deletes node of ID NId from the graph. 
 
int AddEdge(const int &SrcNId, const int &DstNId, int EId=-1)
Adds an edge with ID EId between node IDs SrcNId and DstNId to the graph. 
 
bool IsOk(const bool &ThrowExcept=true) const 
Checks the graph data structure for internal consistency. 
 
TEdgeI EndEI() const 
Returns an iterator referring to the past-the-end edge in the graph. 
 
void GetRNIdV(TIntV &NIdV) const 
Gets a vector IDs of all 'right' nodes in the bipartite graph. 
 
static PUNGraph GetSmallGraph()
Returns a small graph on 5 nodes and 5 edges. 
 
void Del(const TSizeTy &ValN)
Removes the element at position ValN. 
 
TNode & GetNode(const int &NId)
 
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the graph. 
 
void Dump(FILE *OutF=stdout) const 
Print the graph in a human readable form to an output stream OutF. 
 
static const T & Mx(const T &LVal, const T &RVal)
 
static PNGraph New()
Static constructor that returns a pointer to the graph. Call: PNGraph Graph = TNGraph::New(). 
 
TNodeI GetNI(const int &NId) const 
Returns an iterator referring to the node of ID NId in the graph. 
 
TEdgeI BegEI() const 
Returns an iterator referring to the first edge in the graph. 
 
void GetNIdV(TIntV &NIdV) const 
Gets a vector IDs of all nodes in the graph. 
 
int GetNbrNId(const int &NodeN) const 
 
int GetEdges() const 
Returns the number of edges in the graph. 
 
Node iterator. Only forward iteration (operator++) is supported. 
 
int AddNode(int NId=-1)
Adds a node of ID NId to the graph. 
 
THash< TInt, TNode > NodeH
 
int GetEdges() const 
Returns the number of edges in the graph. 
 
TSizeTy Len() const 
Returns the number of elements in the vector. 
 
Node iterator. Only forward iteration (operator++) is supported. 
 
int AddEdgeUnchecked(const int &SrcNId, const int &DstNId)
Adds an edge from node SrcNId to node DstNId to the graph. 
 
void GenExt(TVal *_ValT, const TSizeTy &_Vals)
Constructs a vector of _Vals elements of memory array _ValT. 
 
bool IsOk(const bool &ThrowExcept=true) const 
Checks the graph data structure for internal consistency. 
 
int GetOutEId(const int &EdgeN) const 
 
int AddNode(int NId=-1, const bool &LeftNode=true)
Adds a node of ID NId to the graph. 
 
TEdgeI EndEI() const 
Returns an iterator referring to the past-the-end edge in the graph. 
 
int GetNodes() const 
Returns the number of nodes in the graph. 
 
int AddNode(int NId=-1)
Adds a node of ID NId to the graph. 
 
void Dump(FILE *OutF=stdout) const 
Print the graph in a human readable form to an output stream OutF. 
 
Edge iterator. Only forward iteration (operator++) is supported. 
 
const TDat & GetDat(const TKey &Key) const 
 
int GetRndLNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random 'left' node in the graph. 
 
TNodeI BegNI() const 
Returns an iterator referring to the first node in the graph. 
 
int GetNodes() const 
Returns the number of nodes 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)
 
THash< TInt, TNode > NodeH
 
TNode & GetNode(const int &NId)
 
int GetOutNId(const int &NodeN) const 
 
THash< TInt, TEdge > EdgeH
 
void DelNode(const int &NId)
Deletes node of ID NId from the graph. 
 
TNodeI EndNI() const 
Returns an iterator referring to the past-the-end node in the graph. 
 
TEdgeI GetEI(const int &EId) const 
Not supported/implemented! 
 
int GetInEId(const int &EdgeN) const 
 
TNodeI GetNI(const int &NId) const 
Returns an iterator referring to the node of ID NId in the graph. 
 
void DelKey(const TKey &Key)
 
void GetNIdV(TIntV &NIdV) const 
Gets a vector IDs of all nodes in the graph. 
 
int GetNodes() const 
Returns the number of nodes in the graph. 
 
TEdge & GetEdge(const int &EId)
 
bool IsOutNId(const int &NId) const 
Tests whether the current node points to node with ID NId. 
 
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). ...
 
Edge iterator. Only forward iteration (operator++) is supported. 
 
int GetEdges() const 
Returns the number of edges in the graph. 
 
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node SrcNId to node DstNId to the graph. 
 
static PNEGraph GetSmallGraph()
Returns a small multigraph on 5 nodes and 6 edges. 
 
int GetVLen(const int &VId) const 
Returns the number of elements in the vector with id VId. 
 
void DelEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true)
Deletes an edge from node IDs SrcNId to DstNId from the graph. 
 
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. 
 
const TVal & GetDat(const TVal &Val) const 
Returns reference to the first occurrence of element Val. 
 
TNodeI GetNI(const int &NId) const 
Returns an iterator referring to the node of ID NId in the graph. 
 
bool HasFlag(const TGraphFlag &Flag) const 
Allows for run-time checking the type of the graph (see the TGraphFlag for flags). 
 
bool FNextKeyId(int &KeyId) const 
 
bool IsNode(const int &NId) const 
Tests whether ID NId is a node. 
 
bool IsEdge(const int &LeftNId, const int &RightNId) const 
Tests whether an edge between node IDs LeftNId and RightNId exists in the graph. 
 
TEdgeI BegEI() const 
Returns an iterator referring to the first edge in the graph. 
 
void GetLNIdV(TIntV &NIdV) const 
Gets a vector IDs of all 'left' nodes in the bipartite graph. 
 
static PUNGraph New()
Static constructor that returns a pointer to the graph. Call: PUNGraph Graph = TUNGraph::New(). 
 
int GetOutNId(const int &NodeN) const 
 
int AddNode(int NId=-1)
Adds a node of ID NId to the graph. 
 
void DelEdge(const int &SrcNId, const int &DstNId)
Deletes an edge between node IDs SrcNId and DstNId from the graph. 
 
int AddNodeUnchecked(int NId=-1)
Adds a node of ID NId to the network, noop if the node already exists. 
 
void Dump(FILE *OutF=stdout) const 
Print the graph in a human readable form to an output stream OutF. 
 
TSizeTy SearchBin(const TVal &Val) const 
Returns the position of an element with value Val. 
 
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the graph. 
 
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge between node IDs SrcNId and DstNId to the graph. 
 
TNode & GetNode(const int &NId)
 
static PNEGraph New()
Static constructor that returns a pointer to the graph. Call: PNEGraph Graph = TNEGraph::New(). 
 
int AddEdge(const int &LeftNId, const int &RightNId)
Adds an edge between a node LeftNId on the left and a node RightNId on the right side of the bipartit...
 
void DelEdge(const int &LeftNId, const int &RightNId)
Deletes an edge between a node LeftNId on the left and a node RightNId on the right side of the bipar...
 
bool IsNbrNId(const int &NId) const 
 
int GetNbrNId(const int &NodeN) const 
 
void DelNode(const int &NId)
Deletes node of ID NId from the graph. 
 
bool IsEdge(const int &EId) const 
Tests whether an edge with edge ID EId exists in the graph. 
 
TNodeI EndNI() const 
Returns an iterator referring to the past-the-end node in the graph. 
 
static PNGraph GetSmallGraph()
Returns a small graph on 5 nodes and 6 edges. 
 
int GetRndRNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random 'right' node in the graph. 
 
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. 
 
THash< TInt, TNode > NodeH
 
void GetEIdV(TIntV &EIdV) const 
Gets a vector IDs of all edges 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. 
 
int GetEdges() const 
Returns the number of edges in the graph. 
 
Node iterator. Only forward iteration (operator++) is supported. 
 
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the graph. 
 
#define EAssertR(Cond, MsgStr)
 
TNodeI EndNI() const 
Returns an iterator referring to the past-the-end node in the graph. 
 
static PBPGraph New()
Static constructor that returns a pointer to the graph. Call: PBPGraph BPGraph = TBPGraph::New();. 
 
bool IsNode(const int &NId) const 
Tests whether ID NId is a node. 
 
#define AssertR(Cond, Reason)
 
bool HasFlag(const TGraphFlag &Flag) const 
Allows for run-time checking the type of the graph (see the TGraphFlag for flags). 
 
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements. 
 
void GetNIdV(TIntV &NIdV) const 
Gets a vector IDs of all nodes in the bipartite graph. 
 
int GetUniDevInt(const int &Range=0)
 
bool IsOk(const bool &ThrowExcept=true) const 
Checks the graph data structure for internal consistency. 
 
int AddNodeUnchecked(int NId=-1)
Adds a node of ID NId to the network, noop if the node already exists. 
 
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the graph. 
 
void Dump(FILE *OutF=stdout) const 
Print the biparite graph in a human readable form to an output stream OutF. 
 
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the biparite graph. 
 
bool IsEdge(const int &SrcNId, const int &DstNId) const 
Tests whether an edge between node IDs SrcNId and DstNId exists in the graph. 
 
void DelEdge(const int &EId)
Deletes an edge with edge ID EId from the graph. 
 
TEdgeI GetEI(const int &EId) const 
Not supported/implemented! 
 
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element. 
 
int GetInNId(const int &NodeN) const 
 
bool IsOutNId(const int &NId) const 
 
TDat & AddDat(const TKey &Key)
 
bool IsOk(const bool &ThrowExcept=true) const 
Checks the bipartite graph data structure for internal consistency. 
 
void DelNode(const int &NId)
Deletes node of ID NId from the graph. 
 
Edge iterator. Only forward iteration (operator++) is supported. 
 
Node iterator. Only forward iteration (operator++) is supported. 
 
int AddEdge2(const int &SrcNId, const int &DstNId)
Adds an edge from node IDs SrcNId to node DstNId to the graph. If nodes do not exist, create them. 
 
const TKey & GetKey(const int &KeyId) const 
 
TEdgeI GetEI(const int &EId) const 
Not supported/implemented! 
 
bool IsNode(const int &NId) const 
Tests whether ID NId is a node. 
 
int AddEdgeUnchecked(const int &SrcNId, const int &DstNId)
Adds an edge between node IDs SrcNId and DstNId to the graph.