SNAP Library 3.0, User Reference  2016-07-20 17:56:49
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
TDirNet Class Reference

Directed network. More...

#include <network.h>

Classes

class  TEdgeI
 Edge iterator. Only forward iteration (operator++) is supported. More...
 
class  TNode
 
class  TNodeI
 Node iterator. Only forward iteration (operator++) is supported. More...
 

Public Types

typedef TDirNet TNet
 
typedef TPt< TDirNetPNet
 

Public Member Functions

 TDirNet ()
 
 TDirNet (const int &Nodes, const int &Edges)
 Constructor that reserves enough memory for a network of Nodes nodes and Edges edges. More...
 
 TDirNet (const TDirNet &Graph)
 
 TDirNet (TSIn &SIn)
 Constructor that loads the network from a (binary) stream SIn. More...
 
void Save (TSOut &SOut) const
 Saves the network to a (binary) stream SOut. Expects data structures for sparse attributes. More...
 
void Save_V1 (TSOut &SOut) const
 Saves the network to a (binary) stream SOut. Available for backwards compatibility. More...
 
bool HasFlag (const TGraphFlag &Flag) const
 Allows for run-time checking the type of the network (see the TGraphFlag for flags). More...
 
TDirNetoperator= (const TDirNet &Graph)
 
int GetNodes () const
 Returns the number of nodes in the network. More...
 
int AddNode (int NId=-1)
 Adds a node of ID NId to the network. More...
 
int AddNode (const TNodeI &NodeId)
 Adds a node of ID NodeI.GetId() to the network. More...
 
int AddNode (const int &NId, const TIntV &InNIdV, const TIntV &OutNIdV)
 Adds a node of ID NId to the network, creates edges to the node from all nodes in vector InNIdV, creates edges from the node to all nodes in vector OutNIdV. More...
 
int AddNode (const int &NId, const TVecPool< TInt > &Pool, const int &SrcVId, const int &DstVId)
 Adds a node of ID NId to the network, creates edges to the node from all nodes in vector InNIdV in the vector pool Pool, creates edges from the node to all nodes in vector OutNIdVin the vector pool Pool . More...
 
void DelNode (const int &NId)
 Deletes node of ID NId from the network. More...
 
void DelNode (const TNode &NodeI)
 Deletes node of ID NodeI.GetId() from the network. 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 network. More...
 
TNodeI EndNI () const
 Returns an iterator referring to the past-the-end node in the network. More...
 
TNodeI GetNI (const int &NId) const
 Returns an iterator referring to the node of ID NId in the network. More...
 
int GetMxNId () const
 Returns an ID that is larger than any node ID in the network. More...
 
int GetEdges () const
 Returns the number of edges in the network. More...
 
int AddEdge (const int &SrcNId, const int &DstNId)
 Adds an edge from node IDs SrcNId to node DstNId to the network. More...
 
int AddEdge (const TEdgeI &EdgeI)
 Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() to the network. More...
 
void DelEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true)
 Deletes an edge from node IDs SrcNId to DstNId from the network. More...
 
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 network. More...
 
TEdgeI BegEI () const
 Returns an iterator referring to the first edge in the network. More...
 
TEdgeI EndEI () const
 Returns an iterator referring to the past-the-end edge in the network. More...
 
TEdgeI GetEI (const int &EId) const
 Not supported/implemented! More...
 
TEdgeI GetEI (const int &SrcNId, const int &DstNId) const
 Returns an iterator referring to edge (SrcNId, DstNId) in the network. More...
 
int GetRndNId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random node in the network. More...
 
TNodeI GetRndNI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random node in the network. More...
 
void GetNIdV (TIntV &NIdV) const
 Gets a vector IDs of all nodes in the network. More...
 
bool Empty () const
 Tests whether the network is empty (has zero nodes). More...
 
void Clr ()
 Deletes all nodes and edges from the network. More...
 
void Reserve (const int &Nodes, const int &Edges)
 Reserves memory for a network of Nodes nodes and Edges edges. More...
 
void ReserveNIdInDeg (const int &NId, const int &InDeg)
 Reserves memory for node ID NId having InDeg in-edges. More...
 
void ReserveNIdOutDeg (const int &NId, const int &OutDeg)
 Reserves memory for node ID NId having OutDeg out-edges. More...
 
void Defrag (const bool &OnlyNodeLinks=false)
 Defragments the network. More...
 
bool IsOk (const bool &ThrowExcept=true) const
 Checks the network data structure for internal consistency. More...
 
void Dump (FILE *OutF=stdout) const
 Print the network in a human readable form to an output stream OutF. More...
 
int AddSAttrDatN (const TInt &NId, const TStr &AttrName, const TInt &Val)
 Adds Int sparse attribute with name AttrName to the given node with id NId. More...
 
int AddSAttrDatN (const TInt &NId, const TInt &AttrId, const TInt &Val)
 Adds Int sparse attribute with id AttrId to the given node with id NId. More...
 
int AddSAttrDatN (const TNodeI &NodeI, const TStr &AttrName, const TInt &Val)
 Adds Int sparse attribute with name AttrName to NodeI. More...
 
int AddSAttrDatN (const TNodeI &NodeI, const TInt &AttrId, const TInt &Val)
 Adds Int sparse attribute with id AttrId to NodeI. More...
 
int AddSAttrDatN (const TInt &NId, const TStr &AttrName, const TFlt &Val)
 Adds Flt sparse attribute with name AttrName to the given node with id NId. More...
 
int AddSAttrDatN (const TInt &NId, const TInt &AttrId, const TFlt &Val)
 Adds Flt sparse attribute with id AttrId to the given node with id NId. More...
 
int AddSAttrDatN (const TNodeI &NodeI, const TStr &AttrName, const TFlt &Val)
 Adds Flt sparse attribute with name AttrName to NodeI. More...
 
int AddSAttrDatN (const TNodeI &NodeI, const TInt &AttrId, const TFlt &Val)
 Adds Flt sparse attribute with id AttrId to NodeI. More...
 
int AddSAttrDatN (const TInt &NId, const TStr &AttrName, const TStr &Val)
 Adds Str sparse attribute with name AttrName to the given node with id NId. More...
 
int AddSAttrDatN (const TInt &NId, const TInt &AttrId, const TStr &Val)
 Adds Str sparse attribute with id AttrId to the given node with id NId. More...
 
int AddSAttrDatN (const TNodeI &NodeI, const TStr &AttrName, const TStr &Val)
 Adds Str sparse attribute with name AttrName to NodeI. More...
 
int AddSAttrDatN (const TNodeI &NodeI, const TInt &AttrId, const TStr &Val)
 Adds Str sparse attribute with id AttrId to NodeI. More...
 
int GetSAttrDatN (const TInt &NId, const TStr &AttrName, TInt &ValX) const
 Gets Int sparse attribute with name AttrName from node with id NId. More...
 
int GetSAttrDatN (const TInt &NId, const TInt &AttrId, TInt &ValX) const
 Gets Int sparse attribute with id AttrId from node with id NId. More...
 
int GetSAttrDatN (const TNodeI &NodeI, const TStr &AttrName, TInt &ValX) const
 Gets Int sparse attribute with name AttrName from NodeI. More...
 
int GetSAttrDatN (const TNodeI &NodeI, const TInt &AttrId, TInt &ValX) const
 Gets Int sparse attribute with id AttrId from NodeI. More...
 
int GetSAttrDatN (const TInt &NId, const TStr &AttrName, TFlt &ValX) const
 Gets Flt sparse attribute with name AttrName from node with id NId. More...
 
int GetSAttrDatN (const TInt &NId, const TInt &AttrId, TFlt &ValX) const
 Gets Flt sparse attribute with id AttrId from node with id NId. More...
 
int GetSAttrDatN (const TNodeI &NodeI, const TStr &AttrName, TFlt &ValX) const
 Gets Flt sparse attribute with name AttrName from NodeI. More...
 
int GetSAttrDatN (const TNodeI &NodeI, const TInt &AttrId, TFlt &ValX) const
 Gets Flt sparse attribute with id AttrId from NodeI. More...
 
int GetSAttrDatN (const TInt &NId, const TStr &AttrName, TStr &ValX) const
 Gets Str sparse attribute with name AttrName from node with id NId. More...
 
int GetSAttrDatN (const TInt &NId, const TInt &AttrId, TStr &ValX) const
 Gets Str sparse attribute with id AttrId from node with id NId. More...
 
int GetSAttrDatN (const TNodeI &NodeI, const TStr &AttrName, TStr &ValX) const
 Gets Str sparse attribute with name AttrName from NodeI. More...
 
int GetSAttrDatN (const TNodeI &NodeI, const TInt &AttrId, TStr &ValX) const
 Gets Str sparse attribute with id AttrId from NodeI. More...
 
int DelSAttrDatN (const TInt &NId, const TStr &AttrName)
 Deletes sparse attribute with name AttrName from node with id NId. More...
 
int DelSAttrDatN (const TInt &NId, const TInt &AttrId)
 Deletes sparse attribute with id AttrId from node with id NId. More...
 
int DelSAttrDatN (const TNodeI &NodeI, const TStr &AttrName)
 Deletes sparse attribute with name AttrName from NodeI. More...
 
int DelSAttrDatN (const TNodeI &NodeI, const TInt &AttrId)
 Deletes sparse attribute with id AttrId from NodeI. More...
 
int GetSAttrVN (const TInt &NId, const TAttrType AttrType, TAttrPrV &AttrV) const
 Gets a list of all sparse attributes of type AttrType for node with id NId. More...
 
int GetSAttrVN (const TNodeI &NodeI, const TAttrType AttrType, TAttrPrV &AttrV) const
 Gets a list of all sparse attributes of type AttrType for NodeI. More...
 
int GetIdVSAttrN (const TStr &AttrName, TIntV &IdV) const
 Gets a list of all nodes that have a sparse attribute with name AttrName. More...
 
int GetIdVSAttrN (const TInt &AttrId, TIntV &IdV) const
 Gets a list of all nodes that have a sparse attribute with id AttrId. More...
 
int AddSAttrN (const TStr &Name, const TAttrType &AttrType, TInt &AttrId)
 Adds mapping for sparse attribute with name Name and type AttrType. More...
 
int GetSAttrIdN (const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
 Gets id and type for attribute with name Name. More...
 
int GetSAttrNameN (const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
 Gets name and type for attribute with id AttrId. More...
 
int AddSAttrDatE (const int &SrcNId, const int &DstNId, const TStr &AttrName, const TInt &Val)
 Adds Int sparse attribute with name AttrName to the given edge with ids SrcId and DstId. More...
 
int AddSAttrDatE (const int &SrcNId, const int &DstNId, const TInt &AttrId, const TInt &Val)
 Adds Int sparse attribute with id AttrId to the given edge with ids SrcId and DstId. More...
 
int AddSAttrDatE (const TEdgeI &EdgeI, const TStr &AttrName, const TInt &Val)
 Adds Int sparse attribute with name AttrName to EdgeI. More...
 
int AddSAttrDatE (const TEdgeI &EdgeI, const TInt &AttrId, const TInt &Val)
 Adds Int sparse attribute with id AttrId to EdgeI. More...
 
int AddSAttrDatE (const int &SrcNId, const int &DstNId, const TStr &AttrName, const TFlt &Val)
 Adds Flt sparse attribute with name AttrName to the given edge with ids SrcId and DstId. More...
 
int AddSAttrDatE (const int &SrcNId, const int &DstNId, const TInt &AttrId, const TFlt &Val)
 Adds Flt sparse attribute with id AttrId to the given edge with ids SrcId and DstId. More...
 
int AddSAttrDatE (const TEdgeI &EdgeI, const TStr &AttrName, const TFlt &Val)
 Adds Flt sparse attribute with name AttrName to EdgeI. More...
 
int AddSAttrDatE (const TEdgeI &EdgeI, const TInt &AttrId, const TFlt &Val)
 Adds Flt sparse attribute with id AttrId to EdgeI. More...
 
int AddSAttrDatE (const int &SrcNId, const int &DstNId, const TStr &AttrName, const TStr &Val)
 Adds Str sparse attribute with name AttrName to the given edge with ids SrcId and DstId. More...
 
int AddSAttrDatE (const int &SrcNId, const int &DstNId, const TInt &AttrId, const TStr &Val)
 Adds Str sparse attribute with id AttrId to the given edge with ids SrcId and DstId. More...
 
int AddSAttrDatE (const TEdgeI &EdgeI, const TStr &AttrName, const TStr &Val)
 Adds Str sparse attribute with name AttrName to EdgeI. More...
 
int AddSAttrDatE (const TEdgeI &EdgeI, const TInt &AttrId, const TStr &Val)
 Adds Str sparse attribute with id AttrId to EdgeI. More...
 
int GetSAttrDatE (const int &SrcNId, const int &DstNId, const TStr &AttrName, TInt &ValX) const
 Gets Int sparse attribute with name AttrName from edge with ids SrcId and DstId. More...
 
int GetSAttrDatE (const int &SrcNId, const int &DstNId, const TInt &AttrId, TInt &ValX) const
 Gets Int sparse attribute with id AttrId from edge with ids SrcId and DstId. More...
 
int GetSAttrDatE (const TEdgeI &EdgeI, const TStr &AttrName, TInt &ValX) const
 Gets Int sparse attribute with name AttrName from EdgeI. More...
 
int GetSAttrDatE (const TEdgeI &EdgeI, const TInt &AttrId, TInt &ValX) const
 Gets Int sparse attribute with id AttrId from EdgeI. More...
 
int GetSAttrDatE (const int &SrcNId, const int &DstNId, const TStr &AttrName, TFlt &ValX) const
 Gets Flt sparse attribute with name AttrName from edge with ids SrcId and DstId. More...
 
int GetSAttrDatE (const int &SrcNId, const int &DstNId, const TInt &AttrId, TFlt &ValX) const
 Gets Flt sparse attribute with id AttrId from edge with ids SrcId and DstId. More...
 
int GetSAttrDatE (const TEdgeI &EdgeI, const TStr &AttrName, TFlt &ValX) const
 Gets Flt sparse attribute with name AttrName from EdgeI. More...
 
int GetSAttrDatE (const TEdgeI &EdgeI, const TInt &AttrId, TFlt &ValX) const
 Gets Flt sparse attribute with id AttrId from EdgeI. More...
 
int GetSAttrDatE (const int &SrcNId, const int &DstNId, const TStr &AttrName, TStr &ValX) const
 Gets Str sparse attribute with name AttrName from edge with ids SrcId and DstId. More...
 
int GetSAttrDatE (const int &SrcNId, const int &DstNId, const TInt &AttrId, TStr &ValX) const
 Gets Str sparse attribute with id AttrId from edge with ids SrcId and DstId. More...
 
int GetSAttrDatE (const TEdgeI &EdgeI, const TStr &AttrName, TStr &ValX) const
 Gets Str sparse attribute with name AttrName from EdgeI. More...
 
int GetSAttrDatE (const TEdgeI &EdgeI, const TInt &AttrId, TStr &ValX) const
 Gets Str sparse attribute with id AttrId from EdgeI. More...
 
int DelSAttrDatE (const int &SrcNId, const int &DstNId, const TStr &AttrName)
 Deletes sparse attribute with name AttrName from edge with ids SrcId and DstId. More...
 
int DelSAttrDatE (const int &SrcNId, const int &DstNId, const TInt &AttrId)
 Deletes sparse attribute with id AttrId from edge with ids SrcId and DstId. More...
 
int DelSAttrDatE (const TEdgeI &EdgeI, const TStr &AttrName)
 Deletes sparse attribute with name AttrName from EdgeI. More...
 
int DelSAttrDatE (const TEdgeI &EdgeI, const TInt &AttrId)
 Deletes sparse attribute with id AttrId from EdgeI. More...
 
int GetSAttrVE (const int &SrcNId, const int &DstNId, const TAttrType AttrType, TAttrPrV &AttrV) const
 Gets a list of all sparse attributes of type AttrType for edge with ids SrcId and DstId. More...
 
int GetSAttrVE (const TEdgeI &EdgeI, const TAttrType AttrType, TAttrPrV &AttrV) const
 Gets a list of all sparse attributes of type AttrType for EdgeI. More...
 
int GetIdVSAttrE (const TStr &AttrName, TIntPrV &IdV) const
 Gets a list of all edges that have a sparse attribute with name AttrName. More...
 
int GetIdVSAttrE (const TInt &AttrId, TIntPrV &IdV) const
 Gets a list of all edges that have a sparse attribute with id AttrId. More...
 
int AddSAttrE (const TStr &Name, const TAttrType &AttrType, TInt &AttrId)
 Adds mapping for sparse attribute with name Name and type AttrType. More...
 
int GetSAttrIdE (const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
 Gets id and type for attribute with name Name. More...
 
int GetSAttrNameE (const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
 Gets name and type for attribute with id AttrId. More...
 

Static Public Member Functions

static PDirNet New ()
 Static constructor that returns a pointer to the network. Call: PDirNet Graph = TDirNet::New(). More...
 
static PDirNet New (const int &Nodes, const int &Edges)
 Static constructor that returns a pointer to the network and reserves enough memory for Nodes nodes and Edges edges. More...
 
static PDirNet Load (TSIn &SIn)
 Static constructor that loads the network from a stream SIn and returns a pointer to it. More...
 
static PDirNet Load_V1 (TSIn &SIn)
 Static constructor that loads the network from a stream SIn and returns a pointer to it. Backwards compatible. More...
 
static PDirNet GetSmallGraph ()
 Returns a small network on 5 nodes and 6 edges. More...
 

Private Member Functions

TNodeGetNode (const int &NId)
 
const TNodeGetNode (const int &NId) const
 

Private Attributes

TCRef CRef
 
TInt MxNId
 
THash< TInt, TNodeNodeH
 
TAttr SAttrN
 
TAttrPair SAttrE
 

Friends

class TPt< TDirNet >
 
class TDirNetMtx
 

Detailed Description

Directed network.

Node IDs can be arbitrary non-negative integers. Nodes and edges can have sparse attributes/data associated with them. There is at most one directed edge from one source node to a destination node. There can be an edge between the same pair of nodes in the opposite direction. Self loops (one per node) are allowed but multiple (parallel) edges are not. The directed graph data structure is implemented using sorted adjacency lists. This means adding a node takes constant time, while adding an edge takes linear time (since adjacency list is kept sorted) in the node degree. Accessing arbitrary node takes constant time and accessing any edge takes logarithmic time in the node degree.

Definition at line 3267 of file network.h.

Member Typedef Documentation

Definition at line 3270 of file network.h.

Definition at line 3269 of file network.h.

Constructor & Destructor Documentation

TDirNet::TDirNet ( )
inline

Definition at line 3375 of file network.h.

3375 : CRef(), MxNId(0), NodeH(), SAttrN(), SAttrE() { }
TCRef CRef
Definition: network.h:3366
TAttrPair SAttrE
Definition: network.h:3370
TAttr SAttrN
Definition: network.h:3369
THash< TInt, TNode > NodeH
Definition: network.h:3368
TInt MxNId
Definition: network.h:3367
TDirNet::TDirNet ( const int &  Nodes,
const int &  Edges 
)
inlineexplicit

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

Definition at line 3377 of file network.h.

3377 : MxNId(0), SAttrN(), SAttrE() { Reserve(Nodes, Edges); }
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a network of Nodes nodes and Edges edges.
Definition: network.h:3495
TAttrPair SAttrE
Definition: network.h:3370
TAttr SAttrN
Definition: network.h:3369
TInt MxNId
Definition: network.h:3367
TDirNet::TDirNet ( const TDirNet Graph)
inline

Definition at line 3378 of file network.h.

3378 : MxNId(Graph.MxNId), NodeH(Graph.NodeH), SAttrN(), SAttrE() { }
TAttrPair SAttrE
Definition: network.h:3370
TAttr SAttrN
Definition: network.h:3369
THash< TInt, TNode > NodeH
Definition: network.h:3368
TInt MxNId
Definition: network.h:3367
TDirNet::TDirNet ( TSIn SIn)
inline

Constructor that loads the network from a (binary) stream SIn.

Definition at line 3380 of file network.h.

3380 : MxNId(SIn), NodeH(SIn), SAttrN(SIn), SAttrE(SIn) { }
TAttrPair SAttrE
Definition: network.h:3370
TAttr SAttrN
Definition: network.h:3369
THash< TInt, TNode > NodeH
Definition: network.h:3368
TInt MxNId
Definition: network.h:3367

Member Function Documentation

int TDirNet::AddEdge ( const int &  SrcNId,
const int &  DstNId 
)

Adds an edge from node IDs SrcNId to node DstNId to the network.

If the edge already exists return -2. If the edge was successfully added return -1. Normally the function should return an ID of the edge added but since edges in TDirNet have no IDs we return -1. Function aborts if SrcNId or DstNId are not nodes in the graph.

Definition at line 2222 of file network.cpp.

2222  {
2223  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
2224  //IAssert(! IsEdge(SrcNId, DstNId));
2225  if (IsEdge(SrcNId, DstNId)) { return -2; }
2226  GetNode(SrcNId).OutNIdV.AddSorted(DstNId);
2227  GetNode(DstNId).InNIdV.AddSorted(SrcNId);
2228  return -1; // edge id
2229 }
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 network.
Definition: network.cpp:2251
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TNode & GetNode(const int &NId)
Definition: network.h:3372
TSizeTy AddSorted(const TVal &Val, const bool &Asc=true, const TSizeTy &_MxVals=-1)
Adds element Val to a sorted vector.
Definition: ds.h:1063
TIntV InNIdV
Definition: network.h:3275
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TIntV OutNIdV
Definition: network.h:3275
int TDirNet::AddEdge ( const TEdgeI EdgeI)
inline

Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() to the network.

Definition at line 3465 of file network.h.

3465 { return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId()); }
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node IDs SrcNId to node DstNId to the network.
Definition: network.cpp:2222
int TDirNet::AddNode ( int  NId = -1)

Adds a node of ID NId to the network.

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 2142 of file network.cpp.

2142  {
2143  if (NId == -1) {
2144  NId = MxNId; MxNId++;
2145  } else {
2146  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
2147  MxNId = TMath::Mx(NId+1, MxNId());
2148  }
2149  NodeH.AddDat(NId, TNode(NId));
2150  return NId;
2151 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
THash< TInt, TNode > NodeH
Definition: network.h:3368
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxNId
Definition: network.h:3367
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TDirNet::AddNode ( const TNodeI NodeId)
inline

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

Definition at line 3411 of file network.h.

3411 { return AddNode(NodeId.GetId()); }
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Definition: network.cpp:2142
int TDirNet::AddNode ( const int &  NId,
const TIntV InNIdV,
const TIntV OutNIdV 
)

Adds a node of ID NId to the network, creates edges to the node from all nodes in vector InNIdV, creates edges from the node to all nodes in vector OutNIdV.

//OutNIdV) Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.

The operation can create inconsistent graphs when the neighboring nodes in vectors InNIdV and OutNIdV do not exist. Use TDirNet::IsOk to check that the resulting graph is consistent after the operation.

Definition at line 2155 of file network.cpp.

2155  {
2156  int NewNId;
2157  if (NId == -1) {
2158  NewNId = MxNId; MxNId++;
2159  } else {
2160  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
2161  NewNId = NId;
2162  MxNId = TMath::Mx(NewNId+1, MxNId());
2163  }
2164  TNode& Node = NodeH.AddDat(NewNId);
2165  Node.Id = NewNId;
2166  Node.InNIdV = InNIdV;
2167  Node.OutNIdV = OutNIdV;
2168  Node.InNIdV.Sort();
2169  Node.OutNIdV.Sort();
2170  return NewNId;
2171 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1254
THash< TInt, TNode > NodeH
Definition: network.h:3368
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxNId
Definition: network.h:3367
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TDirNet::AddNode ( const int &  NId,
const TVecPool< TInt > &  Pool,
const int &  SrcVId,
const int &  DstVId 
)

Adds a node of ID NId to the network, creates edges to the node from all nodes in vector InNIdV in the vector pool Pool, creates edges from the node to all nodes in vector OutNIdVin the vector pool Pool .

//NIdVId) Returns the ID of the node being added. If NId is -1, node ID is automatically assigned. Aborts, if a node with ID NId already exists.

The operation can create inconsistent graphs when the neighboring nodes stored in the Pool vector are not explicitly added to the graph. Use TDirNet::IsOk to check that the resulting graph is consistent.

Definition at line 2175 of file network.cpp.

2175  {
2176  int NewNId;
2177  if (NId == -1) {
2178  NewNId = MxNId; MxNId++;
2179  } else {
2180  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
2181  NewNId = NId;
2182  MxNId = TMath::Mx(NewNId+1, MxNId());
2183  }
2184  TNode& Node = NodeH.AddDat(NewNId);
2185  Node.Id = NewNId;
2186  Node.InNIdV.GenExt(Pool.GetValVPt(SrcVId), Pool.GetVLen(SrcVId));
2187  Node.OutNIdV.GenExt(Pool.GetValVPt(DstVId), Pool.GetVLen(DstVId));
2188  Node.InNIdV.Sort();
2189  Node.OutNIdV.Sort();
2190  return NewNId;
2191 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
TVal * GetValVPt(const int &VId) const
Returns pointer to the first element of the vector with id VId.
Definition: ds.h:1665
int GetVLen(const int &VId) const
Returns the number of elements in the vector with id VId.
Definition: ds.h:1663
THash< TInt, TNode > NodeH
Definition: network.h:3368
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxNId
Definition: network.h:3367
TDat & AddDat(const TKey &Key)
Definition: hash.h:196
int TDirNet::AddSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TStr AttrName,
const TInt Val 
)

Adds Int sparse attribute with name AttrName to the given edge with ids SrcId and DstId.

Definition at line 2476 of file network.cpp.

2476  {
2477  if (!IsEdge(SrcNId, DstNId)) {
2478  return -1;
2479  }
2480  TIntPr EId(SrcNId, DstNId);
2481  return SAttrE.AddSAttrDat(EId, AttrName, Val);
2482 }
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 network.
Definition: network.cpp:2251
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int AddSAttrDat(const TIntPr &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:246
int TDirNet::AddSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TInt AttrId,
const TInt Val 
)

Adds Int sparse attribute with id AttrId to the given edge with ids SrcId and DstId.

Definition at line 2484 of file network.cpp.

2484  {
2485  if (!IsEdge(SrcNId, DstNId)) {
2486  return -1;
2487  }
2488  TIntPr EId(SrcNId, DstNId);
2489  return SAttrE.AddSAttrDat(EId, AttrId, Val);
2490 }
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 network.
Definition: network.cpp:2251
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int AddSAttrDat(const TIntPr &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:246
int TDirNet::AddSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName,
const TInt Val 
)
inline

Adds Int sparse attribute with name AttrName to EdgeI.

Definition at line 3645 of file network.h.

3645  {
3646  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, Val);
3647  }
int AddSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with ids SrcId and DstId...
Definition: network.cpp:2476
int TDirNet::AddSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId,
const TInt Val 
)
inline

Adds Int sparse attribute with id AttrId to EdgeI.

Definition at line 3649 of file network.h.

3649  {
3650  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, Val);
3651  }
int AddSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with ids SrcId and DstId...
Definition: network.cpp:2476
int TDirNet::AddSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TStr AttrName,
const TFlt Val 
)

Adds Flt sparse attribute with name AttrName to the given edge with ids SrcId and DstId.

Definition at line 2492 of file network.cpp.

2492  {
2493  if (!IsEdge(SrcNId, DstNId)) {
2494  return -1;
2495  }
2496  TIntPr EId(SrcNId, DstNId);
2497  return SAttrE.AddSAttrDat(EId, AttrName, Val);
2498 }
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 network.
Definition: network.cpp:2251
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int AddSAttrDat(const TIntPr &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:246
int TDirNet::AddSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TInt AttrId,
const TFlt Val 
)

Adds Flt sparse attribute with id AttrId to the given edge with ids SrcId and DstId.

Definition at line 2500 of file network.cpp.

2500  {
2501  if (!IsEdge(SrcNId, DstNId)) {
2502  return -1;
2503  }
2504  TIntPr EId(SrcNId, DstNId);
2505  return SAttrE.AddSAttrDat(EId, AttrId, Val);
2506 }
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 network.
Definition: network.cpp:2251
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int AddSAttrDat(const TIntPr &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:246
int TDirNet::AddSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName,
const TFlt Val 
)
inline

Adds Flt sparse attribute with name AttrName to EdgeI.

Definition at line 3659 of file network.h.

3659  {
3660  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, Val);
3661  }
int AddSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with ids SrcId and DstId...
Definition: network.cpp:2476
int TDirNet::AddSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId,
const TFlt Val 
)
inline

Adds Flt sparse attribute with id AttrId to EdgeI.

Definition at line 3663 of file network.h.

3663  {
3664  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, Val);
3665  }
int AddSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with ids SrcId and DstId...
Definition: network.cpp:2476
int TDirNet::AddSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TStr AttrName,
const TStr Val 
)

Adds Str sparse attribute with name AttrName to the given edge with ids SrcId and DstId.

Definition at line 2508 of file network.cpp.

2508  {
2509  if (!IsEdge(SrcNId, DstNId)) {
2510  return -1;
2511  }
2512  TIntPr EId(SrcNId, DstNId);
2513  return SAttrE.AddSAttrDat(EId, AttrName, Val);
2514 }
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 network.
Definition: network.cpp:2251
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int AddSAttrDat(const TIntPr &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:246
int TDirNet::AddSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TInt AttrId,
const TStr Val 
)

Adds Str sparse attribute with id AttrId to the given edge with ids SrcId and DstId.

Definition at line 2516 of file network.cpp.

2516  {
2517  if (!IsEdge(SrcNId, DstNId)) {
2518  return -1;
2519  }
2520  TIntPr EId(SrcNId, DstNId);
2521  return SAttrE.AddSAttrDat(EId, AttrId, Val);
2522 }
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 network.
Definition: network.cpp:2251
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int AddSAttrDat(const TIntPr &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:246
int TDirNet::AddSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName,
const TStr Val 
)
inline

Adds Str sparse attribute with name AttrName to EdgeI.

Definition at line 3673 of file network.h.

3673  {
3674  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, Val);
3675  }
int AddSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with ids SrcId and DstId...
Definition: network.cpp:2476
int TDirNet::AddSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId,
const TStr Val 
)
inline

Adds Str sparse attribute with id AttrId to EdgeI.

Definition at line 3677 of file network.h.

3677  {
3678  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, Val);
3679  }
int AddSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with ids SrcId and DstId...
Definition: network.cpp:2476
int TDirNet::AddSAttrDatN ( const TInt NId,
const TStr AttrName,
const TInt Val 
)

Adds Int sparse attribute with name AttrName to the given node with id NId.

Definition at line 2350 of file network.cpp.

2350  {
2351  if (!IsNode(NId)) {
2352  return -1;
2353  }
2354  return SAttrN.AddSAttrDat(NId, AttrName, Val);
2355 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:2
TAttr SAttrN
Definition: network.h:3369
int TDirNet::AddSAttrDatN ( const TInt NId,
const TInt AttrId,
const TInt Val 
)

Adds Int sparse attribute with id AttrId to the given node with id NId.

Definition at line 2357 of file network.cpp.

2357  {
2358  if (!IsNode(NId)) {
2359  return -1;
2360  }
2361  return SAttrN.AddSAttrDat(NId, AttrId, Val);
2362 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:2
TAttr SAttrN
Definition: network.h:3369
int TDirNet::AddSAttrDatN ( const TNodeI NodeI,
const TStr AttrName,
const TInt Val 
)
inline

Adds Int sparse attribute with name AttrName to NodeI.

Definition at line 3527 of file network.h.

3527  {
3528  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
3529  }
int AddSAttrDatN(const TInt &NId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given node with id NId.
Definition: network.cpp:2350
int TDirNet::AddSAttrDatN ( const TNodeI NodeI,
const TInt AttrId,
const TInt Val 
)
inline

Adds Int sparse attribute with id AttrId to NodeI.

Definition at line 3531 of file network.h.

3531  {
3532  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
3533  }
int AddSAttrDatN(const TInt &NId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given node with id NId.
Definition: network.cpp:2350
int TDirNet::AddSAttrDatN ( const TInt NId,
const TStr AttrName,
const TFlt Val 
)

Adds Flt sparse attribute with name AttrName to the given node with id NId.

Definition at line 2364 of file network.cpp.

2364  {
2365  if (!IsNode(NId)) {
2366  return -1;
2367  }
2368  return SAttrN.AddSAttrDat(NId, AttrName, Val);
2369 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:2
TAttr SAttrN
Definition: network.h:3369
int TDirNet::AddSAttrDatN ( const TInt NId,
const TInt AttrId,
const TFlt Val 
)

Adds Flt sparse attribute with id AttrId to the given node with id NId.

Definition at line 2371 of file network.cpp.

2371  {
2372  if (!IsNode(NId)) {
2373  return -1;
2374  }
2375  return SAttrN.AddSAttrDat(NId, AttrId, Val);
2376 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:2
TAttr SAttrN
Definition: network.h:3369
int TDirNet::AddSAttrDatN ( const TNodeI NodeI,
const TStr AttrName,
const TFlt Val 
)
inline

Adds Flt sparse attribute with name AttrName to NodeI.

Definition at line 3541 of file network.h.

3541  {
3542  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
3543  }
int AddSAttrDatN(const TInt &NId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given node with id NId.
Definition: network.cpp:2350
int TDirNet::AddSAttrDatN ( const TNodeI NodeI,
const TInt AttrId,
const TFlt Val 
)
inline

Adds Flt sparse attribute with id AttrId to NodeI.

Definition at line 3545 of file network.h.

3545  {
3546  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
3547  }
int AddSAttrDatN(const TInt &NId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given node with id NId.
Definition: network.cpp:2350
int TDirNet::AddSAttrDatN ( const TInt NId,
const TStr AttrName,
const TStr Val 
)

Adds Str sparse attribute with name AttrName to the given node with id NId.

Definition at line 2378 of file network.cpp.

2378  {
2379  if (!IsNode(NId)) {
2380  return -1;
2381  }
2382  return SAttrN.AddSAttrDat(NId, AttrName, Val);
2383 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:2
TAttr SAttrN
Definition: network.h:3369
int TDirNet::AddSAttrDatN ( const TInt NId,
const TInt AttrId,
const TStr Val 
)

Adds Str sparse attribute with id AttrId to the given node with id NId.

Definition at line 2385 of file network.cpp.

2385  {
2386  if (!IsNode(NId)) {
2387  return -1;
2388  }
2389  return SAttrN.AddSAttrDat(NId, AttrId, Val);
2390 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
int AddSAttrDat(const TInt &Id, const TStr &AttrName, const TInt &Val)
Add Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:2
TAttr SAttrN
Definition: network.h:3369
int TDirNet::AddSAttrDatN ( const TNodeI NodeI,
const TStr AttrName,
const TStr Val 
)
inline

Adds Str sparse attribute with name AttrName to NodeI.

Definition at line 3555 of file network.h.

3555  {
3556  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
3557  }
int AddSAttrDatN(const TInt &NId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given node with id NId.
Definition: network.cpp:2350
int TDirNet::AddSAttrDatN ( const TNodeI NodeI,
const TInt AttrId,
const TStr Val 
)
inline

Adds Str sparse attribute with id AttrId to NodeI.

Definition at line 3559 of file network.h.

3559  {
3560  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
3561  }
int AddSAttrDatN(const TInt &NId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given node with id NId.
Definition: network.cpp:2350
int TDirNet::AddSAttrE ( const TStr Name,
const TAttrType AttrType,
TInt AttrId 
)

Adds mapping for sparse attribute with name Name and type AttrType.

Definition at line 2605 of file network.cpp.

2605  {
2606  return SAttrE.AddSAttr(Name, AttrType, AttrId);
2607 }
TAttrPair SAttrE
Definition: network.h:3370
int AddSAttr(const TStr &Name, const TAttrType &AttrType, TInt &AttrIdX)
Adds a mapping for an attribute with name Name and type AttrType.
Definition: attr.cpp:454
int TDirNet::AddSAttrN ( const TStr Name,
const TAttrType AttrType,
TInt AttrId 
)

Adds mapping for sparse attribute with name Name and type AttrType.

Definition at line 2464 of file network.cpp.

2464  {
2465  return SAttrN.AddSAttr(Name, AttrType, AttrId);
2466 }
TAttr SAttrN
Definition: network.h:3369
int AddSAttr(const TStr &Name, const TAttrType &AttrType, TInt &AttrIdX)
Adds a mapping for an attribute with name Name and type AttrType.
Definition: attr.cpp:210
TEdgeI TDirNet::BegEI ( ) const
inline

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

Definition at line 3475 of file network.h.

3475 { TNodeI NI=BegNI(); while(NI<EndNI() && NI.GetOutDeg()==0){NI++;} return TEdgeI(NI, EndNI()); }
int GetOutDeg() const
Returns out-degree of the current node.
Definition: network.h:3321
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:3444
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:3446
TNodeI TDirNet::BegNI ( ) const
inline

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

Definition at line 3444 of file network.h.

3444 { return TNodeI(NodeH.BegI()); }
TIter BegI() const
Definition: hash.h:171
THash< TInt, TNode > NodeH
Definition: network.h:3368
void TDirNet::Clr ( )
inline

Deletes all nodes and edges from the network.

Definition at line 3493 of file network.h.

3493 { MxNId=0; NodeH.Clr(); SAttrN.Clr(); SAttrE.Clr(); }
TAttrPair SAttrE
Definition: network.h:3370
TAttr SAttrN
Definition: network.h:3369
THash< TInt, TNode > NodeH
Definition: network.h:3368
void Clr()
Clears the contents of the attribute map.
Definition: attr.h:114
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:319
TInt MxNId
Definition: network.h:3367
void Clr()
Clears the contents of the attribute map.
Definition: attr.h:29
void TDirNet::Defrag ( const bool &  OnlyNodeLinks = false)

Defragments the network.

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 2270 of file network.cpp.

2270  {
2271  for (int n = NodeH.FFirstKeyId(); NodeH.FNextKeyId(n); ) {
2272  TNode& Node = NodeH[n];
2273  Node.InNIdV.Pack(); Node.OutNIdV.Pack();
2274  }
2275  if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) { NodeH.Defrag(); }
2276 }
bool IsKeyIdEqKeyN() const
Definition: hash.h:191
void Defrag()
Definition: hash.h:513
bool FNextKeyId(int &KeyId) const
Definition: hash.h:436
THash< TInt, TNode > NodeH
Definition: network.h:3368
int FFirstKeyId() const
Definition: hash.h:236
void Pack()
Definition: hash.h:247
void TDirNet::DelEdge ( const int &  SrcNId,
const int &  DstNId,
const bool &  IsDir = true 
)

Deletes an edge from node IDs SrcNId to DstNId from the network.

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 2231 of file network.cpp.

2231  {
2232  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
2233  { TNode& N = GetNode(SrcNId);
2234  TIntPr Id(SrcNId, DstNId);
2235  SAttrE.DelSAttrId(Id);
2236  const int n = N.OutNIdV.SearchBin(DstNId);
2237  if (n!= -1) { N.OutNIdV.Del(n); } }
2238  { TNode& N = GetNode(DstNId);
2239  const int n = N.InNIdV.SearchBin(SrcNId);
2240  if (n!= -1) { N.InNIdV.Del(n); } }
2241  if (! IsDir) {
2242  { TNode& N = GetNode(SrcNId);
2243  const int n = N.InNIdV.SearchBin(DstNId);
2244  if (n!= -1) { N.InNIdV.Del(n); } }
2245  { TNode& N = GetNode(DstNId);
2246  const int n = N.OutNIdV.SearchBin(SrcNId);
2247  if (n!= -1) { N.OutNIdV.Del(n); } }
2248  }
2249 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TNode & GetNode(const int &NId)
Definition: network.h:3372
TAttrPair SAttrE
Definition: network.h:3370
void DelSAttrId(const TIntPr &Id)
Delete all attributes for the given id Id.
Definition: attr.cpp:368
Definition: ds.h:32
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
void TDirNet::DelNode ( const int &  NId)

Deletes node of ID NId from the network.

If the node of ID NId does not exist the function aborts.

Definition at line 2193 of file network.cpp.

2193  {
2194  { TNode& Node = GetNode(NId);
2195  TInt Id(NId);
2196  SAttrN.DelSAttrId(Id);
2197  for (int e = 0; e < Node.GetOutDeg(); e++) {
2198  const int nbr = Node.GetOutNId(e);
2199  if (nbr == NId) { continue; }
2200  TNode& N = GetNode(nbr);
2201  const int n = N.InNIdV.SearchBin(NId);
2202  if (n!= -1) { N.InNIdV.Del(n); }
2203  }
2204  for (int e = 0; e < Node.GetInDeg(); e++) {
2205  const int nbr = Node.GetInNId(e);
2206  if (nbr == NId) { continue; }
2207  TNode& N = GetNode(nbr);
2208  const int n = N.OutNIdV.SearchBin(NId);
2209  if (n!= -1) { N.OutNIdV.Del(n); }
2210  } }
2211  NodeH.DelKey(NId);
2212 }
TNode & GetNode(const int &NId)
Definition: network.h:3372
TAttr SAttrN
Definition: network.h:3369
void DelSAttrId(const TInt &Id)
Delete all attributes for the given id Id.
Definition: attr.cpp:124
void DelKey(const TKey &Key)
Definition: hash.h:362
THash< TInt, TNode > NodeH
Definition: network.h:3368
Definition: dt.h:1044
void TDirNet::DelNode ( const TNode NodeI)
inline

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

Definition at line 3440 of file network.h.

3440 { DelNode(NodeI.GetId()); }
void DelNode(const int &NId)
Deletes node of ID NId from the network.
Definition: network.cpp:2193
int TDirNet::DelSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TStr AttrName 
)

Deletes sparse attribute with name AttrName from edge with ids SrcId and DstId.

Definition at line 2572 of file network.cpp.

2572  {
2573  if (!IsEdge(SrcNId, DstNId)) {
2574  return -1;
2575  }
2576  TIntPr EId(SrcNId, DstNId);
2577  return SAttrE.DelSAttrDat(EId, AttrName);
2578 }
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 network.
Definition: network.cpp:2251
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int DelSAttrDat(const TIntPr &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:347
int TDirNet::DelSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TInt AttrId 
)

Deletes sparse attribute with id AttrId from edge with ids SrcId and DstId.

Definition at line 2580 of file network.cpp.

2580  {
2581  if (!IsEdge(SrcNId, DstNId)) {
2582  return -1;
2583  }
2584  TIntPr EId(SrcNId, DstNId);
2585  return SAttrE.DelSAttrDat(EId, AttrId);
2586 }
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 network.
Definition: network.cpp:2251
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int DelSAttrDat(const TIntPr &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:347
int TDirNet::DelSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName 
)
inline

Deletes sparse attribute with name AttrName from EdgeI.

Definition at line 3729 of file network.h.

3729  {
3730  return DelSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName);
3731  }
int DelSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from edge with ids SrcId and DstId.
Definition: network.cpp:2572
int TDirNet::DelSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId 
)
inline

Deletes sparse attribute with id AttrId from EdgeI.

Definition at line 3733 of file network.h.

3733  {
3734  return DelSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId);
3735  }
int DelSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from edge with ids SrcId and DstId.
Definition: network.cpp:2572
int TDirNet::DelSAttrDatN ( const TInt NId,
const TStr AttrName 
)

Deletes sparse attribute with name AttrName from node with id NId.

Definition at line 2434 of file network.cpp.

2434  {
2435  if (!IsNode(NId)) {
2436  return -1;
2437  }
2438  return SAttrN.DelSAttrDat(NId, AttrName);
2439 }
int DelSAttrDat(const TInt &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:103
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TAttr SAttrN
Definition: network.h:3369
int TDirNet::DelSAttrDatN ( const TInt NId,
const TInt AttrId 
)

Deletes sparse attribute with id AttrId from node with id NId.

Definition at line 2441 of file network.cpp.

2441  {
2442  if (!IsNode(NId)) {
2443  return -1;
2444  }
2445  return SAttrN.DelSAttrDat(NId, AttrId);
2446 }
int DelSAttrDat(const TInt &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:103
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TAttr SAttrN
Definition: network.h:3369
int TDirNet::DelSAttrDatN ( const TNodeI NodeI,
const TStr AttrName 
)
inline

Deletes sparse attribute with name AttrName from NodeI.

Definition at line 3611 of file network.h.

3611  {
3612  return DelSAttrDatN(NodeI.GetId(), AttrName);
3613  }
int DelSAttrDatN(const TInt &NId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:2434
int TDirNet::DelSAttrDatN ( const TNodeI NodeI,
const TInt AttrId 
)
inline

Deletes sparse attribute with id AttrId from NodeI.

Definition at line 3615 of file network.h.

3615  {
3616  return DelSAttrDatN(NodeI.GetId(), AttrId);
3617  }
int DelSAttrDatN(const TInt &NId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:2434
void TDirNet::Dump ( FILE *  OutF = stdout) const

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

Definition at line 2325 of file network.cpp.

2325  {
2326  const int NodePlaces = (int) ceil(log10((double) GetNodes()));
2327  fprintf(OutF, "-------------------------------------------------\nDirected Node Graph: nodes: %d, edges: %d\n", GetNodes(), GetEdges());
2328  for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2329  const TNode& Node = NodeH[N];
2330  fprintf(OutF, " %*d]\n", NodePlaces, Node.GetId());
2331  fprintf(OutF, " in [%d]", Node.GetInDeg());
2332  for (int edge = 0; edge < Node.GetInDeg(); edge++) {
2333  fprintf(OutF, " %*d", NodePlaces, Node.GetInNId(edge)); }
2334  fprintf(OutF, "\n out[%d]", Node.GetOutDeg());
2335  for (int edge = 0; edge < Node.GetOutDeg(); edge++) {
2336  fprintf(OutF, " %*d", NodePlaces, Node.GetOutNId(edge)); }
2337  fprintf(OutF, "\n");
2338  }
2339  fprintf(OutF, "\n");
2340 }
int GetEdges() const
Returns the number of edges in the network.
Definition: network.cpp:2214
bool FNextKeyId(int &KeyId) const
Definition: hash.h:436
THash< TInt, TNode > NodeH
Definition: network.h:3368
int FFirstKeyId() const
Definition: hash.h:236
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:3403
bool TDirNet::Empty ( ) const
inline

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

Definition at line 3491 of file network.h.

3491 { return GetNodes()==0; }
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:3403
TEdgeI TDirNet::EndEI ( ) const
inline

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

Definition at line 3477 of file network.h.

3477 { return TEdgeI(EndNI(), EndNI()); }
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:3446
TNodeI TDirNet::EndNI ( ) const
inline

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

Definition at line 3446 of file network.h.

3446 { return TNodeI(NodeH.EndI()); }
TIter EndI() const
Definition: hash.h:176
THash< TInt, TNode > NodeH
Definition: network.h:3368
int TDirNet::GetEdges ( ) const

Returns the number of edges in the network.

Definition at line 2214 of file network.cpp.

2214  {
2215  int edges=0;
2216  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2217  edges+=NodeH[N].GetOutDeg();
2218  }
2219  return edges;
2220 }
bool FNextKeyId(int &KeyId) const
Definition: hash.h:436
THash< TInt, TNode > NodeH
Definition: network.h:3368
int FFirstKeyId() const
Definition: hash.h:236
TEdgeI TDirNet::GetEI ( const int &  EId) const

Not supported/implemented!

TDirNet::TEdgeI TDirNet::GetEI ( const int &  SrcNId,
const int &  DstNId 
) const

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

Definition at line 2257 of file network.cpp.

2257  {
2258  const TNodeI SrcNI = GetNI(SrcNId);
2259  const int NodeN = SrcNI.NodeHI.GetDat().OutNIdV.SearchBin(DstNId);
2260  IAssert(NodeN != -1);
2261  return TEdgeI(SrcNI, EndNI(), NodeN);
2262 }
#define IAssert(Cond)
Definition: bd.h:262
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
Definition: network.h:3448
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:3446
int TDirNet::GetIdVSAttrE ( const TStr AttrName,
TIntPrV IdV 
) const

Gets a list of all edges that have a sparse attribute with name AttrName.

Definition at line 2597 of file network.cpp.

2597  {
2598  return SAttrE.GetIdVSAttr(AttrName, IdV);
2599 }
TAttrPair SAttrE
Definition: network.h:3370
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntPrV &IdV) const
Definition: attr.cpp:411
int TDirNet::GetIdVSAttrE ( const TInt AttrId,
TIntPrV IdV 
) const

Gets a list of all edges that have a sparse attribute with id AttrId.

Definition at line 2601 of file network.cpp.

2601  {
2602  return SAttrE.GetIdVSAttr(AttrId, IdV);
2603 }
TAttrPair SAttrE
Definition: network.h:3370
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntPrV &IdV) const
Definition: attr.cpp:411
int TDirNet::GetIdVSAttrN ( const TStr AttrName,
TIntV IdV 
) const

Gets a list of all nodes that have a sparse attribute with name AttrName.

Definition at line 2456 of file network.cpp.

2456  {
2457  return SAttrN.GetIdVSAttr(AttrName, IdV);
2458 }
TAttr SAttrN
Definition: network.h:3369
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntV &IdV) const
Definition: attr.cpp:167
int TDirNet::GetIdVSAttrN ( const TInt AttrId,
TIntV IdV 
) const

Gets a list of all nodes that have a sparse attribute with id AttrId.

Definition at line 2460 of file network.cpp.

2460  {
2461  return SAttrN.GetIdVSAttr(AttrId, IdV);
2462 }
TAttr SAttrN
Definition: network.h:3369
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntV &IdV) const
Definition: attr.cpp:167
int TDirNet::GetMxNId ( ) const
inline

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

Definition at line 3452 of file network.h.

3452 { return MxNId; }
TInt MxNId
Definition: network.h:3367
TNodeI TDirNet::GetNI ( const int &  NId) const
inline

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

Definition at line 3448 of file network.h.

3448 { return TNodeI(NodeH.GetI(NId)); }
THash< TInt, TNode > NodeH
Definition: network.h:3368
TIter GetI(const TKey &Key) const
Definition: hash.h:178
void TDirNet::GetNIdV ( TIntV NIdV) const

Gets a vector IDs of all nodes in the network.

Definition at line 2264 of file network.cpp.

2264  {
2265  NIdV.Gen(GetNodes(), 0);
2266  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2267  NIdV.Add(NodeH.GetKey(N)); }
2268 }
bool FNextKeyId(int &KeyId) const
Definition: hash.h:436
THash< TInt, TNode > NodeH
Definition: network.h:3368
int FFirstKeyId() const
Definition: hash.h:236
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:3403
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:495
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:574
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
TNode& TDirNet::GetNode ( const int &  NId)
inlineprivate

Definition at line 3372 of file network.h.

3372 { return NodeH.GetDat(NId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TNode > NodeH
Definition: network.h:3368
const TNode& TDirNet::GetNode ( const int &  NId) const
inlineprivate

Definition at line 3373 of file network.h.

3373 { return NodeH.GetDat(NId); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
THash< TInt, TNode > NodeH
Definition: network.h:3368
int TDirNet::GetNodes ( ) const
inline

Returns the number of nodes in the network.

Definition at line 3403 of file network.h.

3403 { return NodeH.Len(); }
THash< TInt, TNode > NodeH
Definition: network.h:3368
int Len() const
Definition: hash.h:186
TNodeI TDirNet::GetRndNI ( TRnd Rnd = TInt::Rnd)
inline

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

Definition at line 3486 of file network.h.

3486 { return GetNI(GetRndNId(Rnd)); }
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the network.
Definition: network.h:3448
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the network.
Definition: network.h:3484
int TDirNet::GetRndNId ( TRnd Rnd = TInt::Rnd)
inline

Returns an ID of a random node in the network.

Definition at line 3484 of file network.h.

3484 { return NodeH.GetKey(NodeH.GetRndKeyId(Rnd, 0.8)); }
THash< TInt, TNode > NodeH
Definition: network.h:3368
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:402
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
int TDirNet::GetSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TStr AttrName,
TInt ValX 
) const

Gets Int sparse attribute with name AttrName from edge with ids SrcId and DstId.

Definition at line 2524 of file network.cpp.

2524  {
2525  if (!IsEdge(SrcNId, DstNId)) {
2526  return -1;
2527  }
2528  TIntPr EId(SrcNId, DstNId);
2529  return SAttrE.GetSAttrDat(EId, AttrName, Val);
2530 }
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 network.
Definition: network.cpp:2251
int GetSAttrDat(const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:298
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int TDirNet::GetSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TInt AttrId,
TInt ValX 
) const

Gets Int sparse attribute with id AttrId from edge with ids SrcId and DstId.

Definition at line 2532 of file network.cpp.

2532  {
2533  if (!IsEdge(SrcNId, DstNId)) {
2534  return -1;
2535  }
2536  TIntPr EId(SrcNId, DstNId);
2537  return SAttrE.GetSAttrDat(EId, AttrId, Val);
2538 }
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 network.
Definition: network.cpp:2251
int GetSAttrDat(const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:298
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int TDirNet::GetSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName,
TInt ValX 
) const
inline

Gets Int sparse attribute with name AttrName from EdgeI.

Definition at line 3687 of file network.h.

3687  {
3688  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, ValX);
3689  }
int GetSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from edge with ids SrcId and DstId.
Definition: network.cpp:2524
int TDirNet::GetSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId,
TInt ValX 
) const
inline

Gets Int sparse attribute with id AttrId from EdgeI.

Definition at line 3691 of file network.h.

3691  {
3692  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, ValX);
3693  }
int GetSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from edge with ids SrcId and DstId.
Definition: network.cpp:2524
int TDirNet::GetSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TStr AttrName,
TFlt ValX 
) const

Gets Flt sparse attribute with name AttrName from edge with ids SrcId and DstId.

Definition at line 2540 of file network.cpp.

2540  {
2541  if (!IsEdge(SrcNId, DstNId)) {
2542  return -1;
2543  }
2544  TIntPr EId(SrcNId, DstNId);
2545  return SAttrE.GetSAttrDat(EId, AttrName, Val);
2546 }
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 network.
Definition: network.cpp:2251
int GetSAttrDat(const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:298
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int TDirNet::GetSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TInt AttrId,
TFlt ValX 
) const

Gets Flt sparse attribute with id AttrId from edge with ids SrcId and DstId.

Definition at line 2548 of file network.cpp.

2548  {
2549  if (!IsEdge(SrcNId, DstNId)) {
2550  return -1;
2551  }
2552  TIntPr EId(SrcNId, DstNId);
2553  return SAttrE.GetSAttrDat(EId, AttrId, Val);
2554 }
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 network.
Definition: network.cpp:2251
int GetSAttrDat(const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:298
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int TDirNet::GetSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName,
TFlt ValX 
) const
inline

Gets Flt sparse attribute with name AttrName from EdgeI.

Definition at line 3701 of file network.h.

3701  {
3702  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, ValX);
3703  }
int GetSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from edge with ids SrcId and DstId.
Definition: network.cpp:2524
int TDirNet::GetSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId,
TFlt ValX 
) const
inline

Gets Flt sparse attribute with id AttrId from EdgeI.

Definition at line 3705 of file network.h.

3705  {
3706  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, ValX);
3707  }
int GetSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from edge with ids SrcId and DstId.
Definition: network.cpp:2524
int TDirNet::GetSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TStr AttrName,
TStr ValX 
) const

Gets Str sparse attribute with name AttrName from edge with ids SrcId and DstId.

Definition at line 2556 of file network.cpp.

2556  {
2557  if (!IsEdge(SrcNId, DstNId)) {
2558  return -1;
2559  }
2560  TIntPr EId(SrcNId, DstNId);
2561  return SAttrE.GetSAttrDat(EId, AttrName, Val);
2562 }
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 network.
Definition: network.cpp:2251
int GetSAttrDat(const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:298
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int TDirNet::GetSAttrDatE ( const int &  SrcNId,
const int &  DstNId,
const TInt AttrId,
TStr ValX 
) const

Gets Str sparse attribute with id AttrId from edge with ids SrcId and DstId.

Definition at line 2564 of file network.cpp.

2564  {
2565  if (!IsEdge(SrcNId, DstNId)) {
2566  return -1;
2567  }
2568  TIntPr EId(SrcNId, DstNId);
2569  return SAttrE.GetSAttrDat(EId, AttrId, Val);
2570 }
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 network.
Definition: network.cpp:2251
int GetSAttrDat(const TIntPr &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:298
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
int TDirNet::GetSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName,
TStr ValX 
) const
inline

Gets Str sparse attribute with name AttrName from EdgeI.

Definition at line 3715 of file network.h.

3715  {
3716  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, ValX);
3717  }
int GetSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from edge with ids SrcId and DstId.
Definition: network.cpp:2524
int TDirNet::GetSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId,
TStr ValX 
) const
inline

Gets Str sparse attribute with id AttrId from EdgeI.

Definition at line 3719 of file network.h.

3719  {
3720  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, ValX);
3721  }
int GetSAttrDatE(const int &SrcNId, const int &DstNId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from edge with ids SrcId and DstId.
Definition: network.cpp:2524
int TDirNet::GetSAttrDatN ( const TInt NId,
const TStr AttrName,
TInt ValX 
) const

Gets Int sparse attribute with name AttrName from node with id NId.

Definition at line 2392 of file network.cpp.

2392  {
2393  if (!IsNode(NId)) {
2394  return -1;
2395  }
2396  return SAttrN.GetSAttrDat(NId, AttrName, Val);
2397 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TAttr SAttrN
Definition: network.h:3369
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:54
int TDirNet::GetSAttrDatN ( const TInt NId,
const TInt AttrId,
TInt ValX 
) const

Gets Int sparse attribute with id AttrId from node with id NId.

Definition at line 2399 of file network.cpp.

2399  {
2400  if (!IsNode(NId)) {
2401  return -1;
2402  }
2403  return SAttrN.GetSAttrDat(NId, AttrId, Val);
2404 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TAttr SAttrN
Definition: network.h:3369
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:54
int TDirNet::GetSAttrDatN ( const TNodeI NodeI,
const TStr AttrName,
TInt ValX 
) const
inline

Gets Int sparse attribute with name AttrName from NodeI.

Definition at line 3569 of file network.h.

3569  {
3570  return GetSAttrDatN(NodeI.GetId(), AttrName, ValX);
3571  }
int GetSAttrDatN(const TInt &NId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:2392
int TDirNet::GetSAttrDatN ( const TNodeI NodeI,
const TInt AttrId,
TInt ValX 
) const
inline

Gets Int sparse attribute with id AttrId from NodeI.

Definition at line 3573 of file network.h.

3573  {
3574  return GetSAttrDatN(NodeI.GetId(), AttrId, ValX);
3575  }
int GetSAttrDatN(const TInt &NId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:2392
int TDirNet::GetSAttrDatN ( const TInt NId,
const TStr AttrName,
TFlt ValX 
) const

Gets Flt sparse attribute with name AttrName from node with id NId.

Definition at line 2406 of file network.cpp.

2406  {
2407  if (!IsNode(NId)) {
2408  return -1;
2409  }
2410  return SAttrN.GetSAttrDat(NId, AttrName, Val);
2411 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TAttr SAttrN
Definition: network.h:3369
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:54
int TDirNet::GetSAttrDatN ( const TInt NId,
const TInt AttrId,
TFlt ValX 
) const

Gets Flt sparse attribute with id AttrId from node with id NId.

Definition at line 2413 of file network.cpp.

2413  {
2414  if (!IsNode(NId)) {
2415  return -1;
2416  }
2417  return SAttrN.GetSAttrDat(NId, AttrId, Val);
2418 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TAttr SAttrN
Definition: network.h:3369
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:54
int TDirNet::GetSAttrDatN ( const TNodeI NodeI,
const TStr AttrName,
TFlt ValX 
) const
inline

Gets Flt sparse attribute with name AttrName from NodeI.

Definition at line 3583 of file network.h.

3583  {
3584  return GetSAttrDatN(NodeI.GetId(), AttrName, ValX);
3585  }
int GetSAttrDatN(const TInt &NId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:2392
int TDirNet::GetSAttrDatN ( const TNodeI NodeI,
const TInt AttrId,
TFlt ValX 
) const
inline

Gets Flt sparse attribute with id AttrId from NodeI.

Definition at line 3587 of file network.h.

3587  {
3588  return GetSAttrDatN(NodeI.GetId(), AttrId, ValX);
3589  }
int GetSAttrDatN(const TInt &NId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:2392
int TDirNet::GetSAttrDatN ( const TInt NId,
const TStr AttrName,
TStr ValX 
) const

Gets Str sparse attribute with name AttrName from node with id NId.

Definition at line 2420 of file network.cpp.

2420  {
2421  if (!IsNode(NId)) {
2422  return -1;
2423  }
2424  return SAttrN.GetSAttrDat(NId, AttrName, Val);
2425 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TAttr SAttrN
Definition: network.h:3369
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:54
int TDirNet::GetSAttrDatN ( const TInt NId,
const TInt AttrId,
TStr ValX 
) const

Gets Str sparse attribute with id AttrId from node with id NId.

Definition at line 2427 of file network.cpp.

2427  {
2428  if (!IsNode(NId)) {
2429  return -1;
2430  }
2431  return SAttrN.GetSAttrDat(NId, AttrId, Val);
2432 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TAttr SAttrN
Definition: network.h:3369
int GetSAttrDat(const TInt &Id, const TStr &AttrName, TInt &ValX) const
Get Int attribute with name AttrName for the given id Id.
Definition: attr.cpp:54
int TDirNet::GetSAttrDatN ( const TNodeI NodeI,
const TStr AttrName,
TStr ValX 
) const
inline

Gets Str sparse attribute with name AttrName from NodeI.

Definition at line 3597 of file network.h.

3597  {
3598  return GetSAttrDatN(NodeI.GetId(), AttrName, ValX);
3599  }
int GetSAttrDatN(const TInt &NId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:2392
int TDirNet::GetSAttrDatN ( const TNodeI NodeI,
const TInt AttrId,
TStr ValX 
) const
inline

Gets Str sparse attribute with id AttrId from NodeI.

Definition at line 3601 of file network.h.

3601  {
3602  return GetSAttrDatN(NodeI.GetId(), AttrId, ValX);
3603  }
int GetSAttrDatN(const TInt &NId, const TStr &AttrName, TInt &ValX) const
Gets Int sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:2392
int TDirNet::GetSAttrIdE ( const TStr Name,
TInt AttrIdX,
TAttrType AttrTypeX 
) const

Gets id and type for attribute with name Name.

Definition at line 2609 of file network.cpp.

2609  {
2610  return SAttrE.GetSAttrId(Name, AttrId, AttrType);
2611 }
TAttrPair SAttrE
Definition: network.h:3370
int GetSAttrId(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Given the attribute name Name, get the attribute id and type.
Definition: attr.cpp:467
int TDirNet::GetSAttrIdN ( const TStr Name,
TInt AttrIdX,
TAttrType AttrTypeX 
) const

Gets id and type for attribute with name Name.

Definition at line 2468 of file network.cpp.

2468  {
2469  return SAttrN.GetSAttrId(Name, AttrId, AttrType);
2470 }
TAttr SAttrN
Definition: network.h:3369
int GetSAttrId(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Given the attribute name Name, get the attribute id.
Definition: attr.cpp:224
int TDirNet::GetSAttrNameE ( const TInt AttrId,
TStr NameX,
TAttrType AttrTypeX 
) const

Gets name and type for attribute with id AttrId.

Definition at line 2613 of file network.cpp.

2613  {
2614  return SAttrE.GetSAttrName(AttrId, Name, AttrType);
2615 }
TAttrPair SAttrE
Definition: network.h:3370
int GetSAttrName(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Given the attribute id AttrId, get the attribute name and type.
Definition: attr.cpp:477
int TDirNet::GetSAttrNameN ( const TInt AttrId,
TStr NameX,
TAttrType AttrTypeX 
) const

Gets name and type for attribute with id AttrId.

Definition at line 2472 of file network.cpp.

2472  {
2473  return SAttrN.GetSAttrName(AttrId, Name, AttrType);
2474 }
int GetSAttrName(const TInt &AttrId, TStr &NameX, TAttrType &AttrTypeX) const
Given the attribute id AttrId, get the attribute name.
Definition: attr.cpp:233
TAttr SAttrN
Definition: network.h:3369
int TDirNet::GetSAttrVE ( const int &  SrcNId,
const int &  DstNId,
const TAttrType  AttrType,
TAttrPrV AttrV 
) const

Gets a list of all sparse attributes of type AttrType for edge with ids SrcId and DstId.

Definition at line 2588 of file network.cpp.

2588  {
2589  if (!IsEdge(SrcNId, DstNId)) {
2590  return -1;
2591  }
2592  TIntPr EId(SrcNId, DstNId);
2593  SAttrE.GetSAttrV(EId, AttrType, AttrV);
2594  return 0;
2595 }
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 network.
Definition: network.cpp:2251
TAttrPair SAttrE
Definition: network.h:3370
Definition: ds.h:32
void GetSAttrV(const TIntPr &Id, const TAttrType AttrType, TAttrPrV &AttrV) const
Get a list of all attributes of the given type AttrType for the given id Id.
Definition: attr.cpp:383
int TDirNet::GetSAttrVE ( const TEdgeI EdgeI,
const TAttrType  AttrType,
TAttrPrV AttrV 
) const
inline

Gets a list of all sparse attributes of type AttrType for EdgeI.

Definition at line 3739 of file network.h.

3739  {
3740  return GetSAttrVE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrType, AttrV);
3741  }
int GetSAttrVE(const int &SrcNId, const int &DstNId, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for edge with ids SrcId and DstId...
Definition: network.cpp:2588
int TDirNet::GetSAttrVN ( const TInt NId,
const TAttrType  AttrType,
TAttrPrV AttrV 
) const

Gets a list of all sparse attributes of type AttrType for node with id NId.

Definition at line 2448 of file network.cpp.

2448  {
2449  if (!IsNode(NId)) {
2450  return -1;
2451  }
2452  SAttrN.GetSAttrV(NId, AttrType, AttrV);
2453  return 0;
2454 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TAttr SAttrN
Definition: network.h:3369
void GetSAttrV(const TInt &Id, const TAttrType AttrType, TAttrPrV &AttrV) const
Get a list of all attributes of type AttrType for the given id Id.
Definition: attr.cpp:139
int TDirNet::GetSAttrVN ( const TNodeI NodeI,
const TAttrType  AttrType,
TAttrPrV AttrV 
) const
inline

Gets a list of all sparse attributes of type AttrType for NodeI.

Definition at line 3622 of file network.h.

3622  {
3623  return GetSAttrVN(NodeI.GetId(), AttrType, AttrV);
3624  }
int GetSAttrVN(const TInt &NId, const TAttrType AttrType, TAttrPrV &AttrV) const
Gets a list of all sparse attributes of type AttrType for node with id NId.
Definition: network.cpp:2448
PDirNet TDirNet::GetSmallGraph ( )
static

Returns a small network on 5 nodes and 6 edges.

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

Definition at line 2342 of file network.cpp.

2342  {
2343  PDirNet G = TDirNet::New();
2344  for (int i = 0; i < 5; i++) { G->AddNode(i); }
2345  G->AddEdge(0,1); G->AddEdge(1,2); G->AddEdge(0,2);
2346  G->AddEdge(1,3); G->AddEdge(3,4); G->AddEdge(2,3);
2347  return G;
2348 }
Definition: bd.h:196
static PDirNet New()
Static constructor that returns a pointer to the network. Call: PDirNet Graph = TDirNet::New().
Definition: network.h:3386
bool TDirNet::HasFlag ( const TGraphFlag Flag) const

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

Definition at line 2138 of file network.cpp.

2138  {
2139  return HasGraphFlag(TDirNet::TNet, Flag);
2140 }
Directed network.
Definition: network.h:3267
#define HasGraphFlag(TGraph, Flag)
For quick testing of the properties of the graph/network object (see TGraphFlag). ...
Definition: gbase.h:41
bool TDirNet::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 network.

Definition at line 2251 of file network.cpp.

2251  {
2252  if (! IsNode(SrcNId) || ! IsNode(DstNId)) { return false; }
2253  if (IsDir) { return GetNode(SrcNId).IsOutNId(DstNId); }
2254  else { return GetNode(SrcNId).IsOutNId(DstNId) || GetNode(DstNId).IsOutNId(SrcNId); }
2255 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
TNode & GetNode(const int &NId)
Definition: network.h:3372
bool IsOutNId(const int &NId) const
Definition: network.h:3290
bool TDirNet::IsNode ( const int &  NId) const
inline

Tests whether ID NId is a node.

Definition at line 3442 of file network.h.

3442 { return NodeH.IsKey(NId); }
THash< TInt, TNode > NodeH
Definition: network.h:3368
bool IsKey(const TKey &Key) const
Definition: hash.h:216
bool TDirNet::IsOk ( const bool &  ThrowExcept = true) const

Checks the network data structure for internal consistency.

For each node in the graph check that its neighbors are also nodes in the graph.

Definition at line 2279 of file network.cpp.

2279  {
2280  bool RetVal = true;
2281  for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2282  const TNode& Node = NodeH[N];
2283  if (! Node.OutNIdV.IsSorted()) {
2284  const TStr Msg = TStr::Fmt("Out-neighbor list of node %d is not sorted.", Node.GetId());
2285  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2286  }
2287  if (! Node.InNIdV.IsSorted()) {
2288  const TStr Msg = TStr::Fmt("In-neighbor list of node %d is not sorted.", Node.GetId());
2289  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2290  }
2291  // check out-edges
2292  int prevNId = -1;
2293  for (int e = 0; e < Node.GetOutDeg(); e++) {
2294  if (! IsNode(Node.GetOutNId(e))) {
2295  const TStr Msg = TStr::Fmt("Out-edge %d --> %d: node %d does not exist.",
2296  Node.GetId(), Node.GetOutNId(e), Node.GetOutNId(e));
2297  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2298  }
2299  if (e > 0 && prevNId == Node.GetOutNId(e)) {
2300  const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge %d --> %d.",
2301  Node.GetId(), Node.GetId(), Node.GetOutNId(e));
2302  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2303  }
2304  prevNId = Node.GetOutNId(e);
2305  }
2306  // check in-edges
2307  prevNId = -1;
2308  for (int e = 0; e < Node.GetInDeg(); e++) {
2309  if (! IsNode(Node.GetInNId(e))) {
2310  const TStr Msg = TStr::Fmt("In-edge %d <-- %d: node %d does not exist.",
2311  Node.GetId(), Node.GetInNId(e), Node.GetInNId(e));
2312  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2313  }
2314  if (e > 0 && prevNId == Node.GetInNId(e)) {
2315  const TStr Msg = TStr::Fmt("Node %d has duplidate in-edge %d <-- %d.",
2316  Node.GetId(), Node.GetId(), Node.GetInNId(e));
2317  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2318  }
2319  prevNId = Node.GetInNId(e);
2320  }
2321  }
2322  return RetVal;
2323 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3442
void ErrNotify(const char *NotifyCStr)
Definition: bd.h:74
bool FNextKeyId(int &KeyId) const
Definition: hash.h:436
THash< TInt, TNode > NodeH
Definition: network.h:3368
int FFirstKeyId() const
Definition: hash.h:236
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
static PDirNet TDirNet::Load ( TSIn SIn)
inlinestatic

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

Definition at line 3392 of file network.h.

3392 { return PDirNet(new TDirNet(SIn)); }
TDirNet()
Definition: network.h:3375
TPt< TDirNet > PDirNet
Pointer to a directed network (TDirNet)
Definition: network.h:2730
static PDirNet TDirNet::Load_V1 ( TSIn SIn)
inlinestatic

Static constructor that loads the network from a stream SIn and returns a pointer to it. Backwards compatible.

Definition at line 3394 of file network.h.

3394  { PDirNet Graph = PDirNet(new TDirNet());
3395  Graph->MxNId.Load(SIn); Graph->NodeH.Load(SIn); return Graph;
3396  }
TDirNet()
Definition: network.h:3375
Definition: bd.h:196
TPt< TDirNet > PDirNet
Pointer to a directed network (TDirNet)
Definition: network.h:2730
static PDirNet TDirNet::New ( )
inlinestatic

Static constructor that returns a pointer to the network. Call: PDirNet Graph = TDirNet::New().

Definition at line 3386 of file network.h.

3386 { return new TDirNet(); }
TDirNet()
Definition: network.h:3375
static PDirNet TDirNet::New ( const int &  Nodes,
const int &  Edges 
)
inlinestatic

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

Call: PDirNet Net = TDirNet::New(Nodes, Edges).

Definition at line 3390 of file network.h.

3390 { return new TDirNet(Nodes, Edges); }
TDirNet()
Definition: network.h:3375
TDirNet& TDirNet::operator= ( const TDirNet Graph)
inline

Definition at line 3399 of file network.h.

3399  {
3400  if (this!=&Graph) { MxNId=Graph.MxNId; NodeH=Graph.NodeH; } return *this; }
THash< TInt, TNode > NodeH
Definition: network.h:3368
TInt MxNId
Definition: network.h:3367
void TDirNet::Reserve ( const int &  Nodes,
const int &  Edges 
)
inline

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

Definition at line 3495 of file network.h.

3495 { if (Nodes>0) { NodeH.Gen(Nodes/2); } }
void Gen(const int &ExpectVals)
Definition: hash.h:180
THash< TInt, TNode > NodeH
Definition: network.h:3368
void TDirNet::ReserveNIdInDeg ( const int &  NId,
const int &  InDeg 
)
inline

Reserves memory for node ID NId having InDeg in-edges.

Definition at line 3497 of file network.h.

3497 { GetNode(NId).InNIdV.Reserve(InDeg); }
TNode & GetNode(const int &NId)
Definition: network.h:3372
TIntV InNIdV
Definition: network.h:3275
void Reserve(const TSizeTy &_MxVals)
Reserves enough memory for the vector to store _MxVals elements.
Definition: ds.h:515
void TDirNet::ReserveNIdOutDeg ( const int &  NId,
const int &  OutDeg 
)
inline

Reserves memory for node ID NId having OutDeg out-edges.

Definition at line 3499 of file network.h.

3499 { GetNode(NId).OutNIdV.Reserve(OutDeg); }
TNode & GetNode(const int &NId)
Definition: network.h:3372
TIntV OutNIdV
Definition: network.h:3275
void Reserve(const TSizeTy &_MxVals)
Reserves enough memory for the vector to store _MxVals elements.
Definition: ds.h:515
void TDirNet::Save ( TSOut SOut) const
inline

Saves the network to a (binary) stream SOut. Expects data structures for sparse attributes.

Definition at line 3382 of file network.h.

3382 { MxNId.Save(SOut); NodeH.Save(SOut); SAttrN.Save(SOut); SAttrE.Save(SOut); }
void Save(TSOut &SOut) const
Definition: dt.h:1060
TAttrPair SAttrE
Definition: network.h:3370
void Save(TSOut &SOut) const
Definition: hash.h:141
TAttr SAttrN
Definition: network.h:3369
void Save(TSOut &SOut) const
Saves the attributes to a (binary) stream SOut.
Definition: attr.h:110
THash< TInt, TNode > NodeH
Definition: network.h:3368
void Save(TSOut &SOut) const
Saves the attributes to a (binary) stream SOut.
Definition: attr.h:25
TInt MxNId
Definition: network.h:3367
void TDirNet::Save_V1 ( TSOut SOut) const
inline

Saves the network to a (binary) stream SOut. Available for backwards compatibility.

Definition at line 3384 of file network.h.

3384 { MxNId.Save(SOut); NodeH.Save(SOut); }
void Save(TSOut &SOut) const
Definition: dt.h:1060
void Save(TSOut &SOut) const
Definition: hash.h:141
THash< TInt, TNode > NodeH
Definition: network.h:3368
TInt MxNId
Definition: network.h:3367

Friends And Related Function Documentation

friend class TDirNetMtx
friend

Definition at line 3757 of file network.h.

friend class TPt< TDirNet >
friend

Definition at line 3756 of file network.h.

Member Data Documentation

TCRef TDirNet::CRef
private

Definition at line 3366 of file network.h.

TInt TDirNet::MxNId
private

Definition at line 3367 of file network.h.

THash<TInt, TNode> TDirNet::NodeH
private

Definition at line 3368 of file network.h.

TAttrPair TDirNet::SAttrE
private

Definition at line 3370 of file network.h.

TAttr TDirNet::SAttrN
private

Definition at line 3369 of file network.h.


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