SNAP Library 6.0, Developer Reference  2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
TDirNet Class Reference

Directed network. More...

#include <network.h>

Collaboration diagram for TDirNet:

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

Member Typedef Documentation

Definition at line 3969 of file network.h.

Definition at line 3968 of file network.h.

Constructor & Destructor Documentation

TDirNet::TDirNet ( )
inline

Definition at line 4096 of file network.h.

4096 : CRef(), MxNId(0), NodeH(), SAttrN(), SAttrE() { }
TCRef CRef
Definition: network.h:4073
TAttrPair SAttrE
Definition: network.h:4077
TAttr SAttrN
Definition: network.h:4076
THash< TInt, TNode > NodeH
Definition: network.h:4075
TInt MxNId
Definition: network.h:4074
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 4098 of file network.h.

References TNodeEdgeNet< TNodeData, TEdgeData >::Reserve().

4098 : 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:4241
TAttrPair SAttrE
Definition: network.h:4077
TAttr SAttrN
Definition: network.h:4076
TInt MxNId
Definition: network.h:4074

Here is the call graph for this function:

TDirNet::TDirNet ( const TDirNet Graph)
inline

Definition at line 4099 of file network.h.

4099 : MxNId(Graph.MxNId), NodeH(Graph.NodeH), SAttrN(), SAttrE() { }
TAttrPair SAttrE
Definition: network.h:4077
TAttr SAttrN
Definition: network.h:4076
THash< TInt, TNode > NodeH
Definition: network.h:4075
TInt MxNId
Definition: network.h:4074
TDirNet::TDirNet ( TSIn SIn)
inline

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

Definition at line 4101 of file network.h.

4101 : MxNId(SIn), NodeH(SIn), SAttrN(SIn), SAttrE(SIn) { }
TAttrPair SAttrE
Definition: network.h:4077
TAttr SAttrN
Definition: network.h:4076
THash< TInt, TNode > NodeH
Definition: network.h:4075
TInt MxNId
Definition: network.h:4074

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

References TStr::Fmt(), TNEANet::GetNode(), IAssertR, TNEANet::IsEdge(), and TNEANet::IsNode().

2713  {
2714  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
2715  //IAssert(! IsEdge(SrcNId, DstNId));
2716  if (IsEdge(SrcNId, DstNId)) { return -2; }
2717  GetNode(SrcNId).OutNIdV.AddSorted(DstNId);
2718  GetNode(DstNId).InNIdV.AddSorted(SrcNId);
2719  return -1; // no edge id
2720 }
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:2748
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
TNode & GetNode(const int &NId)
Definition: network.h:4079
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:3974
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TIntV OutNIdV
Definition: network.h:3974

Here is the call graph for this function:

int TDirNet::AddEdge ( const TEdgeI EdgeI)
inline

Definition at line 4211 of file network.h.

References AddEdge(), TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

Referenced by AddEdge().

4211 { 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:2713

Here is the call graph for this function:

Here is the caller graph for this function:

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

References TNEANet::GetNode().

2722  {
2723  GetNode(SrcNId).OutNIdV.Add(DstNId);
2724  GetNode(DstNId).InNIdV.Add(SrcNId);
2725  return -1; // no edge id
2726 }
TNode & GetNode(const int &NId)
Definition: network.h:4079
TIntV InNIdV
Definition: network.h:3974
TIntV OutNIdV
Definition: network.h:3974
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602

Here is the call graph for this function:

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

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

2622  {
2623  if (NId == -1) {
2624  NId = MxNId; MxNId++;
2625  } else {
2626  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
2627  MxNId = TMath::Mx(NId+1, MxNId());
2628  }
2629  NodeH.AddDat(NId, TNode(NId));
2630  return NId;
2631 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
THash< TInt, TNode > NodeH
Definition: network.h:4075
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxNId
Definition: network.h:4074
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

int TDirNet::AddNode ( const TNodeI NodeId)
inline

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

Definition at line 4148 of file network.h.

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

Referenced by AddNode().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

References THash< TKey, TDat, THashFunc >::AddDat(), TStr::Fmt(), IAssertR, TDirNet::TNode::Id, TDirNet::TNode::InNIdV, TNEANet::IsNode(), TMath::Mx(), TNEANet::MxNId, TNEANet::NodeH, TDirNet::TNode::OutNIdV, and TVec< TVal, TSizeTy >::Sort().

2646  {
2647  int NewNId;
2648  if (NId == -1) {
2649  NewNId = MxNId; MxNId++;
2650  } else {
2651  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
2652  NewNId = NId;
2653  MxNId = TMath::Mx(NewNId+1, MxNId());
2654  }
2655  TNode& Node = NodeH.AddDat(NewNId);
2656  Node.Id = NewNId;
2657  Node.InNIdV = InNIdV;
2658  Node.OutNIdV = OutNIdV;
2659  Node.InNIdV.Sort();
2660  Node.OutNIdV.Sort();
2661  return NewNId;
2662 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
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:4075
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxNId
Definition: network.h:4074
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

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

References THash< TKey, TDat, THashFunc >::AddDat(), TStr::Fmt(), TVec< TVal, TSizeTy >::GenExt(), TVecPool< TVal, TSizeTy >::GetValVPt(), TVecPool< TVal, TSizeTy >::GetVLen(), IAssertR, TDirNet::TNode::Id, TDirNet::TNode::InNIdV, TNEANet::IsNode(), TMath::Mx(), TNEANet::MxNId, TNEANet::NodeH, TDirNet::TNode::OutNIdV, and TVec< TVal, TSizeTy >::Sort().

2666  {
2667  int NewNId;
2668  if (NId == -1) {
2669  NewNId = MxNId; MxNId++;
2670  } else {
2671  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
2672  NewNId = NId;
2673  MxNId = TMath::Mx(NewNId+1, MxNId());
2674  }
2675  TNode& Node = NodeH.AddDat(NewNId);
2676  Node.Id = NewNId;
2677  Node.InNIdV.GenExt(Pool.GetValVPt(SrcVId), Pool.GetVLen(SrcVId));
2678  Node.OutNIdV.GenExt(Pool.GetValVPt(DstVId), Pool.GetVLen(DstVId));
2679  Node.InNIdV.Sort();
2680  Node.OutNIdV.Sort();
2681  return NewNId;
2682 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
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:1731
int GetVLen(const int &VId) const
Returns the number of elements in the vector with id VId.
Definition: ds.h:1729
THash< TInt, TNode > NodeH
Definition: network.h:4075
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TInt MxNId
Definition: network.h:4074
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

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

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

2633  {
2634  if (NId == -1) {
2635  NId = MxNId; MxNId++;
2636  } else {
2637  if (IsNode(NId)) { return -1;}
2638  MxNId = TMath::Mx(NId+1, MxNId());
2639  }
2640  NodeH.AddDat(NId, TNode(NId));
2641  return NId;
2642 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
THash< TInt, TNode > NodeH
Definition: network.h:4075
TInt MxNId
Definition: network.h:4074
TDat & AddDat(const TKey &Key)
Definition: hash.h:238

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

2973  {
2974  if (!IsEdge(SrcNId, DstNId)) {
2975  return -1;
2976  }
2977  TIntPr EId(SrcNId, DstNId);
2978  return SAttrE.AddSAttrDat(EId, AttrName, Val);
2979 }
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:2748
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

2981  {
2982  if (!IsEdge(SrcNId, DstNId)) {
2983  return -1;
2984  }
2985  TIntPr EId(SrcNId, DstNId);
2986  return SAttrE.AddSAttrDat(EId, AttrId, Val);
2987 }
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:2748
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4393  {
4394  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, Val);
4395  }
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:2973

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4397  {
4398  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, Val);
4399  }
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:2973

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

2989  {
2990  if (!IsEdge(SrcNId, DstNId)) {
2991  return -1;
2992  }
2993  TIntPr EId(SrcNId, DstNId);
2994  return SAttrE.AddSAttrDat(EId, AttrName, Val);
2995 }
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:2748
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

2997  {
2998  if (!IsEdge(SrcNId, DstNId)) {
2999  return -1;
3000  }
3001  TIntPr EId(SrcNId, DstNId);
3002  return SAttrE.AddSAttrDat(EId, AttrId, Val);
3003 }
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:2748
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4407  {
4408  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, Val);
4409  }
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:2973

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4411  {
4412  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, Val);
4413  }
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:2973

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3005  {
3006  if (!IsEdge(SrcNId, DstNId)) {
3007  return -1;
3008  }
3009  TIntPr EId(SrcNId, DstNId);
3010  return SAttrE.AddSAttrDat(EId, AttrName, Val);
3011 }
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:2748
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3013  {
3014  if (!IsEdge(SrcNId, DstNId)) {
3015  return -1;
3016  }
3017  TIntPr EId(SrcNId, DstNId);
3018  return SAttrE.AddSAttrDat(EId, AttrId, Val);
3019 }
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:2748
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4421  {
4422  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, Val);
4423  }
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:2973

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4425  {
4426  return AddSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, Val);
4427  }
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:2973

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2847  {
2848  if (!IsNode(NId)) {
2849  return -1;
2850  }
2851  return SAttrN.AddSAttrDat(NId, AttrName, Val);
2852 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
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:4076

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2854  {
2855  if (!IsNode(NId)) {
2856  return -1;
2857  }
2858  return SAttrN.AddSAttrDat(NId, AttrId, Val);
2859 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
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:4076

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4275  {
4276  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
4277  }
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:2847

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4279  {
4280  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
4281  }
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:2847

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2861  {
2862  if (!IsNode(NId)) {
2863  return -1;
2864  }
2865  return SAttrN.AddSAttrDat(NId, AttrName, Val);
2866 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
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:4076

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2868  {
2869  if (!IsNode(NId)) {
2870  return -1;
2871  }
2872  return SAttrN.AddSAttrDat(NId, AttrId, Val);
2873 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
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:4076

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4289  {
4290  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
4291  }
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:2847

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4293  {
4294  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
4295  }
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:2847

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2875  {
2876  if (!IsNode(NId)) {
2877  return -1;
2878  }
2879  return SAttrN.AddSAttrDat(NId, AttrName, Val);
2880 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
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:4076

Here is the call graph for this function:

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

References TAttr::AddSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2882  {
2883  if (!IsNode(NId)) {
2884  return -1;
2885  }
2886  return SAttrN.AddSAttrDat(NId, AttrId, Val);
2887 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
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:4076

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4303  {
4304  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
4305  }
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:2847

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4307  {
4308  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
4309  }
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:2847

Here is the call graph for this function:

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

References TAttr::AddSAttr(), and TNEANet::SAttrE.

3102  {
3103  return SAttrE.AddSAttr(Name, AttrType, AttrId);
3104 }
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

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

References TAttr::AddSAttr(), and TNEANet::SAttrN.

2961  {
2962  return SAttrN.AddSAttr(Name, AttrType, AttrId);
2963 }
TAttr SAttrN
Definition: network.h:4076
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

Here is the call graph for this function:

TEdgeI TDirNet::BegEI ( ) const
inline

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

Definition at line 4221 of file network.h.

References TNodeEdgeNet< TNodeData, TEdgeData >::BegNI(), TNodeEdgeNet< TNodeData, TEdgeData >::EndNI(), and TDirNet::TNodeI::GetOutDeg().

4221 { 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:4026
TNodeI BegNI() const
Returns an iterator referring to the first node in the network.
Definition: network.h:4181
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:4183

Here is the call graph for this function:

TNodeI TDirNet::BegNI ( ) const
inline

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

Definition at line 4181 of file network.h.

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

4181 { return TNodeI(NodeH.BegI()); }
TIter BegI() const
Definition: hash.h:213
THash< TInt, TNode > NodeH
Definition: network.h:4075

Here is the call graph for this function:

void TDirNet::Clr ( )
inline

Deletes all nodes and edges from the network.

Definition at line 4239 of file network.h.

References TAttr::Clr(), TAttrPair::Clr(), and THash< TKey, TDat, THashFunc >::Clr().

4239 { MxNId=0; NodeH.Clr(); SAttrN.Clr(); SAttrE.Clr(); }
TAttrPair SAttrE
Definition: network.h:4077
TAttr SAttrN
Definition: network.h:4076
THash< TInt, TNode > NodeH
Definition: network.h:4075
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:4074
void Clr()
Clears the contents of the attribute map.
Definition: attr.h:37

Here is the call graph for this function:

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

References THash< TKey, TDat, THashFunc >::Defrag(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TDirNet::TNode::InNIdV, THash< TKey, TDat, THashFunc >::IsKeyIdEqKeyN(), TNEANet::NodeH, TDirNet::TNode::OutNIdV, and TVec< TVal, TSizeTy >::Pack().

2767  {
2768  for (int n = NodeH.FFirstKeyId(); NodeH.FNextKeyId(n); ) {
2769  TNode& Node = NodeH[n];
2770  Node.InNIdV.Pack(); Node.OutNIdV.Pack();
2771  }
2772  if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) { NodeH.Defrag(); }
2773 }
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:4075
int FFirstKeyId() const
Definition: hash.h:278
void Pack()
Definition: hash.h:289

Here is the call graph for this function:

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

References TVec< TVal, TSizeTy >::Del(), TAttr::DelSAttrId(), TStr::Fmt(), TNEANet::GetNode(), IAssertR, TDirNet::TNode::InNIdV, TNEANet::IsNode(), TDirNet::TNode::OutNIdV, TNEANet::SAttrE, and TVec< TVal, TSizeTy >::SearchBin().

2728  {
2729  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
2730  { TNode& N = GetNode(SrcNId);
2731  TIntPr Id(SrcNId, DstNId);
2732  SAttrE.DelSAttrId(Id);
2733  const int n = N.OutNIdV.SearchBin(DstNId);
2734  if (n!= -1) { N.OutNIdV.Del(n); } }
2735  { TNode& N = GetNode(DstNId);
2736  const int n = N.InNIdV.SearchBin(SrcNId);
2737  if (n!= -1) { N.InNIdV.Del(n); } }
2738  if (! IsDir) {
2739  { TNode& N = GetNode(SrcNId);
2740  const int n = N.InNIdV.SearchBin(DstNId);
2741  if (n!= -1) { N.InNIdV.Del(n); } }
2742  { TNode& N = GetNode(DstNId);
2743  const int n = N.OutNIdV.SearchBin(SrcNId);
2744  if (n!= -1) { N.OutNIdV.Del(n); } }
2745  }
2746 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
TNode & GetNode(const int &NId)
Definition: network.h:4079
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

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

References TVec< TVal, TSizeTy >::Del(), THash< TKey, TDat, THashFunc >::DelKey(), TAttr::DelSAttrId(), TDirNet::TNode::GetInDeg(), TDirNet::TNode::GetInNId(), TNEANet::GetNode(), TDirNet::TNode::GetOutDeg(), TDirNet::TNode::GetOutNId(), TDirNet::TNode::InNIdV, TNEANet::NodeH, TDirNet::TNode::OutNIdV, TNEANet::SAttrN, and TVec< TVal, TSizeTy >::SearchBin().

2684  {
2685  { TNode& Node = GetNode(NId);
2686  TInt Id(NId);
2687  SAttrN.DelSAttrId(Id);
2688  for (int e = 0; e < Node.GetOutDeg(); e++) {
2689  const int nbr = Node.GetOutNId(e);
2690  if (nbr == NId) { continue; }
2691  TNode& N = GetNode(nbr);
2692  const int n = N.InNIdV.SearchBin(NId);
2693  if (n!= -1) { N.InNIdV.Del(n); }
2694  }
2695  for (int e = 0; e < Node.GetInDeg(); e++) {
2696  const int nbr = Node.GetInNId(e);
2697  if (nbr == NId) { continue; }
2698  TNode& N = GetNode(nbr);
2699  const int n = N.OutNIdV.SearchBin(NId);
2700  if (n!= -1) { N.OutNIdV.Del(n); }
2701  } }
2702  NodeH.DelKey(NId);
2703 }
TNode & GetNode(const int &NId)
Definition: network.h:4079
TAttr SAttrN
Definition: network.h:4076
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:4075
Definition: dt.h:1137

Here is the call graph for this function:

void TDirNet::DelNode ( const TNode NodeI)
inline

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

Definition at line 4177 of file network.h.

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

Referenced by DelNode().

4177 { DelNode(NodeI.GetId()); }
void DelNode(const int &NId)
Deletes node of ID NId from the network.
Definition: network.cpp:2684

Here is the call graph for this function:

Here is the caller graph for this function:

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

References TAttr::DelSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3069  {
3070  if (!IsEdge(SrcNId, DstNId)) {
3071  return -1;
3072  }
3073  TIntPr EId(SrcNId, DstNId);
3074  return SAttrE.DelSAttrDat(EId, AttrName);
3075 }
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:2748
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

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

References TAttr::DelSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3077  {
3078  if (!IsEdge(SrcNId, DstNId)) {
3079  return -1;
3080  }
3081  TIntPr EId(SrcNId, DstNId);
3082  return SAttrE.DelSAttrDat(EId, AttrId);
3083 }
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:2748
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

int TDirNet::DelSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName 
)
inline

Deletes sparse attribute with name AttrName from EdgeI.

Definition at line 4477 of file network.h.

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4477  {
4478  return DelSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName);
4479  }
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:3069

Here is the call graph for this function:

int TDirNet::DelSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId 
)
inline

Deletes sparse attribute with id AttrId from EdgeI.

Definition at line 4481 of file network.h.

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4481  {
4482  return DelSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId);
4483  }
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:3069

Here is the call graph for this function:

int TDirNet::DelSAttrDatN ( const TInt NId,
const TStr AttrName 
)

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

Definition at line 2931 of file network.cpp.

References TAttr::DelSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2931  {
2932  if (!IsNode(NId)) {
2933  return -1;
2934  }
2935  return SAttrN.DelSAttrDat(NId, AttrName);
2936 }
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:4179
TAttr SAttrN
Definition: network.h:4076

Here is the call graph for this function:

int TDirNet::DelSAttrDatN ( const TInt NId,
const TInt AttrId 
)

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

Definition at line 2938 of file network.cpp.

References TAttr::DelSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2938  {
2939  if (!IsNode(NId)) {
2940  return -1;
2941  }
2942  return SAttrN.DelSAttrDat(NId, AttrId);
2943 }
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:4179
TAttr SAttrN
Definition: network.h:4076

Here is the call graph for this function:

int TDirNet::DelSAttrDatN ( const TNodeI NodeI,
const TStr AttrName 
)
inline

Deletes sparse attribute with name AttrName from NodeI.

Definition at line 4359 of file network.h.

References TDirNet::TNodeI::GetId().

4359  {
4360  return DelSAttrDatN(NodeI.GetId(), AttrName);
4361  }
int DelSAttrDatN(const TInt &NId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:2931

Here is the call graph for this function:

int TDirNet::DelSAttrDatN ( const TNodeI NodeI,
const TInt AttrId 
)
inline

Deletes sparse attribute with id AttrId from NodeI.

Definition at line 4363 of file network.h.

References TDirNet::TNodeI::GetId().

4363  {
4364  return DelSAttrDatN(NodeI.GetId(), AttrId);
4365  }
int DelSAttrDatN(const TInt &NId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:2931

Here is the call graph for this function:

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

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

Definition at line 2822 of file network.cpp.

References edge, THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TNEANet::GetEdges(), TDirNet::TNode::GetId(), TDirNet::TNode::GetInDeg(), TDirNet::TNode::GetInNId(), TNEANet::GetNodes(), TDirNet::TNode::GetOutDeg(), TDirNet::TNode::GetOutNId(), and TNEANet::NodeH.

2822  {
2823  const int NodePlaces = (int) ceil(log10((double) GetNodes()));
2824  fprintf(OutF, "-------------------------------------------------\nDirected Node Graph: nodes: %d, edges: %d\n", GetNodes(), GetEdges());
2825  for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2826  const TNode& Node = NodeH[N];
2827  fprintf(OutF, " %*d]\n", NodePlaces, Node.GetId());
2828  fprintf(OutF, " in [%d]", Node.GetInDeg());
2829  for (int edge = 0; edge < Node.GetInDeg(); edge++) {
2830  fprintf(OutF, " %*d", NodePlaces, Node.GetInNId(edge)); }
2831  fprintf(OutF, "\n out[%d]", Node.GetOutDeg());
2832  for (int edge = 0; edge < Node.GetOutDeg(); edge++) {
2833  fprintf(OutF, " %*d", NodePlaces, Node.GetOutNId(edge)); }
2834  fprintf(OutF, "\n");
2835  }
2836  fprintf(OutF, "\n");
2837 }
int GetEdges() const
Returns the number of edges in the network.
Definition: network.cpp:2705
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
THash< TInt, TNode > NodeH
Definition: network.h:4075
int FFirstKeyId() const
Definition: hash.h:278
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:4134

Here is the call graph for this function:

bool TDirNet::Empty ( ) const
inline

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

Definition at line 4237 of file network.h.

References TNodeEdgeNet< TNodeData, TEdgeData >::GetNodes().

4237 { return GetNodes()==0; }
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:4134

Here is the call graph for this function:

TEdgeI TDirNet::EndEI ( ) const
inline

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

Definition at line 4223 of file network.h.

References TNodeEdgeNet< TNodeData, TEdgeData >::EndNI().

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

Here is the call graph for this function:

TNodeI TDirNet::EndNI ( ) const
inline

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

Definition at line 4183 of file network.h.

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

4183 { return TNodeI(NodeH.EndI()); }
TIter EndI() const
Definition: hash.h:218
THash< TInt, TNode > NodeH
Definition: network.h:4075

Here is the call graph for this function:

int TDirNet::GetEdges ( ) const

Returns the number of edges in the network.

Definition at line 2705 of file network.cpp.

References THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), and TNEANet::NodeH.

2705  {
2706  int edges=0;
2707  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2708  edges+=NodeH[N].GetOutDeg();
2709  }
2710  return edges;
2711 }
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
THash< TInt, TNode > NodeH
Definition: network.h:4075
int FFirstKeyId() const
Definition: hash.h:278

Here is the call graph for this function:

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

References TNEANet::EndNI(), TNEANet::GetNI(), IAssert, and TDirNet::TNodeI::NodeHI.

2754  {
2755  const TNodeI SrcNI = GetNI(SrcNId);
2756  const int NodeN = SrcNI.NodeHI.GetDat().OutNIdV.SearchBin(DstNId);
2757  IAssert(NodeN != -1);
2758  return TEdgeI(SrcNI, EndNI(), NodeN);
2759 }
#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:4185
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:4183

Here is the call graph for this function:

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

References TAttr::GetIdVSAttr(), and TNEANet::SAttrE.

3094  {
3095  return SAttrE.GetIdVSAttr(AttrName, IdV);
3096 }
TAttrPair SAttrE
Definition: network.h:4077
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntPrV &IdV) const
Definition: attr.cpp:411

Here is the call graph for this function:

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

References TAttr::GetIdVSAttr(), and TNEANet::SAttrE.

3098  {
3099  return SAttrE.GetIdVSAttr(AttrId, IdV);
3100 }
TAttrPair SAttrE
Definition: network.h:4077
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntPrV &IdV) const
Definition: attr.cpp:411

Here is the call graph for this function:

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

References TAttr::GetIdVSAttr(), and TNEANet::SAttrN.

2953  {
2954  return SAttrN.GetIdVSAttr(AttrName, IdV);
2955 }
TAttr SAttrN
Definition: network.h:4076
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntV &IdV) const
Definition: attr.cpp:167

Here is the call graph for this function:

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

References TAttr::GetIdVSAttr(), and TNEANet::SAttrN.

2957  {
2958  return SAttrN.GetIdVSAttr(AttrId, IdV);
2959 }
TAttr SAttrN
Definition: network.h:4076
int GetIdVSAttr(const TInt &AttrId, const TAttrType Type, TIntV &IdV) const
Definition: attr.cpp:167

Here is the call graph for this function:

int TDirNet::GetMxNId ( ) const
inline

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

Definition at line 4189 of file network.h.

References TNodeEdgeNet< TNodeData, TEdgeData >::MxNId.

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

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

Definition at line 4185 of file network.h.

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

4185 { return TNodeI(NodeH.GetI(NId)); }
THash< TInt, TNode > NodeH
Definition: network.h:4075
TIter GetI(const TKey &Key) const
Definition: hash.h:220

Here is the call graph for this function:

void TDirNet::GetNIdV ( TIntV NIdV) const

Gets a vector IDs of all nodes in the network.

Definition at line 2761 of file network.cpp.

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

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

Here is the call graph for this function:

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

Definition at line 4079 of file network.h.

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

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

Here is the call graph for this function:

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

Definition at line 4080 of file network.h.

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

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

Here is the call graph for this function:

int TDirNet::GetNodes ( ) const
inline

Returns the number of nodes in the network.

Definition at line 4134 of file network.h.

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

4134 { return NodeH.Len(); }
THash< TInt, TNode > NodeH
Definition: network.h:4075
int Len() const
Definition: hash.h:228

Here is the call graph for this function:

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

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

Definition at line 4232 of file network.h.

References TNodeEdgeNet< TNodeData, TEdgeData >::GetNI(), and TNodeEdgeNet< TNodeData, TEdgeData >::GetRndNId().

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

Here is the call graph for this function:

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

Returns an ID of a random node in the network.

Definition at line 4230 of file network.h.

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

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

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3021  {
3022  if (!IsEdge(SrcNId, DstNId)) {
3023  return -1;
3024  }
3025  TIntPr EId(SrcNId, DstNId);
3026  return SAttrE.GetSAttrDat(EId, AttrName, Val);
3027 }
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:2748
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:4077
Definition: ds.h:32

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3029  {
3030  if (!IsEdge(SrcNId, DstNId)) {
3031  return -1;
3032  }
3033  TIntPr EId(SrcNId, DstNId);
3034  return SAttrE.GetSAttrDat(EId, AttrId, Val);
3035 }
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:2748
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:4077
Definition: ds.h:32

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4435  {
4436  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, ValX);
4437  }
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:3021

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4439  {
4440  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, ValX);
4441  }
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:3021

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3037  {
3038  if (!IsEdge(SrcNId, DstNId)) {
3039  return -1;
3040  }
3041  TIntPr EId(SrcNId, DstNId);
3042  return SAttrE.GetSAttrDat(EId, AttrName, Val);
3043 }
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:2748
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:4077
Definition: ds.h:32

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3045  {
3046  if (!IsEdge(SrcNId, DstNId)) {
3047  return -1;
3048  }
3049  TIntPr EId(SrcNId, DstNId);
3050  return SAttrE.GetSAttrDat(EId, AttrId, Val);
3051 }
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:2748
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:4077
Definition: ds.h:32

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4449  {
4450  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, ValX);
4451  }
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:3021

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4453  {
4454  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, ValX);
4455  }
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:3021

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3053  {
3054  if (!IsEdge(SrcNId, DstNId)) {
3055  return -1;
3056  }
3057  TIntPr EId(SrcNId, DstNId);
3058  return SAttrE.GetSAttrDat(EId, AttrName, Val);
3059 }
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:2748
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:4077
Definition: ds.h:32

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3061  {
3062  if (!IsEdge(SrcNId, DstNId)) {
3063  return -1;
3064  }
3065  TIntPr EId(SrcNId, DstNId);
3066  return SAttrE.GetSAttrDat(EId, AttrId, Val);
3067 }
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:2748
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:4077
Definition: ds.h:32

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4463  {
4464  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrName, ValX);
4465  }
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:3021

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4467  {
4468  return GetSAttrDatE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrId, ValX);
4469  }
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:3021

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2889  {
2890  if (!IsNode(NId)) {
2891  return -1;
2892  }
2893  return SAttrN.GetSAttrDat(NId, AttrName, Val);
2894 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
TAttr SAttrN
Definition: network.h:4076
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

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2896  {
2897  if (!IsNode(NId)) {
2898  return -1;
2899  }
2900  return SAttrN.GetSAttrDat(NId, AttrId, Val);
2901 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
TAttr SAttrN
Definition: network.h:4076
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

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4317  {
4318  return GetSAttrDatN(NodeI.GetId(), AttrName, ValX);
4319  }
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:2889

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4321  {
4322  return GetSAttrDatN(NodeI.GetId(), AttrId, ValX);
4323  }
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:2889

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2903  {
2904  if (!IsNode(NId)) {
2905  return -1;
2906  }
2907  return SAttrN.GetSAttrDat(NId, AttrName, Val);
2908 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
TAttr SAttrN
Definition: network.h:4076
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

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2910  {
2911  if (!IsNode(NId)) {
2912  return -1;
2913  }
2914  return SAttrN.GetSAttrDat(NId, AttrId, Val);
2915 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
TAttr SAttrN
Definition: network.h:4076
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

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4331  {
4332  return GetSAttrDatN(NodeI.GetId(), AttrName, ValX);
4333  }
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:2889

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4335  {
4336  return GetSAttrDatN(NodeI.GetId(), AttrId, ValX);
4337  }
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:2889

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2917  {
2918  if (!IsNode(NId)) {
2919  return -1;
2920  }
2921  return SAttrN.GetSAttrDat(NId, AttrName, Val);
2922 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
TAttr SAttrN
Definition: network.h:4076
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

Here is the call graph for this function:

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

References TAttr::GetSAttrDat(), TNEANet::IsNode(), and TNEANet::SAttrN.

2924  {
2925  if (!IsNode(NId)) {
2926  return -1;
2927  }
2928  return SAttrN.GetSAttrDat(NId, AttrId, Val);
2929 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
TAttr SAttrN
Definition: network.h:4076
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

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4345  {
4346  return GetSAttrDatN(NodeI.GetId(), AttrName, ValX);
4347  }
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:2889

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4349  {
4350  return GetSAttrDatN(NodeI.GetId(), AttrId, ValX);
4351  }
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:2889

Here is the call graph for this function:

int TDirNet::GetSAttrIdE ( const TStr Name,
TInt AttrIdX,
TAttrType AttrTypeX 
) const

Gets id and type for attribute with name Name.

Definition at line 3106 of file network.cpp.

References TAttr::GetSAttrId(), and TNEANet::SAttrE.

3106  {
3107  return SAttrE.GetSAttrId(Name, AttrId, AttrType);
3108 }
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

int TDirNet::GetSAttrIdN ( const TStr Name,
TInt AttrIdX,
TAttrType AttrTypeX 
) const

Gets id and type for attribute with name Name.

Definition at line 2965 of file network.cpp.

References TAttr::GetSAttrId(), and TNEANet::SAttrN.

2965  {
2966  return SAttrN.GetSAttrId(Name, AttrId, AttrType);
2967 }
TAttr SAttrN
Definition: network.h:4076
int GetSAttrId(const TStr &Name, TInt &AttrIdX, TAttrType &AttrTypeX) const
Given the attribute name Name, get the attribute id.
Definition: attr.cpp:224

Here is the call graph for this function:

int TDirNet::GetSAttrNameE ( const TInt AttrId,
TStr NameX,
TAttrType AttrTypeX 
) const

Gets name and type for attribute with id AttrId.

Definition at line 3110 of file network.cpp.

References TAttr::GetSAttrName(), and TNEANet::SAttrE.

3110  {
3111  return SAttrE.GetSAttrName(AttrId, Name, AttrType);
3112 }
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

int TDirNet::GetSAttrNameN ( const TInt AttrId,
TStr NameX,
TAttrType AttrTypeX 
) const

Gets name and type for attribute with id AttrId.

Definition at line 2969 of file network.cpp.

References TAttr::GetSAttrName(), and TNEANet::SAttrN.

2969  {
2970  return SAttrN.GetSAttrName(AttrId, Name, AttrType);
2971 }
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:4076

Here is the call graph for this function:

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

References TAttr::GetSAttrV(), TNEANet::IsEdge(), and TNEANet::SAttrE.

3085  {
3086  if (!IsEdge(SrcNId, DstNId)) {
3087  return -1;
3088  }
3089  TIntPr EId(SrcNId, DstNId);
3090  SAttrE.GetSAttrV(EId, AttrType, AttrV);
3091  return 0;
3092 }
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:2748
TAttrPair SAttrE
Definition: network.h:4077
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

Here is the call graph for this function:

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

References TDirNet::TEdgeI::GetDstNId(), and TDirNet::TEdgeI::GetSrcNId().

4487  {
4488  return GetSAttrVE(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), AttrType, AttrV);
4489  }
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:3085

Here is the call graph for this function:

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

References TAttr::GetSAttrV(), TNEANet::IsNode(), and TNEANet::SAttrN.

2945  {
2946  if (!IsNode(NId)) {
2947  return -1;
2948  }
2949  SAttrN.GetSAttrV(NId, AttrType, AttrV);
2950  return 0;
2951 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
TAttr SAttrN
Definition: network.h:4076
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

Here is the call graph for this function:

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

References TDirNet::TNodeI::GetId().

4370  {
4371  return GetSAttrVN(NodeI.GetId(), AttrType, AttrV);
4372  }
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:2945

Here is the call graph for this function:

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

References New().

2839  {
2840  PDirNet G = TDirNet::New();
2841  for (int i = 0; i < 5; i++) { G->AddNode(i); }
2842  G->AddEdge(0,1); G->AddEdge(1,2); G->AddEdge(0,2);
2843  G->AddEdge(1,3); G->AddEdge(3,4); G->AddEdge(2,3);
2844  return G;
2845 }
Definition: bd.h:196
static PDirNet New()
Static constructor that returns a pointer to the network. Call: PDirNet Graph = TDirNet::New().
Definition: network.h:4107

Here is the call graph for this function:

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

References HasGraphFlag.

2618  {
2619  return HasGraphFlag(TDirNet::TNet, Flag);
2620 }
Directed network.
Definition: network.h:3966
#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 2748 of file network.cpp.

References TNEANet::GetNode(), and TNEANet::IsNode().

2748  {
2749  if (! IsNode(SrcNId) || ! IsNode(DstNId)) { return false; }
2750  if (IsDir) { return GetNode(SrcNId).IsOutNId(DstNId); }
2751  else { return GetNode(SrcNId).IsOutNId(DstNId) || GetNode(DstNId).IsOutNId(SrcNId); }
2752 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
TNode & GetNode(const int &NId)
Definition: network.h:4079
bool IsOutNId(const int &NId) const
Definition: network.h:3989

Here is the call graph for this function:

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

Tests whether ID NId is a node.

Definition at line 4179 of file network.h.

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

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

Here is the call graph for this function:

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

References TStr::CStr(), EAssertR, ErrNotify(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), TStr::Fmt(), THash< TKey, TDat, THashFunc >::FNextKeyId(), TDirNet::TNode::GetId(), TDirNet::TNode::GetInDeg(), TDirNet::TNode::GetInNId(), TDirNet::TNode::GetOutDeg(), TDirNet::TNode::GetOutNId(), TDirNet::TNode::InNIdV, TNEANet::IsNode(), TVec< TVal, TSizeTy >::IsSorted(), TNEANet::NodeH, and TDirNet::TNode::OutNIdV.

2776  {
2777  bool RetVal = true;
2778  for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
2779  const TNode& Node = NodeH[N];
2780  if (! Node.OutNIdV.IsSorted()) {
2781  const TStr Msg = TStr::Fmt("Out-neighbor list of node %d is not sorted.", Node.GetId());
2782  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2783  }
2784  if (! Node.InNIdV.IsSorted()) {
2785  const TStr Msg = TStr::Fmt("In-neighbor list of node %d is not sorted.", Node.GetId());
2786  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2787  }
2788  // check out-edges
2789  int prevNId = -1;
2790  for (int e = 0; e < Node.GetOutDeg(); e++) {
2791  if (! IsNode(Node.GetOutNId(e))) {
2792  const TStr Msg = TStr::Fmt("Out-edge %d --> %d: node %d does not exist.",
2793  Node.GetId(), Node.GetOutNId(e), Node.GetOutNId(e));
2794  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2795  }
2796  if (e > 0 && prevNId == Node.GetOutNId(e)) {
2797  const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge %d --> %d.",
2798  Node.GetId(), Node.GetId(), Node.GetOutNId(e));
2799  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2800  }
2801  prevNId = Node.GetOutNId(e);
2802  }
2803  // check in-edges
2804  prevNId = -1;
2805  for (int e = 0; e < Node.GetInDeg(); e++) {
2806  if (! IsNode(Node.GetInNId(e))) {
2807  const TStr Msg = TStr::Fmt("In-edge %d <-- %d: node %d does not exist.",
2808  Node.GetId(), Node.GetInNId(e), Node.GetInNId(e));
2809  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2810  }
2811  if (e > 0 && prevNId == Node.GetInNId(e)) {
2812  const TStr Msg = TStr::Fmt("Node %d has duplidate in-edge %d <-- %d.",
2813  Node.GetId(), Node.GetId(), Node.GetInNId(e));
2814  if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
2815  }
2816  prevNId = Node.GetInNId(e);
2817  }
2818  }
2819  return RetVal;
2820 }
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:4179
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:4075
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:479

Here is the call graph for this function:

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

4113 { return PDirNet(new TDirNet(SIn)); }
TDirNet()
Definition: network.h:4096
TPt< TDirNet > PDirNet
Pointer to a directed network (TDirNet)
Definition: network.h:3379
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 4115 of file network.h.

4115  { PDirNet Graph = PDirNet(new TDirNet());
4116  Graph->MxNId.Load(SIn); Graph->NodeH.Load(SIn); return Graph;
4117  }
TDirNet()
Definition: network.h:4096
Definition: bd.h:196
TPt< TDirNet > PDirNet
Pointer to a directed network (TDirNet)
Definition: network.h:3379
void TDirNet::LoadNetworkShM ( TShMIn ShMIn)
inlineprivate

Definition at line 4088 of file network.h.

References TAttr::Load(), and THash< TKey, TDat, THashFunc >::LoadShM().

Referenced by LoadShM().

4088  {
4089  MxNId = TInt(ShMIn);
4090  TNodeFunctor f;
4091  NodeH.LoadShM(ShMIn, f);
4092  SAttrN.Load(ShMIn);
4093  SAttrE = TAttrPair(ShMIn);
4094  }
Definition: attr.h:98
TAttrPair SAttrE
Definition: network.h:4077
TAttr SAttrN
Definition: network.h:4076
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:4075
Definition: dt.h:1137
void Load(TSIn &SIn)
Load attribute from input stream.
Definition: attr.h:25
TInt MxNId
Definition: network.h:4074

Here is the call graph for this function:

Here is the caller graph for this function:

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

References LoadNetworkShM().

4123  {
4124  TDirNet* Network = new TDirNet();
4125  Network->LoadNetworkShM(ShMIn);
4126  return PDirNet(Network);
4127  }
Directed network.
Definition: network.h:3966
void LoadNetworkShM(TShMIn &ShMIn)
Definition: network.h:4088
TDirNet()
Definition: network.h:4096
TPt< TDirNet > PDirNet
Pointer to a directed network (TDirNet)
Definition: network.h:3379

Here is the call graph for this function:

static PDirNet TDirNet::New ( )
inlinestatic

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

Definition at line 4107 of file network.h.

Referenced by GetSmallGraph().

4107 { return new TDirNet(); }
TDirNet()
Definition: network.h:4096

Here is the caller graph for this function:

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

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

Definition at line 4130 of file network.h.

References MxNId, and NodeH.

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

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

Definition at line 4241 of file network.h.

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

4241 { if (Nodes>0) { NodeH.Gen(Nodes/2); } }
void Gen(const int &ExpectVals)
Definition: hash.h:222
THash< TInt, TNode > NodeH
Definition: network.h:4075

Here is the call graph for this function:

void TDirNet::ReserveNIdInDeg ( const int &  NId,
const int &  InDeg 
)
inline

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

Definition at line 4243 of file network.h.

References TNodeEdgeNet< TNodeData, TEdgeData >::GetNode().

4243 { GetNode(NId).InNIdV.Reserve(InDeg); }
TNode & GetNode(const int &NId)
Definition: network.h:4079
TIntV InNIdV
Definition: network.h:3974
void Reserve(const TSizeTy &_MxVals)
Reserves enough memory for the vector to store _MxVals elements.
Definition: ds.h:543

Here is the call graph for this function:

void TDirNet::ReserveNIdOutDeg ( const int &  NId,
const int &  OutDeg 
)
inline

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

Definition at line 4245 of file network.h.

References TNodeEdgeNet< TNodeData, TEdgeData >::GetNode().

4245 { GetNode(NId).OutNIdV.Reserve(OutDeg); }
TNode & GetNode(const int &NId)
Definition: network.h:4079
TIntV OutNIdV
Definition: network.h:3974
void Reserve(const TSizeTy &_MxVals)
Reserves enough memory for the vector to store _MxVals elements.
Definition: ds.h:543

Here is the call graph for this function:

void TDirNet::Save ( TSOut SOut) const
inline

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

Definition at line 4103 of file network.h.

References TAttr::Save(), TAttrPair::Save(), THash< TKey, TDat, THashFunc >::Save(), and TInt::Save().

4103 { MxNId.Save(SOut); NodeH.Save(SOut); SAttrN.Save(SOut); SAttrE.Save(SOut); }
void Save(TSOut &SOut) const
Definition: dt.h:1153
TAttrPair SAttrE
Definition: network.h:4077
void Save(TSOut &SOut) const
Definition: hash.h:183
TAttr SAttrN
Definition: network.h:4076
void Save(TSOut &SOut) const
Saves the attributes to a (binary) stream SOut.
Definition: attr.h:118
THash< TInt, TNode > NodeH
Definition: network.h:4075
void Save(TSOut &SOut) const
Saves the attributes to a (binary) stream SOut.
Definition: attr.h:33
TInt MxNId
Definition: network.h:4074

Here is the call graph for this function:

void TDirNet::Save_V1 ( TSOut SOut) const
inline

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

Definition at line 4105 of file network.h.

References THash< TKey, TDat, THashFunc >::Save(), and TInt::Save().

4105 { MxNId.Save(SOut); NodeH.Save(SOut); }
void Save(TSOut &SOut) const
Definition: dt.h:1153
void Save(TSOut &SOut) const
Definition: hash.h:183
THash< TInt, TNode > NodeH
Definition: network.h:4075
TInt MxNId
Definition: network.h:4074

Here is the call graph for this function:

void TDirNet::SortNodeAdjV ( )
inline

Sorts the adjacency lists of each node.

Definition at line 4247 of file network.h.

References TNodeEdgeNet< TNodeData, TEdgeData >::BegNI(), and TNodeEdgeNet< TNodeData, TEdgeData >::EndNI().

4247 { 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:4181
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the network.
Definition: network.h:4183

Here is the call graph for this function:

Friends And Related Function Documentation

friend class TDirNetMtx
friend

Definition at line 4505 of file network.h.

friend class TPt< TDirNet >
friend

Definition at line 4504 of file network.h.

Member Data Documentation

TCRef TDirNet::CRef
private

Definition at line 4073 of file network.h.

TInt TDirNet::MxNId
private

Definition at line 4074 of file network.h.

Referenced by operator=().

THash<TInt, TNode> TDirNet::NodeH
private

Definition at line 4075 of file network.h.

Referenced by operator=().

TAttrPair TDirNet::SAttrE
private

Definition at line 4077 of file network.h.

TAttr TDirNet::SAttrN
private

Definition at line 4076 of file network.h.


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