SNAP Library 4.1, Developer Reference  2018-07-26 16:30:42
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TNEGraph Class Reference

Directed multigraph. More...

#include <graph.h>

Collaboration diagram for TNEGraph:

Classes

class  TEdge
 
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 TNEGraph TNet
 
typedef TPt< TNEGraphPNet
 

Public Member Functions

 TNEGraph ()
 
 TNEGraph (const int &Nodes, const int &Edges)
 Constructor that reserves enough memory for a graph of Nodes nodes and Edges edges. More...
 
 TNEGraph (const TNEGraph &Graph)
 
 TNEGraph (TSIn &SIn)
 Constructor for loading 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...
 
TNEGraphoperator= (const TNEGraph &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 AddNode (const TNodeI &NodeId)
 Adds a node of ID NodeI.GetId() to the graph. 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, int EId=-1)
 Adds an edge with ID EId between node IDs SrcNId and DstNId to the graph. More...
 
int AddEdge (const TEdgeI &EdgeI)
 Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph. More...
 
void DelEdge (const int &EId)
 Deletes an edge with edge ID EId from the graph. More...
 
void DelEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true)
 Deletes all edges between node IDs SrcNId and DstNId from the graph. More...
 
bool IsEdge (const int &EId) const
 Tests whether an edge with edge ID EId exists in the graph. More...
 
bool IsEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true) const
 Tests whether an edge between node IDs SrcNId and DstNId exists in the graph. More...
 
bool IsEdge (const int &SrcNId, const int &DstNId, int &EId, const bool &IsDir=true) const
 Tests whether an edge between node IDs SrcNId and DstNId exists in the graph. if an edge exists, return its edge ID in EId. More...
 
int GetEId (const int &SrcNId, const int &DstNId) const
 Returns an edge ID between node IDs SrcNId and DstNId, if such an edge exists. Otherwise, return -1. 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
 Returns an iterator referring to edge with edge ID EId. 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...
 
int GetRndEId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random edge in the graph. More...
 
TEdgeI GetRndEI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random edge in the graph. More...
 
void GetNIdV (TIntV &NIdV) const
 Gets a vector IDs of all nodes in the graph. More...
 
void GetEIdV (TIntV &EIdV) const
 Gets a vector IDs of all edges 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 Reserve (const int &Nodes, const int &Edges)
 Reserves memory for a graph of Nodes nodes and Edges 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 PNEGraph New ()
 Static constructor that returns a pointer to the graph. Call: PNEGraph Graph = TNEGraph::New(). More...
 
static PNEGraph 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 PNEGraph Load (TSIn &SIn)
 Static constructor that loads the graph from a stream SIn and returns a pointer to it. More...
 
static PNEGraph GetSmallGraph ()
 Returns a small multigraph on 5 nodes and 6 edges. More...
 

Private Member Functions

TNodeGetNode (const int &NId)
 
const TNodeGetNode (const int &NId) const
 
TEdgeGetEdge (const int &EId)
 
const TEdgeGetEdge (const int &EId) const
 

Private Attributes

TCRef CRef
 
TInt MxNId
 
TInt MxEId
 
THash< TInt, TNodeNodeH
 
THash< TInt, TEdgeEdgeH
 

Friends

class TPt< TNEGraph >
 

Detailed Description

Directed multigraph.

Node IDs can be arbitrary non-negative integers. Edges have IDs. Nodes and edges have no attributes/data associated with them. There can be more than one directed edge from one source node to a destination node. Self loops (one per node) are allowed as well as multiple (parallel) edges. The directed multigraph 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.

Definition at line 657 of file graph.h.

Member Typedef Documentation

Definition at line 660 of file graph.h.

Definition at line 659 of file graph.h.

Constructor & Destructor Documentation

TNEGraph::TNEGraph ( )
inline

Definition at line 792 of file graph.h.

Referenced by Load(), and New().

792 : CRef(), MxNId(0), MxEId(0) { }
TCRef CRef
Definition: graph.h:787
TInt MxNId
Definition: graph.h:788
TInt MxEId
Definition: graph.h:788

Here is the caller graph for this function:

TNEGraph::TNEGraph ( const int &  Nodes,
const int &  Edges 
)
inlineexplicit

Constructor that reserves enough memory for a graph of Nodes nodes and Edges edges.

Definition at line 794 of file graph.h.

References Reserve().

794 : CRef(), MxNId(0), MxEId(0) { Reserve(Nodes, Edges); }
TCRef CRef
Definition: graph.h:787
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a graph of Nodes nodes and Edges edges.
Definition: graph.h:894
TInt MxNId
Definition: graph.h:788
TInt MxEId
Definition: graph.h:788

Here is the call graph for this function:

TNEGraph::TNEGraph ( const TNEGraph Graph)
inline

Definition at line 795 of file graph.h.

795 : MxNId(Graph.MxNId), MxEId(Graph.MxEId), NodeH(Graph.NodeH), EdgeH(Graph.EdgeH) { }
THash< TInt, TNode > NodeH
Definition: graph.h:789
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
TInt MxNId
Definition: graph.h:788
TInt MxEId
Definition: graph.h:788
TNEGraph::TNEGraph ( TSIn SIn)
inline

Constructor for loading the graph from a (binary) stream SIn.

Definition at line 797 of file graph.h.

797 : MxNId(SIn), MxEId(SIn), NodeH(SIn), EdgeH(SIn) { }
THash< TInt, TNode > NodeH
Definition: graph.h:789
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
TInt MxNId
Definition: graph.h:788
TInt MxEId
Definition: graph.h:788

Member Function Documentation

int TNEGraph::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.

Returns the ID of the edge being added. If EId is -1, edge ID is automatically assigned. Aborts, if an edge with ID EId already exists. Aborts, if SrcNId or DstNId are not nodes in the graph.

Definition at line 516 of file graph.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), TVec< TVal, TSizeTy >::AddSorted(), EdgeH, TStr::Fmt(), GetNode(), IAssertR, TNEGraph::TNode::InEIdV, IsEdge(), IsNode(), TMath::Mx(), MxEId, and TNEGraph::TNode::OutEIdV.

516  {
517  if (EId == -1) { EId = MxEId; MxEId++; }
518  else { MxEId = TMath::Mx(EId+1, MxEId()); }
519  IAssertR(!IsEdge(EId), TStr::Fmt("EdgeId %d already exists", EId));
520  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
521  EdgeH.AddDat(EId, TEdge(EId, SrcNId, DstNId));
522  GetNode(SrcNId).OutEIdV.AddSorted(EId);
523  GetNode(DstNId).InEIdV.AddSorted(EId);
524  return EId;
525 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
TSizeTy AddSorted(const TVal &Val, const bool &Asc=true, const TSizeTy &_MxVals=-1)
Adds element Val to a sorted vector.
Definition: ds.h:1117
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
TIntV OutEIdV
Definition: graph.h:665
TNode & GetNode(const int &NId)
Definition: graph.h:782
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: graph.h:860
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxEId
Definition: graph.h:788
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: graph.h:830
TIntV InEIdV
Definition: graph.h:665

Here is the call graph for this function:

int TNEGraph::AddEdge ( const TEdgeI EdgeI)
inline

Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph.

Definition at line 850 of file graph.h.

References AddEdge(), TNEGraph::TEdgeI::GetDstNId(), TNEGraph::TEdgeI::GetId(), and TNEGraph::TEdgeI::GetSrcNId().

Referenced by AddEdge().

850 { return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), EdgeI.GetId()); }
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.
Definition: graph.cpp:516

Here is the call graph for this function:

Here is the caller graph for this function:

int TNEGraph::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 486 of file graph.cpp.

References THash< TKey, TDat, THashFunc >::AddDat(), TStr::Fmt(), IAssertR, IsNode(), TMath::Mx(), MxNId, and NodeH.

486  {
487  if (NId == -1) {
488  NId = MxNId; MxNId++;
489  } else {
490  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
491  MxNId = TMath::Mx(NId+1, MxNId());
492  }
493  NodeH.AddDat(NId, TNode(NId));
494  return NId;
495 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
THash< TInt, TNode > NodeH
Definition: graph.h:789
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxNId
Definition: graph.h:788
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: graph.h:830

Here is the call graph for this function:

int TNEGraph::AddNode ( const TNodeI NodeId)
inline

Adds a node of ID NodeI.GetId() to the graph.

Definition at line 822 of file graph.h.

References AddNode(), and TNEGraph::TNodeI::GetId().

Referenced by AddNode().

822 { return AddNode(NodeId.GetId()); }
int AddNode(int NId=-1)
Adds a node of ID NId to the graph.
Definition: graph.cpp:486

Here is the call graph for this function:

Here is the caller graph for this function:

TEdgeI TNEGraph::BegEI ( ) const
inline

Returns an iterator referring to the first edge in the graph.

Definition at line 868 of file graph.h.

References THash< TKey, TDat, THashFunc >::BegI(), and EdgeH.

Referenced by Dump().

868 { return TEdgeI(EdgeH.BegI(), this); }
TIter BegI() const
Definition: hash.h:213
THash< TInt, TEdge > EdgeH
Definition: graph.h:790

Here is the call graph for this function:

Here is the caller graph for this function:

TNodeI TNEGraph::BegNI ( ) const
inline

Returns an iterator referring to the first node in the graph.

Definition at line 832 of file graph.h.

References THash< TKey, TDat, THashFunc >::BegI(), and NodeH.

Referenced by Dump().

832 { return TNodeI(NodeH.BegI(), this); }
TIter BegI() const
Definition: hash.h:213
THash< TInt, TNode > NodeH
Definition: graph.h:789

Here is the call graph for this function:

Here is the caller graph for this function:

void TNEGraph::Clr ( )
inline

Deletes all nodes and edges from the graph.

Definition at line 892 of file graph.h.

References THash< TKey, TDat, THashFunc >::Clr(), EdgeH, MxEId, MxNId, and NodeH.

892 { MxNId=0; MxEId=0; NodeH.Clr(); EdgeH.Clr(); }
THash< TInt, TNode > NodeH
Definition: graph.h:789
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:361
TInt MxNId
Definition: graph.h:788
TInt MxEId
Definition: graph.h:788

Here is the call graph for this function:

void TNEGraph::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 577 of file graph.cpp.

References THash< TKey, TDat, THashFunc >::Defrag(), EdgeH, THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TNEGraph::TNode::InEIdV, THash< TKey, TDat, THashFunc >::IsKeyIdEqKeyN(), NodeH, TNEGraph::TNode::OutEIdV, and TVec< TVal, TSizeTy >::Pack().

577  {
578  for (int kid = NodeH.FFirstKeyId(); NodeH.FNextKeyId(kid); ) {
579  TNode& Node = NodeH[kid];
580  Node.InEIdV.Pack(); Node.OutEIdV.Pack();
581  }
582  if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) { NodeH.Defrag(); }
583  if (! OnlyNodeLinks && ! EdgeH.IsKeyIdEqKeyN()) { EdgeH.Defrag(); }
584 }
bool IsKeyIdEqKeyN() const
Definition: hash.h:233
THash< TInt, TNode > NodeH
Definition: graph.h:789
void Defrag()
Definition: hash.h:555
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
int FFirstKeyId() const
Definition: hash.h:278
void Pack()
Definition: hash.h:289

Here is the call graph for this function:

void TNEGraph::DelEdge ( const int &  EId)

Deletes an edge with edge ID EId from the graph.

Definition at line 527 of file graph.cpp.

References TVec< TVal, TSizeTy >::DelIfIn(), THash< TKey, TDat, THashFunc >::DelKey(), EdgeH, TNEGraph::TEdge::GetDstNId(), GetEdge(), GetNode(), TNEGraph::TEdge::GetSrcNId(), IAssert, TNEGraph::TNode::InEIdV, IsEdge(), and TNEGraph::TNode::OutEIdV.

527  {
528  IAssert(IsEdge(EId));
529  const int SrcNId = GetEdge(EId).GetSrcNId();
530  const int DstNId = GetEdge(EId).GetDstNId();
531  GetNode(SrcNId).OutEIdV.DelIfIn(EId);
532  GetNode(DstNId).InEIdV.DelIfIn(EId);
533  EdgeH.DelKey(EId);
534 }
#define IAssert(Cond)
Definition: bd.h:262
bool DelIfIn(const TVal &Val)
Removes the first occurrence of element Val.
Definition: ds.h:1212
int GetSrcNId() const
Definition: graph.h:693
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
int GetDstNId() const
Definition: graph.h:694
void DelKey(const TKey &Key)
Definition: hash.h:404
TEdge & GetEdge(const int &EId)
Definition: graph.h:784
TIntV OutEIdV
Definition: graph.h:665
TNode & GetNode(const int &NId)
Definition: graph.h:782
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: graph.h:860
TIntV InEIdV
Definition: graph.h:665

Here is the call graph for this function:

void TNEGraph::DelEdge ( const int &  SrcNId,
const int &  DstNId,
const bool &  IsDir = true 
)

Deletes all edges 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 537 of file graph.cpp.

References TVec< TVal, TSizeTy >::DelIfIn(), THash< TKey, TDat, THashFunc >::DelKey(), EdgeH, GetNode(), IAssert, TNEGraph::TNode::InEIdV, IsEdge(), and TNEGraph::TNode::OutEIdV.

537  {
538  int EId;
539  IAssert(IsEdge(SrcNId, DstNId, EId, IsDir)); // there is at least one edge
540  while (IsEdge(SrcNId, DstNId, EId, IsDir)) {
541  GetNode(SrcNId).OutEIdV.DelIfIn(EId);
542  GetNode(DstNId).InEIdV.DelIfIn(EId);
543  }
544  EdgeH.DelKey(EId);
545 }
#define IAssert(Cond)
Definition: bd.h:262
bool DelIfIn(const TVal &Val)
Removes the first occurrence of element Val.
Definition: ds.h:1212
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
void DelKey(const TKey &Key)
Definition: hash.h:404
TIntV OutEIdV
Definition: graph.h:665
TNode & GetNode(const int &NId)
Definition: graph.h:782
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: graph.h:860
TIntV InEIdV
Definition: graph.h:665

Here is the call graph for this function:

void TNEGraph::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 497 of file graph.cpp.

References THash< TKey, TDat, THashFunc >::DelKey(), EdgeH, TNEGraph::TEdge::GetDstNId(), GetEdge(), TNEGraph::TNode::GetInDeg(), TNEGraph::TNode::GetInEId(), GetNode(), TNEGraph::TNode::GetOutDeg(), TNEGraph::TNode::GetOutEId(), TNEGraph::TEdge::GetSrcNId(), IAssert, and NodeH.

497  {
498  const TNode& Node = GetNode(NId);
499  for (int out = 0; out < Node.GetOutDeg(); out++) {
500  const int EId = Node.GetOutEId(out);
501  const TEdge& Edge = GetEdge(EId);
502  IAssert(Edge.GetSrcNId() == NId);
503  GetNode(Edge.GetDstNId()).InEIdV.DelIfIn(EId);
504  EdgeH.DelKey(EId);
505  }
506  for (int in = 0; in < Node.GetInDeg(); in++) {
507  const int EId = Node.GetInEId(in);
508  const TEdge& Edge = GetEdge(EId);
509  IAssert(Edge.GetDstNId() == NId);
510  GetNode(Edge.GetSrcNId()).OutEIdV.DelIfIn(EId);
511  EdgeH.DelKey(EId);
512  }
513  NodeH.DelKey(NId);
514 }
#define IAssert(Cond)
Definition: bd.h:262
THash< TInt, TNode > NodeH
Definition: graph.h:789
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
void DelKey(const TKey &Key)
Definition: hash.h:404
TEdge & GetEdge(const int &EId)
Definition: graph.h:784
TNode & GetNode(const int &NId)
Definition: graph.h:782

Here is the call graph for this function:

void TNEGraph::DelNode ( const TNode NodeI)
inline

Deletes node of ID NodeI.GetId() from the graph.

Definition at line 828 of file graph.h.

References DelNode(), and TNEGraph::TNode::GetId().

Referenced by DelNode().

828 { DelNode(NodeI.GetId()); }
void DelNode(const int &NId)
Deletes node of ID NId from the graph.
Definition: graph.cpp:497

Here is the call graph for this function:

Here is the caller graph for this function:

void TNEGraph::Dump ( FILE *  OutF = stdout) const

Print the graph in a human readable form to an output stream OutF.

Definition at line 639 of file graph.cpp.

References BegEI(), BegNI(), edge, EndEI(), EndNI(), GetEdges(), and GetNodes().

639  {
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());
643  for (TNodeI NodeI = BegNI(); NodeI < EndNI(); NodeI++) {
644  fprintf(OutF, " %*d]\n", NodePlaces, NodeI.GetId());
645  fprintf(OutF, " in[%d]", NodeI.GetInDeg());
646  for (int edge = 0; edge < NodeI.GetInDeg(); edge++) {
647  fprintf(OutF, " %*d", EdgePlaces, NodeI.GetInEId(edge)); }
648  fprintf(OutF, "\n out[%d]", NodeI.GetOutDeg());
649  for (int edge = 0; edge < NodeI.GetOutDeg(); edge++) {
650  fprintf(OutF, " %*d", EdgePlaces, NodeI.GetOutEId(edge)); }
651  fprintf(OutF, "\n");
652  }
653  for (TEdgeI EdgeI = BegEI(); EdgeI < EndEI(); EdgeI++) {
654  fprintf(OutF, " %*d] %*d -> %*d\n", EdgePlaces, EdgeI.GetId(), NodePlaces, EdgeI.GetSrcNId(), NodePlaces, EdgeI.GetDstNId());
655  }
656  fprintf(OutF, "\n");
657 }
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the graph.
Definition: graph.h:868
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the graph.
Definition: graph.h:870
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
Definition: graph.h:832
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
Definition: graph.h:834
int GetNodes() const
Returns the number of nodes in the graph.
Definition: graph.h:814
int GetEdges() const
Returns the number of edges in the graph.
Definition: graph.h:841

Here is the call graph for this function:

bool TNEGraph::Empty ( ) const
inline

Tests whether the graph is empty (has zero nodes).

Definition at line 890 of file graph.h.

References GetNodes().

890 { return GetNodes()==0; }
int GetNodes() const
Returns the number of nodes in the graph.
Definition: graph.h:814

Here is the call graph for this function:

TEdgeI TNEGraph::EndEI ( ) const
inline

Returns an iterator referring to the past-the-end edge in the graph.

Definition at line 870 of file graph.h.

References EdgeH, and THash< TKey, TDat, THashFunc >::EndI().

Referenced by Dump().

870 { return TEdgeI(EdgeH.EndI(), this); }
TIter EndI() const
Definition: hash.h:218
THash< TInt, TEdge > EdgeH
Definition: graph.h:790

Here is the call graph for this function:

Here is the caller graph for this function:

TNodeI TNEGraph::EndNI ( ) const
inline

Returns an iterator referring to the past-the-end node in the graph.

Definition at line 834 of file graph.h.

References THash< TKey, TDat, THashFunc >::EndI(), and NodeH.

Referenced by Dump(), and TBPGraph::GetEI().

834 { return TNodeI(NodeH.EndI(), this); }
TIter EndI() const
Definition: hash.h:218
THash< TInt, TNode > NodeH
Definition: graph.h:789

Here is the call graph for this function:

Here is the caller graph for this function:

TEdge& TNEGraph::GetEdge ( const int &  EId)
inlineprivate

Definition at line 784 of file graph.h.

References EdgeH, and THash< TKey, TDat, THashFunc >::GetDat().

Referenced by DelEdge(), DelNode(), TNEGraph::TNodeI::GetInNId(), TNEGraph::TNodeI::GetNbrNId(), TNEGraph::TNodeI::GetOutNId(), IsEdge(), and TNEGraph::TNodeI::IsInNId().

784 { return EdgeH.GetDat(EId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TEdge > EdgeH
Definition: graph.h:790

Here is the call graph for this function:

Here is the caller graph for this function:

const TEdge& TNEGraph::GetEdge ( const int &  EId) const
inlineprivate

Definition at line 785 of file graph.h.

References EdgeH, and THash< TKey, TDat, THashFunc >::GetDat().

785 { return EdgeH.GetDat(EId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TEdge > EdgeH
Definition: graph.h:790

Here is the call graph for this function:

int TNEGraph::GetEdges ( ) const
inline

Returns the number of edges in the graph.

Definition at line 841 of file graph.h.

References EdgeH, and THash< TKey, TDat, THashFunc >::Len().

Referenced by Dump(), TBPGraph::Dump(), and GetEIdV().

841 { return EdgeH.Len(); }
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
int Len() const
Definition: hash.h:228

Here is the call graph for this function:

Here is the caller graph for this function:

TEdgeI TNEGraph::GetEI ( const int &  EId) const
inline

Returns an iterator referring to edge with edge ID EId.

Definition at line 872 of file graph.h.

References EdgeH, and THash< TKey, TDat, THashFunc >::GetI().

Referenced by GetRndEI().

872 { return TEdgeI(EdgeH.GetI(EId), this); }
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
TIter GetI(const TKey &Key) const
Definition: hash.h:220

Here is the call graph for this function:

Here is the caller graph for this function:

TEdgeI TNEGraph::GetEI ( const int &  SrcNId,
const int &  DstNId 
) const
inline

Returns an iterator referring to edge (SrcNId, DstNId) in the graph.

Definition at line 874 of file graph.h.

References GetEI(), and GetEId().

Referenced by GetEI().

874 { return GetEI(GetEId(SrcNId, DstNId)); }
TEdgeI GetEI(const int &EId) const
Returns an iterator referring to edge with edge ID EId.
Definition: graph.h:872
int GetEId(const int &SrcNId, const int &DstNId) const
Returns an edge ID between node IDs SrcNId and DstNId, if such an edge exists. Otherwise, return -1.
Definition: graph.h:866

Here is the call graph for this function:

Here is the caller graph for this function:

int TNEGraph::GetEId ( const int &  SrcNId,
const int &  DstNId 
) const
inline

Returns an edge ID between node IDs SrcNId and DstNId, if such an edge exists. Otherwise, return -1.

Definition at line 866 of file graph.h.

References IsEdge().

Referenced by GetEI().

866 { int EId; return IsEdge(SrcNId, DstNId, EId)?EId:-1; }
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: graph.h:860

Here is the call graph for this function:

Here is the caller graph for this function:

void TNEGraph::GetEIdV ( TIntV EIdV) const

Gets a vector IDs of all edges in the graph.

Definition at line 570 of file graph.cpp.

References TVec< TVal, TSizeTy >::Add(), EdgeH, THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TVec< TVal, TSizeTy >::Gen(), GetEdges(), and THash< TKey, TDat, THashFunc >::GetKey().

570  {
571  EIdV.Gen(GetEdges(), 0);
572  for (int E=EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E); ) {
573  EIdV.Add(EdgeH.GetKey(E));
574  }
575 }
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
int FFirstKeyId() const
Definition: hash.h:278
int GetEdges() const
Returns the number of edges in the graph.
Definition: graph.h:841
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252

Here is the call graph for this function:

int TNEGraph::GetMxNId ( ) const
inline

Returns an ID that is larger than any node ID in the graph.

Definition at line 838 of file graph.h.

References MxNId.

838 { return MxNId; }
TInt MxNId
Definition: graph.h:788
TNodeI TNEGraph::GetNI ( const int &  NId) const
inline

Returns an iterator referring to the node of ID NId in the graph.

Definition at line 836 of file graph.h.

References THash< TKey, TDat, THashFunc >::GetI(), and NodeH.

Referenced by TBPGraph::GetEI(), and GetRndNI().

836 { return TNodeI(NodeH.GetI(NId), this); }
THash< TInt, TNode > NodeH
Definition: graph.h:789
TIter GetI(const TKey &Key) const
Definition: hash.h:220

Here is the call graph for this function:

Here is the caller graph for this function:

void TNEGraph::GetNIdV ( TIntV NIdV) const

Gets a vector IDs of all nodes in the graph.

Definition at line 564 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.

564  {
565  NIdV.Gen(GetNodes(), 0);
566  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
567  NIdV.Add(NodeH.GetKey(N)); }
568 }
THash< TInt, TNode > NodeH
Definition: graph.h:789
int GetNodes() const
Returns the number of nodes in the graph.
Definition: graph.h:814
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
int FFirstKeyId() const
Definition: hash.h:278
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:523
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252

Here is the call graph for this function:

TNode& TNEGraph::GetNode ( const int &  NId)
inlineprivate

Definition at line 782 of file graph.h.

References THash< TKey, TDat, THashFunc >::GetDat(), and NodeH.

Referenced by AddEdge(), DelEdge(), DelNode(), and IsEdge().

782 { return NodeH.GetDat(NId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TNode > NodeH
Definition: graph.h:789

Here is the call graph for this function:

Here is the caller graph for this function:

const TNode& TNEGraph::GetNode ( const int &  NId) const
inlineprivate

Definition at line 783 of file graph.h.

References THash< TKey, TDat, THashFunc >::GetDat(), and NodeH.

783 { return NodeH.GetDat(NId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TNode > NodeH
Definition: graph.h:789

Here is the call graph for this function:

int TNEGraph::GetNodes ( ) const
inline

Returns the number of nodes in the graph.

Definition at line 814 of file graph.h.

References THash< TKey, TDat, THashFunc >::Len(), and NodeH.

Referenced by Dump(), TBPGraph::Dump(), Empty(), GetNIdV(), TBPGraph::GetNIdV(), and TBPGraph::GetRndNId().

814 { return NodeH.Len(); }
THash< TInt, TNode > NodeH
Definition: graph.h:789
int Len() const
Definition: hash.h:228

Here is the call graph for this function:

Here is the caller graph for this function:

TEdgeI TNEGraph::GetRndEI ( TRnd Rnd = TInt::Rnd)
inline

Returns an interator referring to a random edge in the graph.

Definition at line 883 of file graph.h.

References GetEI(), and GetRndEId().

883 { return GetEI(GetRndEId(Rnd)); }
TEdgeI GetEI(const int &EId) const
Returns an iterator referring to edge with edge ID EId.
Definition: graph.h:872
int GetRndEId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random edge in the graph.
Definition: graph.h:881

Here is the call graph for this function:

int TNEGraph::GetRndEId ( TRnd Rnd = TInt::Rnd)
inline

Returns an ID of a random edge in the graph.

Definition at line 881 of file graph.h.

References EdgeH, THash< TKey, TDat, THashFunc >::GetKey(), and THash< TKey, TDat, THashFunc >::GetRndKeyId().

Referenced by GetRndEI().

881 { return EdgeH.GetKey(EdgeH.GetRndKeyId(Rnd, 0.8)); }
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
int GetRndKeyId(TRnd &Rnd) const
Get an index of a random element. If the hash table has many deleted keys, this may take a long time...
Definition: hash.h:444
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252

Here is the call graph for this function:

Here is the caller graph for this function:

TNodeI TNEGraph::GetRndNI ( TRnd Rnd = TInt::Rnd)
inline

Returns an interator referring to a random node in the graph.

Definition at line 879 of file graph.h.

References GetNI(), and GetRndNId().

879 { return GetNI(GetRndNId(Rnd)); }
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
Definition: graph.h:836
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the graph.
Definition: graph.h:877

Here is the call graph for this function:

int TNEGraph::GetRndNId ( TRnd Rnd = TInt::Rnd)
inline

Returns an ID of a random node in the graph.

Definition at line 877 of file graph.h.

References THash< TKey, TDat, THashFunc >::GetKey(), THash< TKey, TDat, THashFunc >::GetRndKeyId(), and NodeH.

Referenced by GetRndNI().

877 { return NodeH.GetKey(NodeH.GetRndKeyId(Rnd, 0.8)); }
THash< TInt, TNode > NodeH
Definition: graph.h:789
int GetRndKeyId(TRnd &Rnd) const
Get an index of a random element. If the hash table has many deleted keys, this may take a long time...
Definition: hash.h:444
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252

Here is the call graph for this function:

Here is the caller graph for this function:

PNEGraph TNEGraph::GetSmallGraph ( )
static

Returns a small multigraph on 5 nodes and 6 edges.

/// Edges:  0 -> 1, 0 -> 2, 0 -> 3, 0 -> 4, 1 -> 2, 1 -> 2
/// 

Definition at line 660 of file graph.cpp.

References New().

660  {
661  PNEGraph Graph = TNEGraph::New();
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);
666  return Graph;
667 }
static PNEGraph New()
Static constructor that returns a pointer to the graph. Call: PNEGraph Graph = TNEGraph::New().
Definition: graph.h:801
Definition: bd.h:196

Here is the call graph for this function:

bool TNEGraph::HasFlag ( const TGraphFlag Flag) const

Allows for run-time checking the type of the graph (see the TGraphFlag for flags).

Definition at line 464 of file graph.cpp.

References HasGraphFlag.

464  {
465  return HasGraphFlag(TNEGraph::TNet, Flag);
466 }
Directed multigraph.
Definition: graph.h:657
#define HasGraphFlag(TGraph, Flag)
For quick testing of the properties of the graph/network object (see TGraphFlag). ...
Definition: gbase.h:41
bool TNEGraph::IsEdge ( const int &  EId) const
inline

Tests whether an edge with edge ID EId exists in the graph.

Definition at line 860 of file graph.h.

References EdgeH, and THash< TKey, TDat, THashFunc >::IsKey().

Referenced by AddEdge(), DelEdge(), GetEId(), and IsOk().

860 { return EdgeH.IsKey(EId); }
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

Here is the caller graph for this function:

bool TNEGraph::IsEdge ( const int &  SrcNId,
const int &  DstNId,
const bool &  IsDir = true 
) const
inline

Tests whether an edge between node IDs SrcNId and DstNId exists in the graph.

Definition at line 862 of file graph.h.

References IsEdge().

Referenced by IsEdge().

862 { int EId; return IsEdge(SrcNId, DstNId, EId, IsDir); }
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: graph.h:860

Here is the call graph for this function:

Here is the caller graph for this function:

bool TNEGraph::IsEdge ( const int &  SrcNId,
const int &  DstNId,
int &  EId,
const bool &  IsDir = true 
) const

Tests whether an edge between node IDs SrcNId and DstNId exists in the graph. if an edge exists, return its edge ID in EId.

Definition at line 547 of file graph.cpp.

References edge, TNEGraph::TEdge::GetDstNId(), GetEdge(), TNEGraph::TEdge::GetId(), TNEGraph::TNode::GetInDeg(), TNEGraph::TNode::GetInEId(), GetNode(), TNEGraph::TNode::GetOutDeg(), TNEGraph::TNode::GetOutEId(), and TNEGraph::TEdge::GetSrcNId().

547  {
548  const TNode& SrcNode = GetNode(SrcNId);
549  for (int edge = 0; edge < SrcNode.GetOutDeg(); edge++) {
550  const TEdge& Edge = GetEdge(SrcNode.GetOutEId(edge));
551  if (DstNId == Edge.GetDstNId()) {
552  EId = Edge.GetId(); return true; }
553  }
554  if (! IsDir) {
555  for (int edge = 0; edge < SrcNode.GetInDeg(); edge++) {
556  const TEdge& Edge = GetEdge(SrcNode.GetInEId(edge));
557  if (DstNId == Edge.GetSrcNId()) {
558  EId = Edge.GetId(); return true; }
559  }
560  }
561  return false;
562 }
TEdge & GetEdge(const int &EId)
Definition: graph.h:784
TNode & GetNode(const int &NId)
Definition: graph.h:782
int GetId() const
Definition: graph.h:692

Here is the call graph for this function:

bool TNEGraph::IsNode ( const int &  NId) const
inline

Tests whether ID NId is a node.

Definition at line 830 of file graph.h.

References THash< TKey, TDat, THashFunc >::IsKey(), and NodeH.

Referenced by AddEdge(), AddNode(), TBPGraph::DelNode(), TBPGraph::IsEdge(), and IsOk().

830 { return NodeH.IsKey(NId); }
THash< TInt, TNode > NodeH
Definition: graph.h:789
bool IsKey(const TKey &Key) const
Definition: hash.h:258

Here is the call graph for this function:

Here is the caller graph for this function:

bool TNEGraph::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 586 of file graph.cpp.

References TStr::CStr(), EAssertR, EdgeH, ErrNotify(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), TStr::Fmt(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TNEGraph::TEdge::GetDstNId(), TNEGraph::TNode::GetId(), TNEGraph::TEdge::GetId(), TNEGraph::TNode::GetInDeg(), TNEGraph::TNode::GetInEId(), TNEGraph::TNode::GetOutDeg(), TNEGraph::TNode::GetOutEId(), TNEGraph::TEdge::GetSrcNId(), TNEGraph::TNode::InEIdV, IsEdge(), IsNode(), TVec< TVal, TSizeTy >::IsSorted(), NodeH, and TNEGraph::TNode::OutEIdV.

586  {
587 bool RetVal = true;
588  for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
589  const TNode& Node = NodeH[N];
590  if (! Node.OutEIdV.IsSorted()) {
591  const TStr Msg = TStr::Fmt("Out-edge list of node %d is not sorted.", Node.GetId());
592  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
593  }
594  if (! Node.InEIdV.IsSorted()) {
595  const TStr Msg = TStr::Fmt("In-edge list of node %d is not sorted.", Node.GetId());
596  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
597  }
598  // check out-edge ids
599  int prevEId = -1;
600  for (int e = 0; e < Node.GetOutDeg(); e++) {
601  if (! IsEdge(Node.GetOutEId(e))) {
602  const TStr Msg = TStr::Fmt("Out-edge id %d of node %d does not exist.", Node.GetOutEId(e), Node.GetId());
603  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
604  }
605  if (e > 0 && prevEId == Node.GetOutEId(e)) {
606  const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge id %d.", Node.GetId(), Node.GetOutEId(e));
607  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
608  }
609  prevEId = Node.GetOutEId(e);
610  }
611  // check in-edge ids
612  prevEId = -1;
613  for (int e = 0; e < Node.GetInDeg(); e++) {
614  if (! IsEdge(Node.GetInEId(e))) {
615  const TStr Msg = TStr::Fmt("Out-edge id %d of node %d does not exist.", Node.GetInEId(e), Node.GetId());
616  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
617  }
618  if (e > 0 && prevEId == Node.GetInEId(e)) {
619  const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge id %d.", Node.GetId(), Node.GetInEId(e));
620  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
621  }
622  prevEId = Node.GetInEId(e);
623  }
624  }
625  for (int E = EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E); ) {
626  const TEdge& Edge = EdgeH[E];
627  if (! IsNode(Edge.GetSrcNId())) {
628  const TStr Msg = TStr::Fmt("Edge %d source node %d does not exist.", Edge.GetId(), Edge.GetSrcNId());
629  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
630  }
631  if (! IsNode(Edge.GetDstNId())) {
632  const TStr Msg = TStr::Fmt("Edge %d destination node %d does not exist.", Edge.GetId(), Edge.GetDstNId());
633  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
634  }
635  }
636  return RetVal;
637 }
void ErrNotify(const char *NotifyCStr)
Definition: bd.h:74
THash< TInt, TNode > NodeH
Definition: graph.h:789
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
int FFirstKeyId() const
Definition: hash.h:278
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: graph.h:860
Definition: dt.h:412
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
char * CStr()
Definition: dt.h:476
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: graph.h:830

Here is the call graph for this function:

static PNEGraph TNEGraph::Load ( TSIn SIn)
inlinestatic

Static constructor that loads the graph from a stream SIn and returns a pointer to it.

Definition at line 807 of file graph.h.

References TNEGraph().

807 { return PNEGraph(new TNEGraph(SIn)); }
TPt< TNEGraph > PNEGraph
Pointer to a directed multigraph (TNEGraph)
Definition: graph.h:21
TNEGraph()
Definition: graph.h:792

Here is the call graph for this function:

static PNEGraph TNEGraph::New ( )
inlinestatic

Static constructor that returns a pointer to the graph. Call: PNEGraph Graph = TNEGraph::New().

Definition at line 801 of file graph.h.

References TNEGraph().

Referenced by GetSmallGraph().

801 { return PNEGraph(new TNEGraph()); }
TPt< TNEGraph > PNEGraph
Pointer to a directed multigraph (TNEGraph)
Definition: graph.h:21
TNEGraph()
Definition: graph.h:792

Here is the call graph for this function:

Here is the caller graph for this function:

static PNEGraph TNEGraph::New ( const int &  Nodes,
const int &  Edges 
)
inlinestatic

Static constructor that returns a pointer to the graph and reserves enough memory for Nodes nodes and Edges edges.

Call: PNEGraph Graph = TNEGraph::New(Nodes, Edges).

Definition at line 805 of file graph.h.

References TNEGraph().

805 { return PNEGraph(new TNEGraph(Nodes, Edges)); }
TPt< TNEGraph > PNEGraph
Pointer to a directed multigraph (TNEGraph)
Definition: graph.h:21
TNEGraph()
Definition: graph.h:792

Here is the call graph for this function:

TNEGraph& TNEGraph::operator= ( const TNEGraph Graph)
inline

Definition at line 810 of file graph.h.

References EdgeH, MxEId, MxNId, and NodeH.

810  { if (this!=&Graph) {
811  MxNId=Graph.MxNId; MxEId=Graph.MxEId; NodeH=Graph.NodeH; EdgeH=Graph.EdgeH; } return *this; }
THash< TInt, TNode > NodeH
Definition: graph.h:789
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
TInt MxNId
Definition: graph.h:788
TInt MxEId
Definition: graph.h:788
void TNEGraph::Reserve ( const int &  Nodes,
const int &  Edges 
)
inline

Reserves memory for a graph of Nodes nodes and Edges edges.

Definition at line 894 of file graph.h.

References EdgeH, THash< TKey, TDat, THashFunc >::Gen(), and NodeH.

Referenced by TNEGraph().

894  {
895  if (Nodes>0) { NodeH.Gen(Nodes/2); } if (Edges>0) { EdgeH.Gen(Edges/2); } }
THash< TInt, TNode > NodeH
Definition: graph.h:789
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
void Gen(const int &ExpectVals)
Definition: hash.h:222

Here is the call graph for this function:

Here is the caller graph for this function:

void TNEGraph::Save ( TSOut SOut) const
inline

Saves the graph to a (binary) stream SOut.

Definition at line 799 of file graph.h.

References EdgeH, MxEId, MxNId, NodeH, THash< TKey, TDat, THashFunc >::Save(), and TInt::Save().

799 { MxNId.Save(SOut); MxEId.Save(SOut); NodeH.Save(SOut); EdgeH.Save(SOut); }
void Save(TSOut &SOut) const
Definition: dt.h:1150
void Save(TSOut &SOut) const
Definition: hash.h:183
THash< TInt, TNode > NodeH
Definition: graph.h:789
THash< TInt, TEdge > EdgeH
Definition: graph.h:790
TInt MxNId
Definition: graph.h:788
TInt MxEId
Definition: graph.h:788

Here is the call graph for this function:

Friends And Related Function Documentation

friend class TPt< TNEGraph >
friend

Definition at line 916 of file graph.h.

Member Data Documentation

TCRef TNEGraph::CRef
private

Definition at line 787 of file graph.h.

THash<TInt, TEdge> TNEGraph::EdgeH
private
TInt TNEGraph::MxEId
private

Definition at line 788 of file graph.h.

Referenced by AddEdge(), Clr(), operator=(), and Save().

TInt TNEGraph::MxNId
private

Definition at line 788 of file graph.h.

Referenced by AddNode(), TBPGraph::AddNode(), Clr(), GetMxNId(), operator=(), and Save().

THash<TInt, TNode> TNEGraph::NodeH
private

The documentation for this class was generated from the following files: