SNAP Library 4.0, User Reference  2017-07-27 13:18:06
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  TNodeFunctor
 
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 AddNodeUnchecked (int NId=-1)
 Adds a node of ID NId to the network, noop if the node already exists. 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 SrcNId to node DstNId to the network. More...
 
int AddEdgeUnchecked (const int &SrcNId, const int &DstNId)
 Adds an edge from node SrcNId to node DstNId to the network. More...
 
int AddEdge (const TEdgeI &EdgeI)
 
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 SortNodeAdjV ()
 Sorts the adjacency lists of each node. 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 LoadShM (TShMIn &ShMIn)
 Static constructor that loads the network from memory. 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
 
void LoadNetworkShM (TShMIn &ShMIn)
 

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 3714 of file network.h.

Member Typedef Documentation

Definition at line 3717 of file network.h.

Definition at line 3716 of file network.h.

Constructor & Destructor Documentation

TDirNet::TDirNet ( )
inline

Definition at line 3844 of file network.h.

3844 : CRef(), MxNId(0), NodeH(), SAttrN(), SAttrE() { }
TCRef CRef
Definition: network.h:3821
TAttrPair SAttrE
Definition: network.h:3825
TAttr SAttrN
Definition: network.h:3824
THash< TInt, TNode > NodeH
Definition: network.h:3823
TInt MxNId
Definition: network.h:3822
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 3846 of file network.h.

3846 : 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:3989
TAttrPair SAttrE
Definition: network.h:3825
TAttr SAttrN
Definition: network.h:3824
TInt MxNId
Definition: network.h:3822
TDirNet::TDirNet ( const TDirNet Graph)
inline

Definition at line 3847 of file network.h.

3847 : MxNId(Graph.MxNId), NodeH(Graph.NodeH), SAttrN(), SAttrE() { }
TAttrPair SAttrE
Definition: network.h:3825
TAttr SAttrN
Definition: network.h:3824
THash< TInt, TNode > NodeH
Definition: network.h:3823
TInt MxNId
Definition: network.h:3822
TDirNet::TDirNet ( TSIn SIn)
inline

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

Definition at line 3849 of file network.h.

3849 : MxNId(SIn), NodeH(SIn), SAttrN(SIn), SAttrE(SIn) { }
TAttrPair SAttrE
Definition: network.h:3825
TAttr SAttrN
Definition: network.h:3824
THash< TInt, TNode > NodeH
Definition: network.h:3823
TInt MxNId
Definition: network.h:3822

Member Function Documentation

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

Adds an edge from node 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 2391 of file network.cpp.

2391  {
2392  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
2393  //IAssert(! IsEdge(SrcNId, DstNId));
2394  if (IsEdge(SrcNId, DstNId)) { return -2; }
2395  GetNode(SrcNId).OutNIdV.AddSorted(DstNId);
2396  GetNode(DstNId).InNIdV.AddSorted(SrcNId);
2397  return -1; // no edge id
2398 }
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:2426
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
TNode & GetNode(const int &NId)
Definition: network.h:3827
TSizeTy AddSorted(const TVal &Val, const bool &Asc=true, const TSizeTy &_MxVals=-1)
Adds element Val to a sorted vector.
Definition: ds.h:1117
TIntV InNIdV
Definition: network.h:3722
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TIntV OutNIdV
Definition: network.h:3722
int TDirNet::AddEdge ( const TEdgeI EdgeI)
inline

Definition at line 3959 of file network.h.

3959 { return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId()); }
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node SrcNId to node DstNId to the network.
Definition: network.cpp:2391
int TDirNet::AddEdgeUnchecked ( const int &  SrcNId,
const int &  DstNId 
)

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

Returns -1. The method assumes that SrcNId and DstNId are existing nodes in the graph and adds new neighbor values at the end of their adjacency vectors. No checks are performed to verify these assumptions. Adjacency vectors must be sorted and have duplicates removed after a sequence of these operations to assure consistency of data structures.

Definition at line 2400 of file network.cpp.

2400  {
2401  GetNode(SrcNId).OutNIdV.Add(DstNId);
2402  GetNode(DstNId).InNIdV.Add(SrcNId);
2403  return -1; // no edge id
2404 }
TNode & GetNode(const int &NId)
Definition: network.h:3827
TIntV InNIdV
Definition: network.h:3722
TIntV OutNIdV
Definition: network.h:3722
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
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 2300 of file network.cpp.

2300  {
2301  if (NId == -1) {
2302  NId = MxNId; MxNId++;
2303  } else {
2304  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
2305  MxNId = TMath::Mx(NId+1, MxNId());
2306  }
2307  NodeH.AddDat(NId, TNode(NId));
2308  return NId;
2309 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
THash< TInt, TNode > NodeH
Definition: network.h:3823
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxNId
Definition: network.h:3822
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TDirNet::AddNode ( const TNodeI NodeId)
inline

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

Definition at line 3896 of file network.h.

3896 { return AddNode(NodeId.GetId()); }
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Definition: network.cpp:2300
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 2324 of file network.cpp.

2324  {
2325  int NewNId;
2326  if (NId == -1) {
2327  NewNId = MxNId; MxNId++;
2328  } else {
2329  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
2330  NewNId = NId;
2331  MxNId = TMath::Mx(NewNId+1, MxNId());
2332  }
2333  TNode& Node = NodeH.AddDat(NewNId);
2334  Node.Id = NewNId;
2335  Node.InNIdV = InNIdV;
2336  Node.OutNIdV = OutNIdV;
2337  Node.InNIdV.Sort();
2338  Node.OutNIdV.Sort();
2339  return NewNId;
2340 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
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:1318
THash< TInt, TNode > NodeH
Definition: network.h:3823
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxNId
Definition: network.h:3822
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
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 2344 of file network.cpp.

2344  {
2345  int NewNId;
2346  if (NId == -1) {
2347  NewNId = MxNId; MxNId++;
2348  } else {
2349  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
2350  NewNId = NId;
2351  MxNId = TMath::Mx(NewNId+1, MxNId());
2352  }
2353  TNode& Node = NodeH.AddDat(NewNId);
2354  Node.Id = NewNId;
2355  Node.InNIdV.GenExt(Pool.GetValVPt(SrcVId), Pool.GetVLen(SrcVId));
2356  Node.OutNIdV.GenExt(Pool.GetValVPt(DstVId), Pool.GetVLen(DstVId));
2357  Node.InNIdV.Sort();
2358  Node.OutNIdV.Sort();
2359  return NewNId;
2360 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
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:1730
int GetVLen(const int &VId) const
Returns the number of elements in the vector with id VId.
Definition: ds.h:1728
THash< TInt, TNode > NodeH
Definition: network.h:3823
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxNId
Definition: network.h:3822
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TDirNet::AddNodeUnchecked ( int  NId = -1)

Adds a node of ID NId to the network, noop if the node already exists.

Returns -1, if the node NId already exists. Otherwise, it returns the ID of the node being added. If NId is -1, node ID is automatically assigned.

Definition at line 2311 of file network.cpp.

2311  {
2312  if (NId == -1) {
2313  NId = MxNId; MxNId++;
2314  } else {
2315  if (IsNode(NId)) { return -1;}
2316  MxNId = TMath::Mx(NId+1, MxNId());
2317  }
2318  NodeH.AddDat(NId, TNode(NId));
2319  return NId;
2320 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
THash< TInt, TNode > NodeH
Definition: network.h:3823
TInt MxNId
Definition: network.h:3822
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
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 2651 of file network.cpp.

2651  {
2652  if (!IsEdge(SrcNId, DstNId)) {
2653  return -1;
2654  }
2655  TIntPr EId(SrcNId, DstNId);
2656  return SAttrE.AddSAttrDat(EId, AttrName, Val);
2657 }
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:2426
TAttrPair SAttrE
Definition: network.h:3825
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 2659 of file network.cpp.

2659  {
2660  if (!IsEdge(SrcNId, DstNId)) {
2661  return -1;
2662  }
2663  TIntPr EId(SrcNId, DstNId);
2664  return SAttrE.AddSAttrDat(EId, AttrId, Val);
2665 }
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:2426
TAttrPair SAttrE
Definition: network.h:3825
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 4141 of file network.h.

4141  {
4142  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, Val);
4143  }
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:2651
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 4145 of file network.h.

4145  {
4146  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, Val);
4147  }
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:2651
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 2667 of file network.cpp.

2667  {
2668  if (!IsEdge(SrcNId, DstNId)) {
2669  return -1;
2670  }
2671  TIntPr EId(SrcNId, DstNId);
2672  return SAttrE.AddSAttrDat(EId, AttrName, Val);
2673 }
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:2426
TAttrPair SAttrE
Definition: network.h:3825
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 2675 of file network.cpp.

2675  {
2676  if (!IsEdge(SrcNId, DstNId)) {
2677  return -1;
2678  }
2679  TIntPr EId(SrcNId, DstNId);
2680  return SAttrE.AddSAttrDat(EId, AttrId, Val);
2681 }
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:2426
TAttrPair SAttrE
Definition: network.h:3825
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 4155 of file network.h.

4155  {
4156  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, Val);
4157  }
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:2651
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 4159 of file network.h.

4159  {
4160  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, Val);
4161  }
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:2651
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 2683 of file network.cpp.

2683  {
2684  if (!IsEdge(SrcNId, DstNId)) {
2685  return -1;
2686  }
2687  TIntPr EId(SrcNId, DstNId);
2688  return SAttrE.AddSAttrDat(EId, AttrName, Val);
2689 }
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:2426
TAttrPair SAttrE
Definition: network.h:3825
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 2691 of file network.cpp.

2691  {
2692  if (!IsEdge(SrcNId, DstNId)) {
2693  return -1;
2694  }
2695  TIntPr EId(SrcNId, DstNId);
2696  return SAttrE.AddSAttrDat(EId, AttrId, Val);
2697 }
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:2426
TAttrPair SAttrE
Definition: network.h:3825
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 4169 of file network.h.

4169  {
4170  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, Val);
4171  }
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:2651
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 4173 of file network.h.

4173  {
4174  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, Val);
4175  }
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:2651
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 2525 of file network.cpp.

2525  {
2526  if (!IsNode(NId)) {
2527  return -1;
2528  }
2529  return SAttrN.AddSAttrDat(NId, AttrName, Val);
2530 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
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:3824
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 2532 of file network.cpp.

2532  {
2533  if (!IsNode(NId)) {
2534  return -1;
2535  }
2536  return SAttrN.AddSAttrDat(NId, AttrId, Val);
2537 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
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:3824
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 4023 of file network.h.

4023  {
4024  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
4025  }
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:2525
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 4027 of file network.h.

4027  {
4028  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
4029  }
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:2525
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 2539 of file network.cpp.

2539  {
2540  if (!IsNode(NId)) {
2541  return -1;
2542  }
2543  return SAttrN.AddSAttrDat(NId, AttrName, Val);
2544 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
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:3824
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 2546 of file network.cpp.

2546  {
2547  if (!IsNode(NId)) {
2548  return -1;
2549  }
2550  return SAttrN.AddSAttrDat(NId, AttrId, Val);
2551 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
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:3824
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 4037 of file network.h.

4037  {
4038  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
4039  }
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:2525
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 4041 of file network.h.

4041  {
4042  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
4043  }
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:2525
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 2553 of file network.cpp.

2553  {
2554  if (!IsNode(NId)) {
2555  return -1;
2556  }
2557  return SAttrN.AddSAttrDat(NId, AttrName, Val);
2558 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
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:3824
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 2560 of file network.cpp.

2560  {
2561  if (!IsNode(NId)) {
2562  return -1;
2563  }
2564  return SAttrN.AddSAttrDat(NId, AttrId, Val);
2565 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
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:3824
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 4051 of file network.h.

4051  {
4052  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
4053  }
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:2525
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 4055 of file network.h.

4055  {
4056  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
4057  }
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:2525
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 2780 of file network.cpp.

2780  {
2781  return SAttrE.AddSAttr(Name, AttrType, AttrId);
2782 }
TAttrPair SAttrE
Definition: network.h:3825
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 2639 of file network.cpp.

2639  {
2640  return SAttrN.AddSAttr(Name, AttrType, AttrId);
2641 }
TAttr SAttrN
Definition: network.h:3824
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 3969 of file network.h.

3969 { 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:3774
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:3929
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:3931
TNodeI TDirNet::BegNI ( ) const
inline

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

Definition at line 3929 of file network.h.

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

Deletes all nodes and edges from the network.

Definition at line 3987 of file network.h.

3987 { MxNId=0; NodeH.Clr(); SAttrN.Clr(); SAttrE.Clr(); }
TAttrPair SAttrE
Definition: network.h:3825
TAttr SAttrN
Definition: network.h:3824
THash< TInt, TNode > NodeH
Definition: network.h:3823
void Clr()
Clears the contents of the attribute map.
Definition: attr.h:122
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:361
TInt MxNId
Definition: network.h:3822
void Clr()
Clears the contents of the attribute map.
Definition: attr.h:37
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 2445 of file network.cpp.

2445  {
2446  for (int n = NodeH.FFirstKeyId(); NodeH.FNextKeyId(n); ) {
2447  TNode& Node = NodeH[n];
2448  Node.InNIdV.Pack(); Node.OutNIdV.Pack();
2449  }
2450  if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) { NodeH.Defrag(); }
2451 }
bool IsKeyIdEqKeyN() const
Definition: hash.h:233
void Defrag()
Definition: hash.h:555
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
THash< TInt, TNode > NodeH
Definition: network.h:3823
int FFirstKeyId() const
Definition: hash.h:278
void Pack()
Definition: hash.h:289
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 2406 of file network.cpp.

2406  {
2407  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
2408  { TNode& N = GetNode(SrcNId);
2409  TIntPr Id(SrcNId, DstNId);
2410  SAttrE.DelSAttrId(Id);
2411  const int n = N.OutNIdV.SearchBin(DstNId);
2412  if (n!= -1) { N.OutNIdV.Del(n); } }
2413  { TNode& N = GetNode(DstNId);
2414  const int n = N.InNIdV.SearchBin(SrcNId);
2415  if (n!= -1) { N.InNIdV.Del(n); } }
2416  if (! IsDir) {
2417  { TNode& N = GetNode(SrcNId);
2418  const int n = N.InNIdV.SearchBin(DstNId);
2419  if (n!= -1) { N.InNIdV.Del(n); } }
2420  { TNode& N = GetNode(DstNId);
2421  const int n = N.OutNIdV.SearchBin(SrcNId);
2422  if (n!= -1) { N.OutNIdV.Del(n); } }
2423  }
2424 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
TNode & GetNode(const int &NId)
Definition: network.h:3827
TAttrPair SAttrE
Definition: network.h:3825
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 2362 of file network.cpp.

2362  {
2363  { TNode& Node = GetNode(NId);
2364  TInt Id(NId);
2365  SAttrN.DelSAttrId(Id);
2366  for (int e = 0; e < Node.GetOutDeg(); e++) {
2367  const int nbr = Node.GetOutNId(e);
2368  if (nbr == NId) { continue; }
2369  TNode& N = GetNode(nbr);
2370  const int n = N.InNIdV.SearchBin(NId);
2371  if (n!= -1) { N.InNIdV.Del(n); }
2372  }
2373  for (int e = 0; e < Node.GetInDeg(); e++) {
2374  const int nbr = Node.GetInNId(e);
2375  if (nbr == NId) { continue; }
2376  TNode& N = GetNode(nbr);
2377  const int n = N.OutNIdV.SearchBin(NId);
2378  if (n!= -1) { N.OutNIdV.Del(n); }
2379  } }
2380  NodeH.DelKey(NId);
2381 }
TNode & GetNode(const int &NId)
Definition: network.h:3827
TAttr SAttrN
Definition: network.h:3824
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:404
THash< TInt, TNode > NodeH
Definition: network.h:3823
Definition: dt.h:1134
void TDirNet::DelNode ( const TNode NodeI)
inline

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

Definition at line 3925 of file network.h.

3925 { DelNode(NodeI.GetId()); }
void DelNode(const int &NId)
Deletes node of ID NId from the network.
Definition: network.cpp:2362
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 2747 of file network.cpp.

2747  {
2748  if (!IsEdge(SrcNId, DstNId)) {
2749  return -1;
2750  }
2751  TIntPr EId(SrcNId, DstNId);
2752  return SAttrE.DelSAttrDat(EId, AttrName);
2753 }
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:2426
TAttrPair SAttrE
Definition: network.h:3825
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 2755 of file network.cpp.

2755  {
2756  if (!IsEdge(SrcNId, DstNId)) {
2757  return -1;
2758  }
2759  TIntPr EId(SrcNId, DstNId);
2760  return SAttrE.DelSAttrDat(EId, AttrId);
2761 }
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:2426
TAttrPair SAttrE
Definition: network.h:3825
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 4225 of file network.h.

4225  {
4226  return DelSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName);
4227  }
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:2747
int TDirNet::DelSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId 
)
inline

Deletes sparse attribute with id AttrId from EdgeI.

Definition at line 4229 of file network.h.

4229  {
4230  return DelSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId);
4231  }
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:2747
int TDirNet::DelSAttrDatN ( const TInt NId,
const TStr AttrName 
)

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

Definition at line 2609 of file network.cpp.

2609  {
2610  if (!IsNode(NId)) {
2611  return -1;
2612  }
2613  return SAttrN.DelSAttrDat(NId, AttrName);
2614 }
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:3927
TAttr SAttrN
Definition: network.h:3824
int TDirNet::DelSAttrDatN ( const TInt NId,
const TInt AttrId 
)

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

Definition at line 2616 of file network.cpp.

2616  {
2617  if (!IsNode(NId)) {
2618  return -1;
2619  }
2620  return SAttrN.DelSAttrDat(NId, AttrId);
2621 }
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:3927
TAttr SAttrN
Definition: network.h:3824
int TDirNet::DelSAttrDatN ( const TNodeI NodeI,
const TStr AttrName 
)
inline

Deletes sparse attribute with name AttrName from NodeI.

Definition at line 4107 of file network.h.

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

Deletes sparse attribute with id AttrId from NodeI.

Definition at line 4111 of file network.h.

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

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

Definition at line 2500 of file network.cpp.

2500  {
2501  const int NodePlaces = (int) ceil(log10((double) GetNodes()));
2502  fprintf(OutF, "-------------------------------------------------\nDirected Node Graph: nodes: %d, edges: %d\n", GetNodes(), GetEdges());
2503  for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2504  const TNode& Node = NodeH[N];
2505  fprintf(OutF, " %*d]\n", NodePlaces, Node.GetId());
2506  fprintf(OutF, " in [%d]", Node.GetInDeg());
2507  for (int edge = 0; edge < Node.GetInDeg(); edge++) {
2508  fprintf(OutF, " %*d", NodePlaces, Node.GetInNId(edge)); }
2509  fprintf(OutF, "\n out[%d]", Node.GetOutDeg());
2510  for (int edge = 0; edge < Node.GetOutDeg(); edge++) {
2511  fprintf(OutF, " %*d", NodePlaces, Node.GetOutNId(edge)); }
2512  fprintf(OutF, "\n");
2513  }
2514  fprintf(OutF, "\n");
2515 }
int GetEdges() const
Returns the number of edges in the network.
Definition: network.cpp:2383
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
THash< TInt, TNode > NodeH
Definition: network.h:3823
int FFirstKeyId() const
Definition: hash.h:278
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:3882
bool TDirNet::Empty ( ) const
inline

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

Definition at line 3985 of file network.h.

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

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

Definition at line 3971 of file network.h.

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

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

Definition at line 3931 of file network.h.

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

Returns the number of edges in the network.

Definition at line 2383 of file network.cpp.

2383  {
2384  int edges=0;
2385  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2386  edges+=NodeH[N].GetOutDeg();
2387  }
2388  return edges;
2389 }
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
THash< TInt, TNode > NodeH
Definition: network.h:3823
int FFirstKeyId() const
Definition: hash.h:278
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 2432 of file network.cpp.

2432  {
2433  const TNodeI SrcNI = GetNI(SrcNId);
2434  const int NodeN = SrcNI.NodeHI.GetDat().OutNIdV.SearchBin(DstNId);
2435  IAssert(NodeN != -1);
2436  return TEdgeI(SrcNI, EndNI(), NodeN);
2437 }
#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:3933
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:3931
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 2772 of file network.cpp.

2772  {
2773  return SAttrE.GetIdVSAttr(AttrName, IdV);
2774 }
TAttrPair SAttrE
Definition: network.h:3825
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 2776 of file network.cpp.

2776  {
2777  return SAttrE.GetIdVSAttr(AttrId, IdV);
2778 }
TAttrPair SAttrE
Definition: network.h:3825
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 2631 of file network.cpp.

2631  {
2632  return SAttrN.GetIdVSAttr(AttrName, IdV);
2633 }
TAttr SAttrN
Definition: network.h:3824
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 2635 of file network.cpp.

2635  {
2636  return SAttrN.GetIdVSAttr(AttrId, IdV);
2637 }
TAttr SAttrN
Definition: network.h:3824
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 3937 of file network.h.

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

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

Definition at line 3933 of file network.h.

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

Gets a vector IDs of all nodes in the network.

Definition at line 2439 of file network.cpp.

2439  {
2440  NIdV.Gen(GetNodes(), 0);
2441  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2442  NIdV.Add(NodeH.GetKey(N)); }
2443 }
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
THash< TInt, TNode > NodeH
Definition: network.h:3823
int FFirstKeyId() const
Definition: hash.h:278
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:3882
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
TNode& TDirNet::GetNode ( const int &  NId)
inlineprivate

Definition at line 3827 of file network.h.

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

Definition at line 3828 of file network.h.

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

Returns the number of nodes in the network.

Definition at line 3882 of file network.h.

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

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

Definition at line 3980 of file network.h.

3980 { 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:3933
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the network.
Definition: network.h:3978
int TDirNet::GetRndNId ( TRnd Rnd = TInt::Rnd)
inline

Returns an ID of a random node in the network.

Definition at line 3978 of file network.h.

3978 { return NodeH.GetKey(NodeH.GetRndKeyId(Rnd, 0.8)); }
THash< TInt, TNode > NodeH
Definition: network.h:3823
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
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 2699 of file network.cpp.

2699  {
2700  if (!IsEdge(SrcNId, DstNId)) {
2701  return -1;
2702  }
2703  TIntPr EId(SrcNId, DstNId);
2704  return SAttrE.GetSAttrDat(EId, AttrName, Val);
2705 }
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:2426
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:3825
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 2707 of file network.cpp.

2707  {
2708  if (!IsEdge(SrcNId, DstNId)) {
2709  return -1;
2710  }
2711  TIntPr EId(SrcNId, DstNId);
2712  return SAttrE.GetSAttrDat(EId, AttrId, Val);
2713 }
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:2426
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:3825
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 4183 of file network.h.

4183  {
4184  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, ValX);
4185  }
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:2699
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 4187 of file network.h.

4187  {
4188  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, ValX);
4189  }
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:2699
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 2715 of file network.cpp.

2715  {
2716  if (!IsEdge(SrcNId, DstNId)) {
2717  return -1;
2718  }
2719  TIntPr EId(SrcNId, DstNId);
2720  return SAttrE.GetSAttrDat(EId, AttrName, Val);
2721 }
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:2426
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:3825
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 2723 of file network.cpp.

2723  {
2724  if (!IsEdge(SrcNId, DstNId)) {
2725  return -1;
2726  }
2727  TIntPr EId(SrcNId, DstNId);
2728  return SAttrE.GetSAttrDat(EId, AttrId, Val);
2729 }
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:2426
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:3825
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 4197 of file network.h.

4197  {
4198  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, ValX);
4199  }
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:2699
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 4201 of file network.h.

4201  {
4202  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, ValX);
4203  }
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:2699
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 2731 of file network.cpp.

2731  {
2732  if (!IsEdge(SrcNId, DstNId)) {
2733  return -1;
2734  }
2735  TIntPr EId(SrcNId, DstNId);
2736  return SAttrE.GetSAttrDat(EId, AttrName, Val);
2737 }
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:2426
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:3825
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 2739 of file network.cpp.

2739  {
2740  if (!IsEdge(SrcNId, DstNId)) {
2741  return -1;
2742  }
2743  TIntPr EId(SrcNId, DstNId);
2744  return SAttrE.GetSAttrDat(EId, AttrId, Val);
2745 }
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:2426
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:3825
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 4211 of file network.h.

4211  {
4212  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, ValX);
4213  }
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:2699
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 4215 of file network.h.

4215  {
4216  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, ValX);
4217  }
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:2699
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 2567 of file network.cpp.

2567  {
2568  if (!IsNode(NId)) {
2569  return -1;
2570  }
2571  return SAttrN.GetSAttrDat(NId, AttrName, Val);
2572 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
TAttr SAttrN
Definition: network.h:3824
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 2574 of file network.cpp.

2574  {
2575  if (!IsNode(NId)) {
2576  return -1;
2577  }
2578  return SAttrN.GetSAttrDat(NId, AttrId, Val);
2579 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
TAttr SAttrN
Definition: network.h:3824
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 4065 of file network.h.

4065  {
4066  return GetSAttrDatN(NodeI.GetId(), AttrName, ValX);
4067  }
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:2567
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 4069 of file network.h.

4069  {
4070  return GetSAttrDatN(NodeI.GetId(), AttrId, ValX);
4071  }
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:2567
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 2581 of file network.cpp.

2581  {
2582  if (!IsNode(NId)) {
2583  return -1;
2584  }
2585  return SAttrN.GetSAttrDat(NId, AttrName, Val);
2586 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
TAttr SAttrN
Definition: network.h:3824
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 2588 of file network.cpp.

2588  {
2589  if (!IsNode(NId)) {
2590  return -1;
2591  }
2592  return SAttrN.GetSAttrDat(NId, AttrId, Val);
2593 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
TAttr SAttrN
Definition: network.h:3824
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 4079 of file network.h.

4079  {
4080  return GetSAttrDatN(NodeI.GetId(), AttrName, ValX);
4081  }
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:2567
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 4083 of file network.h.

4083  {
4084  return GetSAttrDatN(NodeI.GetId(), AttrId, ValX);
4085  }
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:2567
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 2595 of file network.cpp.

2595  {
2596  if (!IsNode(NId)) {
2597  return -1;
2598  }
2599  return SAttrN.GetSAttrDat(NId, AttrName, Val);
2600 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
TAttr SAttrN
Definition: network.h:3824
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 2602 of file network.cpp.

2602  {
2603  if (!IsNode(NId)) {
2604  return -1;
2605  }
2606  return SAttrN.GetSAttrDat(NId, AttrId, Val);
2607 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
TAttr SAttrN
Definition: network.h:3824
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 4093 of file network.h.

4093  {
4094  return GetSAttrDatN(NodeI.GetId(), AttrName, ValX);
4095  }
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:2567
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 4097 of file network.h.

4097  {
4098  return GetSAttrDatN(NodeI.GetId(), AttrId, ValX);
4099  }
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:2567
int TDirNet::GetSAttrIdE ( const TStr Name,
TInt AttrIdX,
TAttrType AttrTypeX 
) const

Gets id and type for attribute with name Name.

Definition at line 2784 of file network.cpp.

2784  {
2785  return SAttrE.GetSAttrId(Name, AttrId, AttrType);
2786 }
TAttrPair SAttrE
Definition: network.h:3825
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 2643 of file network.cpp.

2643  {
2644  return SAttrN.GetSAttrId(Name, AttrId, AttrType);
2645 }
TAttr SAttrN
Definition: network.h:3824
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 2788 of file network.cpp.

2788  {
2789  return SAttrE.GetSAttrName(AttrId, Name, AttrType);
2790 }
TAttrPair SAttrE
Definition: network.h:3825
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 2647 of file network.cpp.

2647  {
2648  return SAttrN.GetSAttrName(AttrId, Name, AttrType);
2649 }
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:3824
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 2763 of file network.cpp.

2763  {
2764  if (!IsEdge(SrcNId, DstNId)) {
2765  return -1;
2766  }
2767  TIntPr EId(SrcNId, DstNId);
2768  SAttrE.GetSAttrV(EId, AttrType, AttrV);
2769  return 0;
2770 }
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:2426
TAttrPair SAttrE
Definition: network.h:3825
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 4235 of file network.h.

4235  {
4236  return GetSAttrVE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrType, AttrV);
4237  }
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:2763
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 2623 of file network.cpp.

2623  {
2624  if (!IsNode(NId)) {
2625  return -1;
2626  }
2627  SAttrN.GetSAttrV(NId, AttrType, AttrV);
2628  return 0;
2629 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
TAttr SAttrN
Definition: network.h:3824
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 4118 of file network.h.

4118  {
4119  return GetSAttrVN(NodeI.GetId(), AttrType, AttrV);
4120  }
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:2623
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 2517 of file network.cpp.

2517  {
2518  PDirNet G = TDirNet::New();
2519  for (int i = 0; i < 5; i++) { G->AddNode(i); }
2520  G->AddEdge(0,1); G->AddEdge(1,2); G->AddEdge(0,2);
2521  G->AddEdge(1,3); G->AddEdge(3,4); G->AddEdge(2,3);
2522  return G;
2523 }
Definition: bd.h:196
static PDirNet New()
Static constructor that returns a pointer to the network. Call: PDirNet Graph = TDirNet::New().
Definition: network.h:3855
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 2296 of file network.cpp.

2296  {
2297  return HasGraphFlag(TDirNet::TNet, Flag);
2298 }
Directed network.
Definition: network.h:3714
#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 2426 of file network.cpp.

2426  {
2427  if (! IsNode(SrcNId) || ! IsNode(DstNId)) { return false; }
2428  if (IsDir) { return GetNode(SrcNId).IsOutNId(DstNId); }
2429  else { return GetNode(SrcNId).IsOutNId(DstNId) || GetNode(DstNId).IsOutNId(SrcNId); }
2430 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
TNode & GetNode(const int &NId)
Definition: network.h:3827
bool IsOutNId(const int &NId) const
Definition: network.h:3737
bool TDirNet::IsNode ( const int &  NId) const
inline

Tests whether ID NId is a node.

Definition at line 3927 of file network.h.

3927 { return NodeH.IsKey(NId); }
THash< TInt, TNode > NodeH
Definition: network.h:3823
bool IsKey(const TKey &Key) const
Definition: hash.h:258
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 2454 of file network.cpp.

2454  {
2455  bool RetVal = true;
2456  for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2457  const TNode& Node = NodeH[N];
2458  if (! Node.OutNIdV.IsSorted()) {
2459  const TStr Msg = TStr::Fmt("Out-neighbor list of node %d is not sorted.", Node.GetId());
2460  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2461  }
2462  if (! Node.InNIdV.IsSorted()) {
2463  const TStr Msg = TStr::Fmt("In-neighbor list of node %d is not sorted.", Node.GetId());
2464  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2465  }
2466  // check out-edges
2467  int prevNId = -1;
2468  for (int e = 0; e < Node.GetOutDeg(); e++) {
2469  if (! IsNode(Node.GetOutNId(e))) {
2470  const TStr Msg = TStr::Fmt("Out-edge %d --> %d: node %d does not exist.",
2471  Node.GetId(), Node.GetOutNId(e), Node.GetOutNId(e));
2472  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2473  }
2474  if (e > 0 && prevNId == Node.GetOutNId(e)) {
2475  const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge %d --> %d.",
2476  Node.GetId(), Node.GetId(), Node.GetOutNId(e));
2477  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2478  }
2479  prevNId = Node.GetOutNId(e);
2480  }
2481  // check in-edges
2482  prevNId = -1;
2483  for (int e = 0; e < Node.GetInDeg(); e++) {
2484  if (! IsNode(Node.GetInNId(e))) {
2485  const TStr Msg = TStr::Fmt("In-edge %d <-- %d: node %d does not exist.",
2486  Node.GetId(), Node.GetInNId(e), Node.GetInNId(e));
2487  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2488  }
2489  if (e > 0 && prevNId == Node.GetInNId(e)) {
2490  const TStr Msg = TStr::Fmt("Node %d has duplidate in-edge %d <-- %d.",
2491  Node.GetId(), Node.GetId(), Node.GetInNId(e));
2492  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2493  }
2494  prevNId = Node.GetInNId(e);
2495  }
2496  }
2497  return RetVal;
2498 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:3927
void ErrNotify(const char *NotifyCStr)
Definition: bd.h:74
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
THash< TInt, TNode > NodeH
Definition: network.h:3823
int FFirstKeyId() const
Definition: hash.h:278
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 3861 of file network.h.

3861 { return PDirNet(new TDirNet(SIn)); }
TDirNet()
Definition: network.h:3844
TPt< TDirNet > PDirNet
Pointer to a directed network (TDirNet)
Definition: network.h:3127
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 3863 of file network.h.

3863  { PDirNet Graph = PDirNet(new TDirNet());
3864  Graph->MxNId.Load(SIn); Graph->NodeH.Load(SIn); return Graph;
3865  }
TDirNet()
Definition: network.h:3844
Definition: bd.h:196
TPt< TDirNet > PDirNet
Pointer to a directed network (TDirNet)
Definition: network.h:3127
void TDirNet::LoadNetworkShM ( TShMIn ShMIn)
inlineprivate

Definition at line 3836 of file network.h.

3836  {
3837  MxNId = TInt(ShMIn);
3838  TNodeFunctor f;
3839  NodeH.LoadShM(ShMIn, f);
3840  SAttrN.Load(ShMIn);
3841  SAttrE = TAttrPair(ShMIn);
3842  }
Definition: attr.h:98
TAttrPair SAttrE
Definition: network.h:3825
TAttr SAttrN
Definition: network.h:3824
void LoadShM(TShMIn &ShMIn)
Load THash from shared memory file. Copying/Deleting Keys is illegal.
Definition: hash.h:157
THash< TInt, TNode > NodeH
Definition: network.h:3823
Definition: dt.h:1134
void Load(TSIn &SIn)
Load attribute from input stream.
Definition: attr.h:25
TInt MxNId
Definition: network.h:3822
static PDirNet TDirNet::LoadShM ( TShMIn ShMIn)
inlinestatic

Static constructor that loads the network from memory.

The object is read-only. It does not support operations that edit the edge vectors of nodes or perform illegal operations on the NodeH, EdgeH (deletion or swapping keys).

Definition at line 3871 of file network.h.

3871  {
3872  TDirNet* Network = new TDirNet();
3873  Network->LoadNetworkShM(ShMIn);
3874  return PDirNet(Network);
3875  }
Directed network.
Definition: network.h:3714
void LoadNetworkShM(TShMIn &ShMIn)
Definition: network.h:3836
TDirNet()
Definition: network.h:3844
TPt< TDirNet > PDirNet
Pointer to a directed network (TDirNet)
Definition: network.h:3127
static PDirNet TDirNet::New ( )
inlinestatic

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

Definition at line 3855 of file network.h.

3855 { return new TDirNet(); }
TDirNet()
Definition: network.h:3844
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 3859 of file network.h.

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

Definition at line 3878 of file network.h.

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

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

Definition at line 3989 of file network.h.

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

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

Definition at line 3991 of file network.h.

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

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

Definition at line 3993 of file network.h.

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

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

Definition at line 3851 of file network.h.

3851 { MxNId.Save(SOut); NodeH.Save(SOut); SAttrN.Save(SOut); SAttrE.Save(SOut); }
void Save(TSOut &SOut) const
Definition: dt.h:1150
TAttrPair SAttrE
Definition: network.h:3825
void Save(TSOut &SOut) const
Definition: hash.h:183
TAttr SAttrN
Definition: network.h:3824
void Save(TSOut &SOut) const
Saves the attributes to a (binary) stream SOut.
Definition: attr.h:118
THash< TInt, TNode > NodeH
Definition: network.h:3823
void Save(TSOut &SOut) const
Saves the attributes to a (binary) stream SOut.
Definition: attr.h:33
TInt MxNId
Definition: network.h:3822
void TDirNet::Save_V1 ( TSOut SOut) const
inline

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

Definition at line 3853 of file network.h.

3853 { MxNId.Save(SOut); NodeH.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: network.h:3823
TInt MxNId
Definition: network.h:3822
void TDirNet::SortNodeAdjV ( )
inline

Sorts the adjacency lists of each node.

Definition at line 3995 of file network.h.

3995 { for (TNodeI NI = BegNI(); NI < EndNI(); NI++) { NI.SortNIdV();} }
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:3929
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:3931

Friends And Related Function Documentation

friend class TDirNetMtx
friend

Definition at line 4253 of file network.h.

friend class TPt< TDirNet >
friend

Definition at line 4252 of file network.h.

Member Data Documentation

TCRef TDirNet::CRef
private

Definition at line 3821 of file network.h.

TInt TDirNet::MxNId
private

Definition at line 3822 of file network.h.

THash<TInt, TNode> TDirNet::NodeH
private

Definition at line 3823 of file network.h.

TAttrPair TDirNet::SAttrE
private

Definition at line 3825 of file network.h.

TAttr TDirNet::SAttrN
private

Definition at line 3824 of file network.h.


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