34 for (
int i = 0; i < NbrNIdV.
Len(); i++) {
63 for (
int e = 0; e < Node.
GetDeg(); e++) {
65 if (nbr == NId) {
continue; }
86 if (
IsEdge(SrcNId, DstNId)) {
return -2; }
100 if (SrcNId != DstNId) {
115 const int MnNId =
TMath::Mn(SrcNId, DstNId);
118 const int NodeN = SrcNI.
NodeHI.GetDat().NIdV.SearchBin(MxNId);
152 for (
int e = 0; e < Node.
GetDeg(); e++) {
154 const TStr Msg =
TStr::Fmt(
"Edge %d --> %d: node %d does not exist.",
159 if (e > 0 && prevNId == Node.
GetNbrNId(e)) {
160 const TStr Msg =
TStr::Fmt(
"Node %d has duplicate edge %d --> %d.",
171 const TStr Msg =
TStr::Fmt(
"Number of edges counter is corrupted: GetEdges():%d, EdgeCount:%d.",
GetEdges(), EdgeCnt);
180 const int NodePlaces = (int) ceil(log10((
double)
GetNodes()));
181 fprintf(OutF,
"-------------------------------------------------\nUndirected Node Graph: nodes: %d, edges: %d\n",
GetNodes(),
GetEdges());
184 fprintf(OutF,
" %*d [%d] ", NodePlaces, Node.
GetId(), Node.
GetDeg());
185 for (
int edge = 0; edge < Node.
GetDeg(); edge++) {
186 fprintf(OutF,
" %*d", NodePlaces, Node.
GetNbrNId(edge)); }
195 for (
int i = 0; i < 5; i++) { Graph->
AddNode(i); }
261 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
263 if (nbr == NId) {
continue; }
268 for (
int e = 0; e < Node.
GetInDeg(); e++) {
270 if (nbr == NId) {
continue; }
281 edges+=
NodeH[N].GetOutDeg();
289 if (
IsEdge(SrcNId, DstNId)) {
return -2; }
314 if (!
IsNode(SrcNId) || !
IsNode(DstNId)) {
return false; }
321 const int NodeN = SrcNI.
NodeHI.GetDat().OutNIdV.SearchBin(DstNId);
346 const TStr Msg =
TStr::Fmt(
"Out-neighbor list of node %d is not sorted.", Node.
GetId());
350 const TStr Msg =
TStr::Fmt(
"In-neighbor list of node %d is not sorted.", Node.
GetId());
355 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
357 const TStr Msg =
TStr::Fmt(
"Out-edge %d --> %d: node %d does not exist.",
361 if (e > 0 && prevNId == Node.
GetOutNId(e)) {
362 const TStr Msg =
TStr::Fmt(
"Node %d has duplidate out-edge %d --> %d.",
370 for (
int e = 0; e < Node.
GetInDeg(); e++) {
372 const TStr Msg =
TStr::Fmt(
"In-edge %d <-- %d: node %d does not exist.",
376 if (e > 0 && prevNId == Node.
GetInNId(e)) {
377 const TStr Msg =
TStr::Fmt(
"Node %d has duplidate in-edge %d <-- %d.",
388 const int NodePlaces = (int) ceil(log10((
double)
GetNodes()));
389 fprintf(OutF,
"-------------------------------------------------\nDirected Node Graph: nodes: %d, edges: %d\n",
GetNodes(),
GetEdges());
392 fprintf(OutF,
" %*d]\n", NodePlaces, Node.
GetId());
393 fprintf(OutF,
" in [%d]", Node.
GetInDeg());
394 for (
int edge = 0; edge < Node.
GetInDeg(); edge++) {
395 fprintf(OutF,
" %*d", NodePlaces, Node.
GetInNId(edge)); }
396 fprintf(OutF,
"\n out[%d]", Node.
GetOutDeg());
397 for (
int edge = 0; edge < Node.
GetOutDeg(); edge++) {
398 fprintf(OutF,
" %*d", NodePlaces, Node.
GetOutNId(edge)); }
406 for (
int i = 0; i < 5; i++) { G->
AddNode(i); }
420 for (
int edge = 0; edge < Node.
GetInDeg(); edge++) {
428 const TNode& Node = NodeHI.GetDat();
429 for (
int edge = 0; edge < Node.
GetOutDeg(); edge++) {
430 if (NId == Graph->GetEdge(Node.
GetOutEId(edge)).GetDstNId())
449 for (
int out = 0; out < Node.
GetOutDeg(); out++) {
456 for (
int in = 0; in < Node.
GetInDeg(); in++) {
490 while (
IsEdge(SrcNId, DstNId, EId, IsDir)) {
497 bool TNEGraph::IsEdge(
const int& SrcNId,
const int& DstNId,
int& EId,
const bool& IsDir)
const {
499 for (
int edge = 0; edge < SrcNode.
GetOutDeg(); edge++) {
502 EId = Edge.
GetId();
return true; }
505 for (
int edge = 0; edge < SrcNode.
GetInDeg(); edge++) {
508 EId = Edge.
GetId();
return true; }
550 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
555 if (e > 0 && prevEId == Node.
GetOutEId(e)) {
563 for (
int e = 0; e < Node.
GetInDeg(); e++) {
568 if (e > 0 && prevEId == Node.
GetInEId(e)) {
590 const int NodePlaces = (int) ceil(log10((
double)
GetNodes()));
591 const int EdgePlaces = (int) ceil(log10((
double)
GetEdges()));
592 fprintf(OutF,
"-------------------------------------------------\nDirected Node-Edge Graph: nodes: %d, edges: %d\n",
GetNodes(),
GetEdges());
594 fprintf(OutF,
" %*d]\n", NodePlaces, NodeI.GetId());
595 fprintf(OutF,
" in[%d]", NodeI.GetInDeg());
596 for (
int edge = 0; edge < NodeI.GetInDeg(); edge++) {
597 fprintf(OutF,
" %*d", EdgePlaces, NodeI.GetInEId(edge)); }
598 fprintf(OutF,
"\n out[%d]", NodeI.GetOutDeg());
599 for (
int edge = 0; edge < NodeI.GetOutDeg(); edge++) {
600 fprintf(OutF,
" %*d", EdgePlaces, NodeI.GetOutEId(edge)); }
604 fprintf(OutF,
" %*d] %*d -> %*d\n", EdgePlaces, EdgeI.GetId(), NodePlaces, EdgeI.GetSrcNId(), NodePlaces, EdgeI.GetDstNId());
612 for (
int i = 0; i < 5; i++) { Graph->AddNode(i); }
613 Graph->AddEdge(0,1); Graph->AddEdge(0,2);
614 Graph->AddEdge(0,3); Graph->AddEdge(0,4);
615 Graph->AddEdge(1,2); Graph->AddEdge(1,2);
623 else if (IsLNode(NId)) {
IAssertR(LeftNode,
TStr::Fmt(
"Node with id %s already exists on the 'left'.", NId));
return NId; }
624 else if (IsRNode(NId)) {
IAssertR(! LeftNode,
TStr::Fmt(
"Node with id %s already exists on the 'right'.", NId));
return NId; }
626 if (LeftNode) { LeftH.AddDat(NId,
TNode(NId)); }
627 else { RightH.AddDat(NId,
TNode(NId)); }
637 for (
int e = 0; e < Node.
GetOutDeg(); e++) {
639 IAssertR(nbr != NId,
"Bipartite graph has a loop!");
650 for (
int N=LeftH.FFirstKeyId(); LeftH.FNextKeyId(N); ) {
651 Edges += LeftH[N].GetDeg(); }
656 const bool IsLL = IsLNode(LeftNId), IsLR = IsRNode(LeftNId);
657 const bool IsRL = IsLNode(RightNId), IsRR = IsRNode(RightNId);
658 IAssertR((IsLL||IsLR)&&(IsRL||IsRR),
TStr::Fmt(
"%d or %d is not a node.", LeftNId, RightNId).CStr());
659 IAssertR(LeftNId!=RightNId,
"No self-edges are allowed.");
660 IAssertR((IsLL&&!IsLR&&!IsRL&&IsRR)||(!IsLL&&IsLR&&IsRL&&!IsRR),
"One node should be on the 'left' and the other on the 'right'.");
661 const int LNId = IsLL ? LeftNId : RightNId;
662 const int RNId = IsLL ? RightNId : LeftNId;
663 if (LeftH.GetDat(LNId).IsOutNId(RNId)) {
return -2; }
664 LeftH.GetDat(LNId).NIdV.AddSorted(RNId);
665 RightH.GetDat(RNId).NIdV.AddSorted(LNId);
670 const bool IsLL = IsLNode(LeftNId), IsLR = IsRNode(LeftNId);
671 const bool IsRL = IsLNode(RightNId), IsRR = IsRNode(RightNId);
672 IAssertR((IsLL||IsLR)&&(IsRL||IsRR),
TStr::Fmt(
"%d or %d is not a node.", LeftNId, RightNId).CStr());
673 IAssertR(LeftNId!=RightNId,
"No self-edges are allowed.");
674 IAssertR((IsLL&&!IsLR&&!IsRL&&IsRR)||(!IsLL&&IsLR&&IsRL&&!IsRR),
"One node should be on the 'left' and the other on the 'right'.");
675 const int LNId = IsLL ? LeftNId : RightNId;
676 const int RNId = IsLL ? RightNId : LeftNId;
679 if (n != -1) { NIdV.
Del(n); } }
682 if (n != -1) { NIdV.
Del(n); } }
686 if (!
IsNode(LeftNId) || !
IsNode(RightNId)) {
return false; }
687 return IsLNode(LeftNId) ? LeftH.GetDat(LeftNId).IsOutNId(RightNId) : RightH.GetDat(LeftNId).IsOutNId(RightNId);
691 const bool IsLL = IsLNode(LeftNId), IsLR = IsRNode(LeftNId);
692 const bool IsRL = IsLNode(RightNId), IsRR = IsRNode(RightNId);
693 IAssertR((IsLL||IsLR)&&(IsRL||IsRR),
TStr::Fmt(
"%d or %d is not a node.", LeftNId, RightNId).CStr());
694 IAssertR(LeftNId!=RightNId,
"No self-edges are allowed.");
695 IAssertR((IsLL&&!IsLR&&!IsRL&&IsRR)||(!IsLL&&IsLR&&IsRL&&!IsRR),
"One node should be on the 'left' and the other on the 'right'.");
696 const int LNId = IsLL ? LeftNId : RightNId;
697 const int RNId = IsLL ? RightNId : LeftNId;
699 const int NodeN = SrcNI.
LeftHI.GetDat().NIdV.SearchBin(RNId);
700 IAssertR(NodeN != -1,
"Right edge endpoint does not exists!");
707 return GetRndLNId(Rnd); }
709 return GetRndRNId(Rnd); }
713 return LeftH.GetKey(LeftH.GetRndKeyId(Rnd, 0.8));
717 return RightH.GetKey(RightH.GetRndKeyId(Rnd, 0.8));
722 for (
int N=LeftH.FFirstKeyId(); LeftH.FNextKeyId(N); ) {
723 NIdV.
Add(LeftH.GetKey(N)); }
724 for (
int N=RightH.FFirstKeyId(); RightH.FNextKeyId(N); ) {
725 NIdV.
Add(RightH.GetKey(N)); }
729 NIdV.
Gen(GetLNodes(), 0);
730 for (
int N=LeftH.FFirstKeyId(); LeftH.FNextKeyId(N); ) {
731 NIdV.
Add(LeftH.GetKey(N)); }
735 NIdV.
Gen(GetRNodes(), 0);
736 for (
int N=RightH.FFirstKeyId(); RightH.FNextKeyId(N); ) {
737 NIdV.
Add(RightH.GetKey(N)); }
741 if (Nodes>0) { LeftH.Gen(Nodes/2); RightH.Gen(Nodes/2); }
745 for (
int n = LeftH.FFirstKeyId(); LeftH.FNextKeyId(n); ) {
746 LeftH[n].NIdV.Pack(); }
747 for (
int n = RightH.FFirstKeyId(); RightH.FNextKeyId(n); ) {
748 RightH[n].NIdV.Pack(); }
749 if (! OnlyNodeLinks && ! LeftH.IsKeyIdEqKeyN()) { LeftH.Defrag(); }
750 if (! OnlyNodeLinks && ! RightH.IsKeyIdEqKeyN()) { RightH.Defrag(); }
756 for (
int n = LeftH.FFirstKeyId(); LeftH.FNextKeyId(n); ) {
757 if (! LeftH[n].NIdV.IsSorted()) {
758 const TStr Msg =
TStr::Fmt(
"Neighbor list of node %d is not sorted.", LeftH[n].GetId());
761 for (
int n = RightH.FFirstKeyId(); RightH.FNextKeyId(n); ) {
762 if (! RightH[n].NIdV.IsSorted()) {
763 const TStr Msg =
TStr::Fmt(
"Neighbor list of node %d is not sorted.", RightH[n].GetId());
767 for (
int n = LeftH.FFirstKeyId(); LeftH.FNextKeyId(n); ) {
768 if (RightH.IsKey(LeftH[n].GetId())) {
769 const TStr Msg =
TStr::Fmt(
"'Left' node %d also appears on the 'right'.", LeftH[n].GetId());
772 for (
int n = RightH.FFirstKeyId(); RightH.FNextKeyId(n); ) {
773 if (LeftH.IsKey(RightH[n].GetId())) {
774 const TStr Msg =
TStr::Fmt(
"'Right' node %d also appears on the 'left'.", RightH[n].GetId());
778 for (
int n = LeftH.FFirstKeyId(); LeftH.FNextKeyId(n); ) {
779 for (
int e = 0; e < LeftH[n].NIdV.Len(); e++) {
780 if (! RightH.IsKey(LeftH[n].NIdV[e]) || ! RightH.GetDat(LeftH[n].NIdV[e]).NIdV.IsIn(LeftH[n].GetId())) {
781 const TStr Msg =
TStr::Fmt(
"'Left' node %d does not point to the 'right' node %d.", LeftH[n].GetId(), LeftH[n].NIdV[e]());
785 for (
int n = RightH.FFirstKeyId(); RightH.FNextKeyId(n); ) {
786 for (
int e = 0; e < RightH[n].NIdV.Len(); e++) {
787 if (! LeftH.IsKey(RightH[n].NIdV[e]) || ! LeftH.GetDat(RightH[n].NIdV[e]).NIdV.IsIn(RightH[n].GetId())) {
788 const TStr Msg =
TStr::Fmt(
"'Left' node %d does not point to the 'right' node %d.", RightH[n].GetId(), RightH[n].NIdV[e]());
796 const int NodePlaces = (int) ceil(log10((
double)
GetNodes()));
797 fprintf(OutF,
"-------------------------------------------------\nBipartite Graph: nodes: %d+%d=%d, edges: %d\n", GetLNodes(), GetRNodes(),
GetNodes(),
GetEdges());
798 for (
int N = LeftH.FFirstKeyId(); LeftH.FNextKeyId(N); ) {
799 const TNode& Node = LeftH[N];
800 fprintf(OutF,
" %*d [%d] ", NodePlaces, Node.
GetId(), Node.
GetDeg());
801 for (
int edge = 0; edge < Node.
GetDeg(); edge++) {
802 fprintf(OutF,
" %*d", NodePlaces, Node.
GetNbrNId(edge)); }
820 BP->AddNode(0,
true);
821 BP->AddNode(1,
true);
822 BP->AddNode(2,
false);
823 BP->AddNode(3,
false);
824 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.
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 IDs 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.
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.
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()
The vector reduces its 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.
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.
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.