SNAP Library 4.0, User Reference  2017-07-27 13:18:06
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TNEANet Class Reference

Directed multigraph with node edge attributes. More...

#include <network.h>

Inherited by TModeNet.

Classes

class  LoadHashOfVecFunctor
 
class  LoadTNodeFunctor
 
class  LoadVecFunctor
 
class  LoadVecOfVecFunctor
 
class  TAFltI
 Node/edge float attribute iterator. Iterates through all nodes/edges for one float attribute. More...
 
class  TAIntI
 Node/edge integer attribute iterator. Iterates through all nodes/edges for one integer attribute. More...
 
class  TAIntVI
 
class  TAStrI
 Node/edge string attribute iterator. Iterates through all nodes/edges for one string attribute. More...
 
class  TEdge
 
class  TEdgeI
 Edge iterator. Only forward iteration (operator++) is supported. More...
 
class  TNode
 
class  TNodeI
 Node iterator. Only forward iteration (operator++) is supported. More...
 

Public Types

typedef TNEANet TNet
 
typedef TPt< TNEANetPNet
 

Public Member Functions

 TNEANet ()
 
 TNEANet (const int &Nodes, const int &Edges)
 Constructor that reserves enough memory for a graph of nodes and edges. More...
 
 TNEANet (const TNEANet &Graph)
 
 TNEANet (TSIn &SIn)
 Constructor for loading the graph from a (binary) stream SIn. More...
 
void Save (TSOut &SOut) const
 Saves the graph to a (binary) stream SOut. Expects data structures for sparse attributes. More...
 
void Save_V1 (TSOut &SOut) const
 Saves the graph to a (binary) stream SOut. Available for backwards compatibility. More...
 
void Save_V2 (TSOut &SOut) const
 Saves the graph without any sparse data structures. Available for backwards compatibility. More...
 
void LoadNetworkShM (TShMIn &ShMIn)
 load network from shared memory for this network More...
 
void ConvertToSparse ()
 
bool HasFlag (const TGraphFlag &Flag) const
 Allows for run-time checking the type of the graph (see the TGraphFlag for flags). More...
 
TNEANetoperator= (const TNEANet &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 &NodeI)
 Adds a node of ID NodeI.GetId() to the graph. More...
 
virtual void DelNode (const int &NId)
 Deletes node of ID NId from the graph. More...
 
void DelNode (const TNode &NodeI)
 Deletes node of ID NodeI.GetId() from the graph. More...
 
bool IsNode (const int &NId) const
 Tests whether ID NId is a node. More...
 
TNodeI BegNI () const
 Returns an iterator referring to the first node in the graph. More...
 
TNodeI EndNI () const
 Returns an iterator referring to the past-the-end node in the graph. More...
 
TNodeI GetNI (const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph. More...
 
TAIntI BegNAIntI (const TStr &attr) const
 Returns an iterator referring to the first node's int attribute. More...
 
TAIntI EndNAIntI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute. More...
 
TAIntI GetNAIntI (const TStr &attr, const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph. More...
 
TAIntVI BegNAIntVI (const TStr &attr) const
 Returns an iterator referring to the first node's int attribute. More...
 
TAIntVI EndNAIntVI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute. More...
 
TAIntVI GetNAIntVI (const TStr &attr, const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph. More...
 
TAStrI BegNAStrI (const TStr &attr) const
 Returns an iterator referring to the first node's str attribute. More...
 
TAStrI EndNAStrI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute. More...
 
TAStrI GetNAStrI (const TStr &attr, const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph. More...
 
TAFltI BegNAFltI (const TStr &attr) const
 Returns an iterator referring to the first node's flt attribute. More...
 
TAFltI EndNAFltI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute. More...
 
TAFltI GetNAFltI (const TStr &attr, const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph. More...
 
void AttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of attr names for node NId. More...
 
void AttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
 
void AttrValueNI (const TInt &NId, TStrV &Values) const
 Returns a vector of attr values for node NId. More...
 
void AttrValueNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Values) const
 
void IntAttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of int attr names for node NId. More...
 
void IntAttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
 
void IntAttrValueNI (const TInt &NId, TIntV &Values) const
 Returns a vector of attr values for node NId. More...
 
void IntAttrValueNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TIntV &Values) const
 
void IntVAttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of int attr names for node NId. More...
 
void IntVAttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
 
void IntVAttrValueNI (const TInt &NId, TVec< TIntV > &Values) const
 Returns a vector of attr values for node NId. More...
 
void IntVAttrValueNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TVec< TIntV > &Values) const
 
void StrAttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of str attr names for node NId. More...
 
void StrAttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
 
void StrAttrValueNI (const TInt &NId, TStrV &Values) const
 Returns a vector of attr values for node NId. More...
 
void StrAttrValueNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Values) const
 
void FltAttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of int attr names for node NId. More...
 
void FltAttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
 
void FltAttrValueNI (const TInt &NId, TFltV &Values) const
 Returns a vector of attr values for node NId. More...
 
void FltAttrValueNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TFltV &Values) const
 
void AttrNameEI (const TInt &EId, TStrV &Names) const
 Returns a vector of attr names for edge EId. More...
 
void AttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
 
void AttrValueEI (const TInt &EId, TStrV &Values) const
 Returns a vector of attr values for edge EId. More...
 
void AttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Values) const
 
void IntAttrNameEI (const TInt &EId, TStrV &Names) const
 Returns a vector of int attr names for edge EId. More...
 
void IntAttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
 
void IntAttrValueEI (const TInt &EId, TIntV &Values) const
 Returns a vector of attr values for edge EId. More...
 
void IntAttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TIntV &Values) const
 
void IntVAttrNameEI (const TInt &EId, TStrV &Names) const
 Returns a vector of int attr names for edge EId. More...
 
void IntVAttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
 
void IntVAttrValueEI (const TInt &EId, TVec< TIntV > &Values) const
 Returns a vector of attr values for edge EId. More...
 
void IntVAttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TVec< TIntV > &Values) const
 
void StrAttrNameEI (const TInt &EId, TStrV &Names) const
 Returns a vector of str attr names for node NId. More...
 
void StrAttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
 
void StrAttrValueEI (const TInt &EId, TStrV &Values) const
 Returns a vector of attr values for node NId. More...
 
void StrAttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Values) const
 
void FltAttrNameEI (const TInt &EId, TStrV &Names) const
 Returns a vector of int attr names for node NId. More...
 
void FltAttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
 
void FltAttrValueEI (const TInt &EId, TFltV &Values) const
 Returns a vector of attr values for node NId. More...
 
void FltAttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TFltV &Values) const
 
TAIntI BegEAIntI (const TStr &attr) const
 Returns an iterator referring to the first edge's int attribute. More...
 
TAIntI EndEAIntI (const TStr &attr) const
 Returns an iterator referring to the past-the-end edge's attribute. More...
 
TAIntI GetEAIntI (const TStr &attr, const int &EId) const
 Returns an iterator referring to the edge of ID EId in the graph. More...
 
TAIntVI BegEAIntVI (const TStr &attr) const
 Returns an iterator referring to the first edge's int attribute. More...
 
TAIntVI EndEAIntVI (const TStr &attr) const
 Returns an iterator referring to the past-the-end edge's attribute. More...
 
TAIntVI GetEAIntVI (const TStr &attr, const int &EId) const
 Returns an iterator referring to the edge of ID EId in the graph. More...
 
TAStrI BegEAStrI (const TStr &attr) const
 Returns an iterator referring to the first edge's str attribute. More...
 
TAStrI EndEAStrI (const TStr &attr) const
 Returns an iterator referring to the past-the-end edge's attribute. More...
 
TAStrI GetEAStrI (const TStr &attr, const int &EId) const
 Returns an iterator referring to the edge of ID EId in the graph. More...
 
TAFltI BegEAFltI (const TStr &attr) const
 Returns an iterator referring to the first edge's flt attribute. More...
 
TAFltI EndEAFltI (const TStr &attr) const
 Returns an iterator referring to the past-the-end edge's attribute. More...
 
TAFltI GetEAFltI (const TStr &attr, const int &EId) const
 Returns an iterator referring to the edge of ID EId in the graph. More...
 
int GetMxNId () const
 Returns an ID that is larger than any node ID in the network. More...
 
int GetMxEId () const
 Returns an ID that is larger than any edge ID in the network. More...
 
int GetEdges () const
 Returns the number of edges in the graph. More...
 
int AddEdge (const int &SrcNId, const int &DstNId, int EId=-1)
 Adds an edge with ID EId between node IDs SrcNId and DstNId to the graph. More...
 
int AddEdge (const TEdgeI &EdgeI)
 Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph. More...
 
void DelEdge (const int &EId)
 Deletes an edge with edge ID EId from the graph. More...
 
void DelEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true)
 Deletes all edges between node IDs SrcNId and DstNId from the graph. More...
 
bool IsEdge (const int &EId) const
 Tests whether an edge with edge ID EId exists in the graph. More...
 
bool IsEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true) const
 Tests whether an edge between node IDs SrcNId and DstNId exists in the graph. More...
 
bool IsEdge (const int &SrcNId, const int &DstNId, int &EId, const bool &IsDir=true) const
 Tests whether an edge between node IDs SrcNId and DstNId exists in the graph. if an edge exists, return its edge ID in EId. More...
 
int GetEId (const int &SrcNId, const int &DstNId) const
 Returns an edge ID between node IDs SrcNId and DstNId, if such an edge exists. Otherwise, return -1. More...
 
TEdgeI BegEI () const
 Returns an iterator referring to the first edge in the graph. More...
 
TEdgeI EndEI () const
 Returns an iterator referring to the past-the-end edge in the graph. More...
 
TEdgeI GetEI (const int &EId) const
 Returns an iterator referring to edge with edge ID EId. More...
 
TEdgeI GetEI (const int &SrcNId, const int &DstNId) const
 Returns an iterator referring to edge (SrcNId, DstNId) in the graph. More...
 
int GetRndNId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random node in the graph. More...
 
TNodeI GetRndNI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random node in the graph. More...
 
int GetRndEId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random edge in the graph. More...
 
TEdgeI GetRndEI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random edge in the graph. More...
 
void GetNIdV (TIntV &NIdV) const
 Gets a vector IDs of all nodes in the graph. More...
 
void GetEIdV (TIntV &EIdV) const
 Gets a vector IDs of all edges in the graph. More...
 
bool Empty () const
 Tests whether the graph is empty (has zero nodes). More...
 
void Clr ()
 Deletes all nodes and edges from the graph. More...
 
void Reserve (const int &Nodes, const int &Edges)
 Reserves memory for a graph of Nodes nodes and Edges edges. More...
 
void Defrag (const bool &OnlyNodeLinks=false)
 Defragments the graph. More...
 
bool IsOk (const bool &ThrowExcept=true) const
 Checks the graph data structure for internal consistency. More...
 
void Dump (FILE *OutF=stdout) const
 Print the graph in a human readable form to an output stream OutF. More...
 
int AddIntAttrDatN (const TNodeI &NodeI, const TInt &value, const TStr &attr)
 Attribute based add function for attr to Int value. More...
 
int AddIntAttrDatN (const int &NId, const TInt &value, const TStr &attr)
 
int AddStrAttrDatN (const TNodeI &NodeI, const TStr &value, const TStr &attr)
 Attribute based add function for attr to Str value. More...
 
int AddStrAttrDatN (const int &NId, const TStr &value, const TStr &attr)
 
int AddFltAttrDatN (const TNodeI &NodeI, const TFlt &value, const TStr &attr)
 Attribute based add function for attr to Flt value. More...
 
int AddFltAttrDatN (const int &NId, const TFlt &value, const TStr &attr)
 
int AddIntVAttrDatN (const TNodeI &NodeI, const TIntV &value, const TStr &attr)
 Attribute based add function for attr to IntV value. More...
 
int AddIntVAttrDatN (const int &NId, const TIntV &value, const TStr &attr, TBool UseDense=true)
 
int AppendIntVAttrDatN (const TNodeI &NodeI, const TInt &value, const TStr &attr)
 Appends value onto the TIntV attribute for the given node. More...
 
int AppendIntVAttrDatN (const int &NId, const TInt &value, const TStr &attr, TBool UseDense=true)
 
int DelFromIntVAttrDatN (const TNodeI &NodeI, const TInt &value, const TStr &attr)
 Deletes value from the TIntV attribute for the given node. More...
 
int DelFromIntVAttrDatN (const int &NId, const TInt &value, const TStr &attr)
 
int AddIntAttrDatE (const TEdgeI &EdgeI, const TInt &value, const TStr &attr)
 Attribute based add function for attr to Int value. More...
 
int AddIntAttrDatE (const int &EId, const TInt &value, const TStr &attr)
 
int AddStrAttrDatE (const TEdgeI &EdgeI, const TStr &value, const TStr &attr)
 Attribute based add function for attr to Str value. More...
 
int AddStrAttrDatE (const int &EId, const TStr &value, const TStr &attr)
 
int AddFltAttrDatE (const TEdgeI &EdgeI, const TFlt &value, const TStr &attr)
 Attribute based add function for attr to Flt value. More...
 
int AddFltAttrDatE (const int &EId, const TFlt &value, const TStr &attr)
 
int AddIntVAttrDatE (const TEdgeI &EdgeI, const TIntV &value, const TStr &attr)
 Attribute based add function for attr to IntV value. More...
 
int AddIntVAttrDatE (const int &EId, const TIntV &value, const TStr &attr, TBool UseDense=true)
 
int AppendIntVAttrDatE (const TEdgeI &EdgeI, const TInt &value, const TStr &attr)
 Appends value onto the TIntV attribute for the given node. More...
 
int AppendIntVAttrDatE (const int &EId, const TInt &value, const TStr &attr, TBool UseDense=true)
 
TInt GetIntAttrDatN (const TNodeI &NodeI, const TStr &attr)
 Gets the value of int attr from the node attr value vector. More...
 
TInt GetIntAttrDatN (const int &NId, const TStr &attr)
 
TStr GetStrAttrDatN (const TNodeI &NodeI, const TStr &attr)
 Gets the value of str attr from the node attr value vector. More...
 
TStr GetStrAttrDatN (const int &NId, const TStr &attr)
 
TFlt GetFltAttrDatN (const TNodeI &NodeI, const TStr &attr)
 Gets the value of flt attr from the node attr value vector. More...
 
TFlt GetFltAttrDatN (const int &NId, const TStr &attr)
 
TIntV GetIntVAttrDatN (const TNodeI &NodeI, const TStr &attr) const
 Gets the value of the intv attr from the node attr value vector. More...
 
TIntV GetIntVAttrDatN (const int &NId, const TStr &attr) const
 
int GetIntAttrIndN (const TStr &attr)
 Gets the index of the node attr value vector specified by attr (same as GetAttrIndN for compatibility reasons). More...
 
int GetAttrIndN (const TStr &attr)
 Gets the index of the node attr value vector specified by attr. More...
 
TInt GetIntAttrIndDatN (const TNodeI &NodeI, const int &index)
 Gets the value of an int node attr specified by node iterator NodeI and the attr index. More...
 
TInt GetIntAttrIndDatN (const int &NId, const int &index)
 Gets the value of an int node attr specified by node ID NId and the attr index. More...
 
TStr GetStrAttrIndDatN (const TNodeI &NodeI, const int &index)
 Gets the value of a string node attr specified by node iterator NodeI and the attr index. More...
 
TStr GetStrAttrIndDatN (const int &NId, const int &index)
 Gets the value of a string node attr specified by node ID NId and the attr index. More...
 
TFlt GetFltAttrIndDatN (const TNodeI &NodeI, const int &index)
 Gets the value of a float node attr specified by node iterator NodeI and the attr index. More...
 
TFlt GetFltAttrIndDatN (const int &NId, const int &index)
 Gets the value of a float node attr specified by node ID NId and the attr index. More...
 
TInt GetIntAttrDatE (const TEdgeI &EdgeI, const TStr &attr)
 Gets the value of int attr from the edge attr value vector. More...
 
TInt GetIntAttrDatE (const int &EId, const TStr &attr)
 
TStr GetStrAttrDatE (const TEdgeI &EdgeI, const TStr &attr)
 Gets the value of str attr from the edge attr value vector. More...
 
TStr GetStrAttrDatE (const int &EId, const TStr &attr)
 
TFlt GetFltAttrDatE (const TEdgeI &EdgeI, const TStr &attr)
 Gets the value of flt attr from the edge attr value vector. More...
 
TFlt GetFltAttrDatE (const int &EId, const TStr &attr)
 
TIntV GetIntVAttrDatE (const TEdgeI &EdgeI, const TStr &attr)
 Gets the value of the intv attr from the edge attr value vector. More...
 
TIntV GetIntVAttrDatE (const int &EId, const TStr &attr)
 
int GetIntAttrIndE (const TStr &attr)
 Gets the index of the edge attr value vector specified by attr (same as GetAttrIndE for compatibility reasons). More...
 
int GetAttrIndE (const TStr &attr)
 Gets the index of the edge attr value vector specified by attr. More...
 
TInt GetIntAttrIndDatE (const TEdgeI &EdgeI, const int &index)
 Gets the value of an int edge attr specified by edge iterator EdgeI and the attr index. More...
 
TInt GetIntAttrIndDatE (const int &EId, const int &index)
 Gets the value of an int edge attr specified by edge ID EId and the attr index. More...
 
TFlt GetFltAttrIndDatE (const TEdgeI &EdgeI, const int &index)
 Gets the value of a float edge attr specified by edge iterator EdgeI and the attr index. More...
 
TFlt GetFltAttrIndDatE (const int &EId, const int &index)
 Gets the value of an int edge attr specified by edge ID EId and the attr index. More...
 
TStr GetStrAttrIndDatE (const TEdgeI &EdgeI, const int &index)
 Gets the value of a string edge attr specified by edge iterator EdgeI and the attr index. More...
 
TStr GetStrAttrIndDatE (const int &EId, const int &index)
 Gets the value of an int edge attr specified by edge ID EId and the attr index. More...
 
int DelAttrDatN (const TNodeI &NodeI, const TStr &attr)
 Deletes the node attribute for NodeI. More...
 
int DelAttrDatN (const int &NId, const TStr &attr)
 
int DelAttrDatE (const TEdgeI &EdgeI, const TStr &attr)
 Deletes the edge attribute for NodeI. More...
 
int DelAttrDatE (const int &EId, const TStr &attr)
 
int AddIntAttrN (const TStr &attr, TInt defaultValue=TInt::Mn)
 Adds a new Int node attribute to the hashmap. More...
 
int AddStrAttrN (const TStr &attr, TStr defaultValue=TStr::GetNullStr())
 Adds a new Str node attribute to the hashmap. More...
 
int AddFltAttrN (const TStr &attr, TFlt defaultValue=TFlt::Mn)
 Adds a new Flt node attribute to the hashmap. More...
 
int AddIntVAttrN (const TStr &attr, TBool UseDense=true)
 Adds a new IntV node attribute to the hashmap. More...
 
int AddIntAttrE (const TStr &attr, TInt defaultValue=TInt::Mn)
 Adds a new Int edge attribute to the hashmap. More...
 
int AddStrAttrE (const TStr &attr, TStr defaultValue=TStr::GetNullStr())
 Adds a new Str edge attribute to the hashmap. More...
 
int AddFltAttrE (const TStr &attr, TFlt defaultValue=TFlt::Mn)
 Adds a new Flt edge attribute to the hashmap. More...
 
int AddIntVAttrE (const TStr &attr, TBool UseDense=true)
 Adds a new IntV edge attribute to the hashmap. More...
 
int DelAttrN (const TStr &attr)
 Removes all the values for node attr. More...
 
int DelAttrE (const TStr &attr)
 Removes all the values for edge attr. More...
 
bool IsAttrDeletedN (const int &NId, const TStr &attr) const
 Returns true if attr exists for node NId and has default value. More...
 
bool IsIntAttrDeletedN (const int &NId, const TStr &attr) const
 Returns true if Int attr exists for node NId and has default value. More...
 
bool IsIntVAttrDeletedN (const int &NId, const TStr &attr) const
 Returns true if IntV attr exists for node NId and is an empty vector. More...
 
bool IsStrAttrDeletedN (const int &NId, const TStr &attr) const
 Returns true if Str attr exists for node NId and has default value. More...
 
bool IsFltAttrDeletedN (const int &NId, const TStr &attr) const
 Returns true if Flt attr exists for node NId and has default value. More...
 
bool NodeAttrIsDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 Returns true if NId attr deleted for current node attr iterator. More...
 
bool NodeAttrIsIntDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 Returns true if NId attr deleted value for current node int attr iterator. More...
 
bool NodeAttrIsIntVDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 Returns true if NId attr deleted value for current node int vector attr iterator. More...
 
bool NodeAttrIsStrDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 Returns true if NId attr deleted value for current node str attr iterator. More...
 
bool NodeAttrIsFltDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 Returns true if NId attr deleted value for current node flt attr iterator. More...
 
bool IsAttrDeletedE (const int &EId, const TStr &attr) const
 Returns true if attr exists for edge EId and has default value. More...
 
bool IsIntAttrDeletedE (const int &EId, const TStr &attr) const
 Returns true if Int attr exists for edge EId and has default value. More...
 
bool IsIntVAttrDeletedE (const int &EId, const TStr &attr) const
 Returns true if IntV attr exists for edge EId and is an empty vector. More...
 
bool IsStrAttrDeletedE (const int &EId, const TStr &attr) const
 Returns true if Str attr exists for edge NId and has default value. More...
 
bool IsFltAttrDeletedE (const int &EId, const TStr &attr) const
 Returns true if Flt attr exists for edge NId and has default value. More...
 
bool EdgeAttrIsDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 Returns true if EId attr deleted for current edge attr iterator. More...
 
bool EdgeAttrIsIntDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 Returns true if EId attr deleted for current edge int attr iterator. More...
 
bool EdgeAttrIsIntVDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 Returns true if EId attr deleted for current edge int vector attr iterator. More...
 
bool EdgeAttrIsStrDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 Returns true if EId attr deleted for current edge str attr iterator. More...
 
bool EdgeAttrIsFltDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 Returns true if EId attr deleted for current edge flt attr iterator. More...
 
TStr GetNodeAttrValue (const int &NId, const TStrIntPrH::TIter &NodeHI) const
 Returns node attribute value, converted to Str type. More...
 
TStr GetEdgeAttrValue (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
 Returns edge attribute value, converted to Str type. More...
 
TFlt GetWeightOutEdges (const TNodeI &NI, const TStr &attr)
 Gets the sum of the weights of all the outgoing edges of the node. More...
 
bool IsFltAttrE (const TStr &attr)
 Checks if there is an edge attribute with name attr. More...
 
bool IsIntAttrE (const TStr &attr)
 Checks if there is an edge attribute with name attr. More...
 
bool IsStrAttrE (const TStr &attr)
 Checks if there is an edge attribute with name attr. More...
 
TVec< TFlt > & GetFltAttrVecE (const TStr &attr)
 Gets Vector for the Flt Attribute attr. More...
 
int GetFltKeyIdE (const int &EId)
 Gets keyid for edge with id EId. More...
 
void GetWeightOutEdgesV (TFltV &OutWeights, const TFltV &AttrVal)
 Fills OutWeights with the outgoing weight from each node. More...
 
void GetAttrNNames (TStrV &IntAttrNames, TStrV &FltAttrNames, TStrV &StrAttrNames) const
 Fills each of the vectors with the names of node attributes of the given type. More...
 
void GetAttrENames (TStrV &IntAttrNames, TStrV &FltAttrNames, TStrV &StrAttrNames) const
 Fills each of the vectors with the names of edge attributes of the given type. 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 TInt &EId, const TStr &AttrName, const TInt &Val)
 Adds Int sparse attribute with name AttrName to the given edge with id EId. More...
 
int AddSAttrDatE (const TInt &EId, const TInt &AttrId, const TInt &Val)
 Adds Int sparse attribute with id AttrId to the given edge with id EId. 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 TInt &EId, const TStr &AttrName, const TFlt &Val)
 Adds Flt sparse attribute with name AttrName to the given edge with id EId. More...
 
int AddSAttrDatE (const TInt &EId, const TInt &AttrId, const TFlt &Val)
 Adds Flt sparse attribute with id AttrId to the given edge with id EId. 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 TInt &EId, const TStr &AttrName, const TStr &Val)
 Adds Str sparse attribute with name AttrName to the given edge with id EId. More...
 
int AddSAttrDatE (const TInt &EId, const TInt &AttrId, const TStr &Val)
 Adds Str sparse attribute with id AttrId to the given edge with id EId. 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 TInt &EId, const TStr &AttrName, TInt &ValX) const
 Gets Int sparse attribute with name AttrName from edge with id EId. More...
 
int GetSAttrDatE (const TInt &EId, const TInt &AttrId, TInt &ValX) const
 Gets Int sparse attribute with id AttrId from edge with id EId. 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 TInt &EId, const TStr &AttrName, TFlt &ValX) const
 Gets Flt sparse attribute with name AttrName from edge with id EId. More...
 
int GetSAttrDatE (const TInt &EId, const TInt &AttrId, TFlt &ValX) const
 Gets Flt sparse attribute with id AttrId from edge with id EId. 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 TInt &EId, const TStr &AttrName, TStr &ValX) const
 Gets Str sparse attribute with name AttrName from edge with id EId. More...
 
int GetSAttrDatE (const TInt &EId, const TInt &AttrId, TStr &ValX) const
 Gets Str sparse attribute with id AttrId from edge with id EId. 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 TInt &EId, const TStr &AttrName)
 Deletes sparse attribute with name AttrName from edge with id EId. More...
 
int DelSAttrDatE (const TInt &EId, const TInt &AttrId)
 Deletes sparse attribute with id AttrId from edge with id EId. 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 TInt &EId, const TAttrType AttrType, TAttrPrV &AttrV) const
 Gets a list of all sparse attributes of type AttrType for edge with id EId. 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, TIntV &IdV) const
 Gets a list of all edges that have a sparse attribute with name AttrName. More...
 
int GetIdVSAttrE (const TInt &AttrId, TIntV &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 PNEANet New ()
 Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New(). More...
 
static PNEANet New (const int &Nodes, const int &Edges)
 Static constructor that returns a pointer to the graph and reserves enough memory for Nodes nodes and Edges edges. More...
 
static PNEANet Load (TSIn &SIn)
 Static constructor that loads the graph from a stream SIn and returns a pointer to it. More...
 
static PNEANet Load_V1 (TSIn &SIn)
 Static constructor that loads the graph from a stream SIn and returns a pointer to it. Backwards compatible. More...
 
static PNEANet Load_V2 (TSIn &SIn)
 Static constructor that loads the graph from a stream SIn and returns a pointer to it. Backwards compatible without Sparse. More...
 
static PNEANet LoadShM (TShMIn &ShMIn)
 Static constructor that loads the network from memory. More...
 
static PNEANet GetSmallGraph ()
 Returns a small multigraph on 5 nodes and 6 edges. More...
 

Public Attributes

TCRef CRef
 

Protected Types

enum  { IntType, StrType, FltType, IntVType }
 

Protected Member Functions

TNodeGetNode (const int &NId)
 
const TNodeGetNode (const int &NId) const
 
TEdgeGetEdge (const int &EId)
 
const TEdgeGetEdge (const int &EId) const
 
int AddAttributes (const int NId)
 
TInt GetIntAttrDefaultN (const TStr &attribute) const
 Gets Int node attribute val. If not a proper attr, return default. More...
 
TStr GetStrAttrDefaultN (const TStr &attribute) const
 Gets Str node attribute val. If not a proper attr, return default. More...
 
TFlt GetFltAttrDefaultN (const TStr &attribute) const
 Gets Flt node attribute val. If not a proper attr, return default. More...
 
TInt GetIntAttrDefaultE (const TStr &attribute) const
 Gets Int edge attribute val. If not a proper attr, return default. More...
 
TStr GetStrAttrDefaultE (const TStr &attribute) const
 Gets Str edge attribute val. If not a proper attr, return default. More...
 
TFlt GetFltAttrDefaultE (const TStr &attribute) const
 Gets Flt edge attribute val. If not a proper attr, return default. More...
 
TInt CheckDenseOrSparseN (const TStr &attr) const
 Return 1 if in Dense, 0 if in Sparse, -1 if neither. More...
 
TInt CheckDenseOrSparseE (const TStr &attr) const
 
 TNEANet (const TNEANet &Graph, bool modeSubGraph)
 
 TNEANet (bool copyAll, const TNEANet &Graph)
 

Protected Attributes

TInt MxNId
 
TInt MxEId
 
THash< TInt, TNodeNodeH
 
THash< TInt, TEdgeEdgeH
 
TStrIntPrH KeyToIndexTypeN
 KeyToIndexType[N|E]: Key->(Type,Index). More...
 
TStrIntPrH KeyToIndexTypeE
 
THash< TStr, TBoolKeyToDenseN
 KeyToDense[N|E]: Key->(True if Vec, False if Hash) More...
 
THash< TStr, TBoolKeyToDenseE
 
THash< TStr, TIntIntDefaultsN
 
THash< TStr, TIntIntDefaultsE
 
THash< TStr, TStrStrDefaultsN
 
THash< TStr, TStrStrDefaultsE
 
THash< TStr, TFltFltDefaultsN
 
THash< TStr, TFltFltDefaultsE
 
TVec< TIntVVecOfIntVecsN
 
TVec< TIntVVecOfIntVecsE
 
TVec< TStrVVecOfStrVecsN
 
TVec< TStrVVecOfStrVecsE
 
TVec< TFltVVecOfFltVecsN
 
TVec< TFltVVecOfFltVecsE
 
TVec< TVec< TIntV > > VecOfIntVecVecsN
 
TVec< TVec< TIntV > > VecOfIntVecVecsE
 
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
 
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
 
TAttr SAttrN
 
TAttr SAttrE
 

Friends

class TPt< TNEANet >
 

Detailed Description

Directed multigraph with node edge attributes.

Node IDs can be arbitrary non-negative integers. Edges have IDs. There can be more than one directed edge from one source node to a destination node. Self loops (one per node) are allowed as well as multiple (parallel) edges. Nodes and edges can have attributes/data associated with them. The attributes can be added dynamically at runtime. The directed multigraph data structure is implemented using sorted adjacency lists. This means adding a node takes constant time, while adding an edge takes linear time (since adjacency list is kept sorted) in the node degree. Accessing arbitrary node takes constant time and accessing any edge takes logarithmic time in the node degree. The attributes are organized in a columnar store, where each attribute column is defined for all the nodes or edges in the network.

Definition at line 1741 of file network.h.

Member Typedef Documentation

Definition at line 1744 of file network.h.

Definition at line 1743 of file network.h.

Member Enumeration Documentation

anonymous enum
protected
Enumerator
IntType 
StrType 
FltType 
IntVType 

Definition at line 2043 of file network.h.

Constructor & Destructor Documentation

TNEANet::TNEANet ( )
inline

Definition at line 2097 of file network.h.

2097  : CRef(), MxNId(0), MxEId(0), NodeH(), EdgeH(),
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
THash< TStr, TBool > KeyToDenseE
Definition: network.h:2033
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:2037
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
THash< TStr, TInt > IntDefaultsE
Definition: network.h:2035
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
TAttr SAttrN
Definition: network.h:2045
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:2037
TInt MxNId
Definition: network.h:2027
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TAttr SAttrE
Definition: network.h:2046
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
TCRef CRef
Definition: network.h:2025
THash< TStr, TStr > StrDefaultsN
Definition: network.h:2036
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
TInt MxEId
Definition: network.h:2027
THash< TStr, TStr > StrDefaultsE
Definition: network.h:2036
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
THash< TStr, TInt > IntDefaultsN
Definition: network.h:2035
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
Definition: network.h:2033
TNEANet::TNEANet ( const int &  Nodes,
const int &  Edges 
)
inlineexplicit

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

Definition at line 2104 of file network.h.

2104  : CRef(),
2110  { Reserve(Nodes, Edges); }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
THash< TStr, TBool > KeyToDenseE
Definition: network.h:2033
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:2037
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
THash< TStr, TInt > IntDefaultsE
Definition: network.h:2035
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
TAttr SAttrN
Definition: network.h:2045
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:2037
TInt MxNId
Definition: network.h:2027
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TAttr SAttrE
Definition: network.h:2046
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a graph of Nodes nodes and Edges edges.
Definition: network.h:2634
TCRef CRef
Definition: network.h:2025
THash< TStr, TStr > StrDefaultsN
Definition: network.h:2036
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
TInt MxEId
Definition: network.h:2027
THash< TStr, TStr > StrDefaultsE
Definition: network.h:2036
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
THash< TStr, TInt > IntDefaultsN
Definition: network.h:2035
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
Definition: network.h:2033
TNEANet::TNEANet ( const TNEANet Graph)
inline

Definition at line 2111 of file network.h.

2111  : MxNId(Graph.MxNId), MxEId(Graph.MxEId),
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
THash< TStr, TBool > KeyToDenseE
Definition: network.h:2033
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:2037
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
THash< TStr, TInt > IntDefaultsE
Definition: network.h:2035
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
TAttr SAttrN
Definition: network.h:2045
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:2037
TInt MxNId
Definition: network.h:2027
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TAttr SAttrE
Definition: network.h:2046
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
THash< TStr, TStr > StrDefaultsN
Definition: network.h:2036
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
TInt MxEId
Definition: network.h:2027
THash< TStr, TStr > StrDefaultsE
Definition: network.h:2036
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
THash< TStr, TInt > IntDefaultsN
Definition: network.h:2035
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
Definition: network.h:2033
TNEANet::TNEANet ( TSIn SIn)
inline

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

Definition at line 2118 of file network.h.

2118  : MxNId(SIn), MxEId(SIn), NodeH(SIn), EdgeH(SIn),
2120  StrDefaultsN(SIn), StrDefaultsE(SIn), FltDefaultsN(SIn), FltDefaultsE(SIn),
2123  SAttrN(SIn), SAttrE(SIn) { }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
THash< TStr, TBool > KeyToDenseE
Definition: network.h:2033
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:2037
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
THash< TStr, TInt > IntDefaultsE
Definition: network.h:2035
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
TAttr SAttrN
Definition: network.h:2045
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:2037
TInt MxNId
Definition: network.h:2027
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TAttr SAttrE
Definition: network.h:2046
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
THash< TStr, TStr > StrDefaultsN
Definition: network.h:2036
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
TInt MxEId
Definition: network.h:2027
THash< TStr, TStr > StrDefaultsE
Definition: network.h:2036
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
THash< TStr, TInt > IntDefaultsN
Definition: network.h:2035
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
Definition: network.h:2033
TNEANet::TNEANet ( const TNEANet Graph,
bool  modeSubGraph 
)
inlineprotected

Definition at line 2125 of file network.h.

2125  : MxNId(Graph.MxNId), MxEId(Graph.MxEId),
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
THash< TStr, TBool > KeyToDenseE
Definition: network.h:2033
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:2037
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
THash< TStr, TInt > IntDefaultsE
Definition: network.h:2035
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:2037
TInt MxNId
Definition: network.h:2027
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
THash< TStr, TStr > StrDefaultsN
Definition: network.h:2036
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
TInt MxEId
Definition: network.h:2027
THash< TStr, TStr > StrDefaultsE
Definition: network.h:2036
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
THash< TStr, TInt > IntDefaultsN
Definition: network.h:2035
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
Definition: network.h:2033
TNEANet::TNEANet ( bool  copyAll,
const TNEANet Graph 
)
inlineprotected

Definition at line 2131 of file network.h.

2131  : MxNId(Graph.MxNId), MxEId(Graph.MxEId),
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
THash< TStr, TBool > KeyToDenseE
Definition: network.h:2033
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:2037
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
THash< TStr, TInt > IntDefaultsE
Definition: network.h:2035
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
TAttr SAttrN
Definition: network.h:2045
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:2037
TInt MxNId
Definition: network.h:2027
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TAttr SAttrE
Definition: network.h:2046
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
THash< TStr, TStr > StrDefaultsN
Definition: network.h:2036
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
TInt MxEId
Definition: network.h:2027
THash< TStr, TStr > StrDefaultsE
Definition: network.h:2036
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
THash< TStr, TInt > IntDefaultsN
Definition: network.h:2035
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
Definition: network.h:2033

Member Function Documentation

int TNEANet::AddAttributes ( const int  NId)
protected

Definition at line 468 of file network.cpp.

468  {
469  int i;
470  // update attribute columns
471  for (i = 0; i < VecOfIntVecsN.Len(); i++) {
472  TVec<TInt>& IntVec = VecOfIntVecsN[i];
473  int KeyId = NodeH.GetKeyId(NId);
474  if (IntVec.Len() > KeyId) {
475  IntVec[KeyId] = TInt::Mn;
476  } else {
477  IntVec.Ins(KeyId, TInt::Mn);
478  }
479  }
480  TVec<TStr> DefIntVec = TVec<TStr>();
481  IntDefaultsN.GetKeyV(DefIntVec);
482  for (i = 0; i < DefIntVec.Len(); i++) {
483  TStr attr = DefIntVec[i];
484  TVec<TInt>& IntVec = VecOfIntVecsN[KeyToIndexTypeN.GetDat(DefIntVec[i]).Val2];
485  IntVec[NodeH.GetKeyId(NId)] = GetIntAttrDefaultN(attr);
486  }
487  for (i = 0; i < VecOfStrVecsN.Len(); i++) {
488  TVec<TStr>& StrVec = VecOfStrVecsN[i];
489  int KeyId = NodeH.GetKeyId(NId);
490  if (StrVec.Len() > KeyId) {
491  StrVec[KeyId] = TStr::GetNullStr();
492  } else {
493  StrVec.Ins(KeyId, TStr::GetNullStr());
494  }
495  }
496  TVec<TStr> DefStrVec = TVec<TStr>();
497  StrDefaultsN.GetKeyV(DefStrVec);
498  for (i = 0; i < DefStrVec.Len(); i++) {
499  TStr attr = DefStrVec[i];
500  TVec<TStr>& StrVec = VecOfStrVecsN[KeyToIndexTypeN.GetDat(DefStrVec[i]).Val2];
501  StrVec[NodeH.GetKeyId(NId)] = GetStrAttrDefaultN(attr);
502  }
503  for (i = 0; i < VecOfFltVecsN.Len(); i++) {
504  TVec<TFlt>& FltVec = VecOfFltVecsN[i];
505  int KeyId = NodeH.GetKeyId(NId);
506  if (FltVec.Len() > KeyId) {
507  FltVec[KeyId] = TFlt::Mn;
508  } else {
509  FltVec.Ins(KeyId, TFlt::Mn);
510  }
511  }
512  TVec<TStr> DefFltVec = TVec<TStr>();
513  FltDefaultsN.GetKeyV(DefFltVec);
514  for (i = 0; i < DefFltVec.Len(); i++) {
515  TStr attr = DefFltVec[i];
516  TVec<TFlt>& FltVec = VecOfFltVecsN[KeyToIndexTypeN.GetDat(DefFltVec[i]).Val2];
517  FltVec[NodeH.GetKeyId(NId)] = GetFltAttrDefaultN(attr);
518  }
519  for (i = 0; i < VecOfIntVecVecsN.Len(); i++) {
520  TVec<TIntV>& IntVecV = VecOfIntVecVecsN[i];
521  int KeyId = NodeH.GetKeyId(NId);
522  if (IntVecV.Len() > KeyId) {
523  IntVecV[KeyId] = TIntV();
524  } else {
525  IntVecV.Ins(KeyId, TIntV());
526  }
527  }
528  return NId;
529 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:2037
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
static const int Mn
Definition: dt.h:1138
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
THash< TStr, TStr > StrDefaultsN
Definition: network.h:2036
TStr GetStrAttrDefaultN(const TStr &attribute) const
Gets Str node attribute val. If not a proper attr, return default.
Definition: network.h:2015
static TStr GetNullStr()
Definition: dt.cpp:1626
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
void GetKeyV(TVec< TKey > &KeyV) const
Definition: hash.h:484
Definition: dt.h:412
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVec< TInt > TIntV
Definition: ds.h:1594
TVal2 Val2
Definition: ds.h:35
THash< TStr, TInt > IntDefaultsN
Definition: network.h:2035
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Gets Flt node attribute val. If not a proper attr, return default.
Definition: network.h:2017
TInt GetIntAttrDefaultN(const TStr &attribute) const
Gets Int node attribute val. If not a proper attr, return default.
Definition: network.h:2013
static const double Mn
Definition: dt.h:1387
int TNEANet::AddEdge ( const int &  SrcNId,
const int &  DstNId,
int  EId = -1 
)

Adds an edge with ID EId between node IDs SrcNId and DstNId to the graph.

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

Definition at line 622 of file network.cpp.

622  {
623  int i;
624 
625  if (EId == -1) { EId = MxEId; MxEId++; }
626  else { MxEId = TMath::Mx(EId+1, MxEId()); }
627  IAssertR(!IsEdge(EId), TStr::Fmt("EdgeId %d already exists", EId));
628  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
629  EdgeH.AddDat(EId, TEdge(EId, SrcNId, DstNId));
630  GetNode(SrcNId).OutEIdV.AddSorted(EId);
631  GetNode(DstNId).InEIdV.AddSorted(EId);
632 
633  // update attribute columns
634  for (i = 0; i < VecOfIntVecsE.Len(); i++) {
635  TVec<TInt>& IntVec = VecOfIntVecsE[i];
636  int KeyId = EdgeH.GetKeyId(EId);
637  if (IntVec.Len() > KeyId) {
638  IntVec[KeyId] = TInt::Mn;
639  } else {
640  IntVec.Ins(KeyId, TInt::Mn);
641  }
642  }
643  TVec<TStr> DefIntVec = TVec<TStr>();
644  IntDefaultsE.GetKeyV(DefIntVec);
645  for (i = 0; i < DefIntVec.Len(); i++) {
646  TStr attr = DefIntVec[i];
647  TVec<TInt>& IntVec = VecOfIntVecsE[KeyToIndexTypeE.GetDat(DefIntVec[i]).Val2];
648  IntVec[EdgeH.GetKeyId(EId)] = GetIntAttrDefaultE(attr);
649  }
650 
651  for (i = 0; i < VecOfIntVecVecsE.Len(); i++) {
652  TVec<TIntV>& IntVecV = VecOfIntVecVecsE[i];
653  IntVecV.Ins(EdgeH.GetKeyId(EId), TIntV());
654  }
655 
656  for (i = 0; i < VecOfStrVecsE.Len(); i++) {
657  TVec<TStr>& StrVec = VecOfStrVecsE[i];
658  int KeyId = EdgeH.GetKeyId(EId);
659  if (StrVec.Len() > KeyId) {
660  StrVec[KeyId] = TStr::GetNullStr();
661  } else {
662  StrVec.Ins(KeyId, TStr::GetNullStr());
663  }
664  }
665  TVec<TStr> DefStrVec = TVec<TStr>();
666  StrDefaultsE.GetKeyV(DefStrVec);
667  for (i = 0; i < DefStrVec.Len(); i++) {
668  TStr attr = DefStrVec[i];
669  TVec<TStr>& StrVec = VecOfStrVecsE[KeyToIndexTypeE.GetDat(DefStrVec[i]).Val2];
670  StrVec[EdgeH.GetKeyId(EId)] = GetStrAttrDefaultE(attr);
671  }
672 
673  for (i = 0; i < VecOfFltVecsE.Len(); i++) {
674  TVec<TFlt>& FltVec = VecOfFltVecsE[i];
675  int KeyId = EdgeH.GetKeyId(EId);
676  if (FltVec.Len() > KeyId) {
677  FltVec[KeyId] = TFlt::Mn;
678  } else {
679  FltVec.Ins(KeyId, TFlt::Mn);
680  }
681  }
682  TVec<TStr> DefFltVec = TVec<TStr>();
683  FltDefaultsE.GetKeyV(DefFltVec);
684  for (i = 0; i < DefFltVec.Len(); i++) {
685  TStr attr = DefFltVec[i];
686  TVec<TFlt>& FltVec = VecOfFltVecsE[KeyToIndexTypeE.GetDat(DefFltVec[i]).Val2];
687  FltVec[EdgeH.GetKeyId(EId)] = GetFltAttrDefaultE(attr);
688  }
689  return EId;
690 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:2037
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
THash< TStr, TInt > IntDefaultsE
Definition: network.h:2035
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
TNode & GetNode(const int &NId)
Definition: network.h:2005
TInt GetIntAttrDefaultE(const TStr &attribute) const
Gets Int edge attribute val. If not a proper attr, return default.
Definition: network.h:2019
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
TIntV OutEIdV
Definition: network.h:1749
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
TSizeTy AddSorted(const TVal &Val, const bool &Asc=true, const TSizeTy &_MxVals=-1)
Adds element Val to a sorted vector.
Definition: ds.h:1117
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
static const int Mn
Definition: dt.h:1138
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TStr GetStrAttrDefaultE(const TStr &attribute) const
Gets Str edge attribute val. If not a proper attr, return default.
Definition: network.h:2021
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
static TStr GetNullStr()
Definition: dt.cpp:1626
TInt MxEId
Definition: network.h:2027
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
THash< TStr, TStr > StrDefaultsE
Definition: network.h:2036
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Gets Flt edge attribute val. If not a proper attr, return default.
Definition: network.h:2023
void GetKeyV(TVec< TKey > &KeyV) const
Definition: hash.h:484
Definition: dt.h:412
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TVec< TInt > TIntV
Definition: ds.h:1594
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
TIntV InEIdV
Definition: network.h:1749
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
static const double Mn
Definition: dt.h:1387
int TNEANet::AddEdge ( const TEdgeI EdgeI)
inline

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

Definition at line 2585 of file network.h.

2585 { return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), EdgeI.GetId()); }
int AddEdge(const int &SrcNId, const int &DstNId, int EId=-1)
Adds an edge with ID EId between node IDs SrcNId and DstNId to the graph.
Definition: network.cpp:622
int TNEANet::AddFltAttrDatE ( const TEdgeI EdgeI,
const TFlt value,
const TStr attr 
)
inline

Attribute based add function for attr to Flt value.

Adds the key flt value pair to the corresponding edge attribute value vector.

Definition at line 2690 of file network.h.

2690 { return AddFltAttrDatE(EdgeI.GetId(), value, attr); }
int AddFltAttrDatE(const TEdgeI &EdgeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
Definition: network.h:2690
int TNEANet::AddFltAttrDatE ( const int &  EId,
const TFlt value,
const TStr attr 
)

Definition at line 1121 of file network.cpp.

1121  {
1122  int i;
1123  TInt CurrLen;
1124 
1125  if (!IsEdge(EId)) {
1126  //AddEdge(EId);
1127  return -1;
1128  }
1129  if (KeyToIndexTypeE.IsKey(attr)) {
1131  NewVec[EdgeH.GetKeyId(EId)] = value;
1132  } else {
1133  CurrLen = VecOfFltVecsE.Len();
1134  KeyToIndexTypeE.AddDat(attr, TIntPr(FltType, CurrLen));
1135  TVec<TFlt> NewVec = TVec<TFlt>();
1136  for (i = 0; i < MxEId; i++) {
1137  NewVec.Ins(i, GetFltAttrDefaultE(attr));
1138  }
1139  NewVec[EdgeH.GetKeyId(EId)] = value;
1140  VecOfFltVecsE.Add(NewVec);
1141  }
1142  return 0;
1143 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TInt MxEId
Definition: network.h:2027
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Gets Flt edge attribute val. If not a proper attr, return default.
Definition: network.h:2023
TVal2 Val2
Definition: ds.h:35
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddFltAttrDatN ( const TNodeI NodeI,
const TFlt value,
const TStr attr 
)
inline

Attribute based add function for attr to Flt value.

Adds the key flt value pair to the corresponding node attribute value vector.

Definition at line 2664 of file network.h.

2664 { return AddFltAttrDatN(NodeI.GetId(), value, attr); }
int AddFltAttrDatN(const TNodeI &NodeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
Definition: network.h:2664
int TNEANet::AddFltAttrDatN ( const int &  NId,
const TFlt value,
const TStr attr 
)

Definition at line 1010 of file network.cpp.

1010  {
1011  int i;
1012  TInt CurrLen;
1013 
1014  if (!IsNode(NId)) {
1015  // AddNode(NId);
1016  return -1;
1017  }
1018  if (KeyToIndexTypeN.IsKey(attr)) {
1020  NewVec[NodeH.GetKeyId(NId)] = value;
1021  } else {
1022  CurrLen = VecOfFltVecsN.Len();
1023  KeyToIndexTypeN.AddDat(attr, TIntPr(FltType, CurrLen));
1024  TVec<TFlt> NewVec = TVec<TFlt>();
1025  for (i = 0; i < MxNId; i++) {
1026  NewVec.Ins(i, GetFltAttrDefaultN(attr));
1027  }
1028  NewVec[NodeH.GetKeyId(NId)] = value;
1029  VecOfFltVecsN.Add(NewVec);
1030  }
1031  return 0;
1032 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TInt MxNId
Definition: network.h:2027
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
THash< TInt, TNode > NodeH
Definition: network.h:2028
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Gets Flt node attribute val. If not a proper attr, return default.
Definition: network.h:2017
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddFltAttrE ( const TStr attr,
TFlt  defaultValue = TFlt::Mn 
)

Adds a new Flt edge attribute to the hashmap.

Definition at line 1399 of file network.cpp.

1399  {
1400  int i;
1401  TInt CurrLen;
1402  TVec<TFlt> NewVec;
1403  CurrLen = VecOfFltVecsE.Len();
1404  KeyToIndexTypeE.AddDat(attr, TIntPr(FltType, CurrLen));
1405  NewVec = TVec<TFlt>();
1406  for (i = 0; i < MxEId; i++) {
1407  NewVec.Ins(i, defaultValue);
1408  }
1409  VecOfFltVecsE.Add(NewVec);
1410  if (!FltDefaultsE.IsKey(attr)) {
1411  FltDefaultsE.AddDat(attr, defaultValue);
1412  } else {
1413  return -1;
1414  }
1415  return 0;
1416 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:2037
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TInt MxEId
Definition: network.h:2027
Definition: dt.h:1134
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddFltAttrN ( const TStr attr,
TFlt  defaultValue = TFlt::Mn 
)

Adds a new Flt node attribute to the hashmap.

Definition at line 1322 of file network.cpp.

1322  {
1323  // TODO(nkhadke): add error checking
1324  int i;
1325  TInt CurrLen;
1326  TVec<TFlt> NewVec;
1327  CurrLen = VecOfFltVecsN.Len();
1328  KeyToIndexTypeN.AddDat(attr, TIntPr(FltType, CurrLen));
1329  NewVec = TVec<TFlt>();
1330  for (i = 0; i < MxNId; i++) {
1331  NewVec.Ins(i, defaultValue);
1332  }
1333  VecOfFltVecsN.Add(NewVec);
1334  if (!FltDefaultsN.IsKey(attr)) {
1335  FltDefaultsN.AddDat(attr, defaultValue);
1336  } else {
1337  return -1;
1338  }
1339  return 0;
1340 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:2037
TInt MxNId
Definition: network.h:2027
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
Definition: dt.h:1134
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddIntAttrDatE ( const TEdgeI EdgeI,
const TInt value,
const TStr attr 
)
inline

Attribute based add function for attr to Int value.

Adds the key int value pair to the corresponding edge attribute value vector.

Definition at line 2680 of file network.h.

2680 { return AddIntAttrDatE(EdgeI.GetId(), value, attr); }
int AddIntAttrDatE(const TEdgeI &EdgeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
Definition: network.h:2680
int TNEANet::AddIntAttrDatE ( const int &  EId,
const TInt value,
const TStr attr 
)

Definition at line 1034 of file network.cpp.

1034  {
1035  int i;
1036  TInt CurrLen;
1037  if (!IsEdge(EId)) {
1038  //AddEdge(EId);
1039  return -1;
1040  }
1041  if (KeyToIndexTypeE.IsKey(attr)) {
1043  NewVec[EdgeH.GetKeyId(EId)] = value;
1044  } else {
1045  CurrLen = VecOfIntVecsE.Len();
1046  KeyToIndexTypeE.AddDat(attr, TIntPr(IntType, CurrLen));
1047  TVec<TInt> NewVec = TVec<TInt>();
1048  for (i = 0; i < MxEId; i++) {
1049  NewVec.Ins(i, GetIntAttrDefaultE(attr));
1050  }
1051  NewVec[EdgeH.GetKeyId(EId)] = value;
1052  VecOfIntVecsE.Add(NewVec);
1053  }
1054  return 0;
1055 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TInt GetIntAttrDefaultE(const TStr &attribute) const
Gets Int edge attribute val. If not a proper attr, return default.
Definition: network.h:2019
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TInt MxEId
Definition: network.h:2027
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
TVal2 Val2
Definition: ds.h:35
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddIntAttrDatN ( const TNodeI NodeI,
const TInt value,
const TStr attr 
)
inline

Attribute based add function for attr to Int value.

Adds the key int value pair to the corresponding node attribute value vector.

Definition at line 2654 of file network.h.

2654 { return AddIntAttrDatN(NodeI.GetId(), value, attr); }
int AddIntAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
Definition: network.h:2654
int TNEANet::AddIntAttrDatN ( const int &  NId,
const TInt value,
const TStr attr 
)

Definition at line 894 of file network.cpp.

894  {
895  int i;
896  TInt CurrLen;
897  if (!IsNode(NId)) {
898  // AddNode(NId);
899  return -1;
900  }
901  if (KeyToIndexTypeN.IsKey(attr)) {
903  NewVec[NodeH.GetKeyId(NId)] = value;
904  } else {
905  CurrLen = VecOfIntVecsN.Len();
906  KeyToIndexTypeN.AddDat(attr, TIntPr(IntType, CurrLen));
907  TVec<TInt> NewVec = TVec<TInt>();
908  for (i = 0; i < MxNId; i++) {
909  NewVec.Ins(i, GetIntAttrDefaultN(attr));
910  }
911  NewVec[NodeH.GetKeyId(NId)] = value;
912  VecOfIntVecsN.Add(NewVec);
913  }
914  return 0;
915 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TInt MxNId
Definition: network.h:2027
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
THash< TInt, TNode > NodeH
Definition: network.h:2028
TInt GetIntAttrDefaultN(const TStr &attribute) const
Gets Int node attribute val. If not a proper attr, return default.
Definition: network.h:2013
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddIntAttrE ( const TStr attr,
TInt  defaultValue = TInt::Mn 
)

Adds a new Int edge attribute to the hashmap.

Definition at line 1342 of file network.cpp.

1342  {
1343  // TODO(nkhadke): add error checking
1344  int i;
1345  TInt CurrLen;
1346  TVec<TInt> NewVec;
1347  CurrLen = VecOfIntVecsE.Len();
1348  KeyToIndexTypeE.AddDat(attr, TIntPr(IntType, CurrLen));
1349  NewVec = TVec<TInt>();
1350  for (i = 0; i < MxEId; i++) {
1351  NewVec.Ins(i, defaultValue);
1352  }
1353  VecOfIntVecsE.Add(NewVec);
1354  if (!IntDefaultsE.IsKey(attr)) {
1355  IntDefaultsE.AddDat(attr, defaultValue);
1356  } else {
1357  return -1;
1358  }
1359  return 0;
1360 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
THash< TStr, TInt > IntDefaultsE
Definition: network.h:2035
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
TInt MxEId
Definition: network.h:2027
Definition: dt.h:1134
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddIntAttrN ( const TStr attr,
TInt  defaultValue = TInt::Mn 
)

Adds a new Int node attribute to the hashmap.

Definition at line 1266 of file network.cpp.

1266  {
1267  int i;
1268  TInt CurrLen;
1269  TVec<TInt> NewVec;
1270  CurrLen = VecOfIntVecsN.Len();
1271  KeyToIndexTypeN.AddDat(attr, TIntPr(IntType, CurrLen));
1272  NewVec = TVec<TInt>();
1273  for (i = 0; i < MxNId; i++) {
1274  NewVec.Ins(i, defaultValue);
1275  }
1276  VecOfIntVecsN.Add(NewVec);
1277  if (!IntDefaultsN.IsKey(attr)) {
1278  IntDefaultsN.AddDat(attr, defaultValue);
1279  } else {
1280  return -1;
1281  }
1282  return 0;
1283 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TInt MxNId
Definition: network.h:2027
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
Definition: dt.h:1134
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
THash< TStr, TInt > IntDefaultsN
Definition: network.h:2035
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddIntVAttrDatE ( const TEdgeI EdgeI,
const TIntV value,
const TStr attr 
)
inline

Attribute based add function for attr to IntV value.

Adds the key intv value pair to the corresponding edge attribute value vector.

Definition at line 2695 of file network.h.

2695 { return AddIntVAttrDatE(EdgeI.GetId(), value, attr); }
int AddIntVAttrDatE(const TEdgeI &EdgeI, const TIntV &value, const TStr &attr)
Attribute based add function for attr to IntV value.
Definition: network.h:2695
int TNEANet::AddIntVAttrDatE ( const int &  EId,
const TIntV value,
const TStr attr,
TBool  UseDense = true 
)

Definition at line 1057 of file network.cpp.

1057  {
1058  if (!IsNode(EId)) {
1059  // AddNode(NId);
1060  return -1;
1061  }
1062  TInt location = CheckDenseOrSparseE(attr);
1063  if (location==-1) {
1064  AddIntVAttrE(attr, UseDense);
1065  location = CheckDenseOrSparseE(attr);
1066  }
1067  if (UseDense) {
1068  IAssertR(location != 0, TStr::Fmt("EdgeID %d exists for %s in sparse representation", EId, attr.CStr()));
1070  NewVec[EdgeH.GetKeyId(EId)] = value;
1071  } else {
1072  IAssertR(location != 1, TStr::Fmt("NodeId %d exists for %s in dense representation", EId, attr.CStr()));
1074  NewHash.AddDat(EdgeH.GetKeyId(EId), value);
1075  }
1076  return 0;
1077 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TInt CheckDenseOrSparseE(const TStr &attr) const
Definition: network.h:2089
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
int AddIntVAttrE(const TStr &attr, TBool UseDense=true)
Adds a new IntV edge attribute to the hashmap.
Definition: network.cpp:1362
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
char * CStr()
Definition: dt.h:476
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddIntVAttrDatN ( const TNodeI NodeI,
const TIntV value,
const TStr attr 
)
inline

Attribute based add function for attr to IntV value.

Adds the key intv value pair to the corresponding node attribute value vector.

Definition at line 2669 of file network.h.

2669 { return AddIntVAttrDatN(NodeI.GetId(), value, attr); }
int AddIntVAttrDatN(const TNodeI &NodeI, const TIntV &value, const TStr &attr)
Attribute based add function for attr to IntV value.
Definition: network.h:2669
int TNEANet::AddIntVAttrDatN ( const int &  NId,
const TIntV value,
const TStr attr,
TBool  UseDense = true 
)

Definition at line 917 of file network.cpp.

917  {
918  if (!IsNode(NId)) {
919  // AddNode(NId);
920  return -1;
921  }
922  TInt location = CheckDenseOrSparseN(attr);
923  if (location==-1) {
924  AddIntVAttrN(attr, UseDense);
925  location = CheckDenseOrSparseN(attr);
926  }
927  if (UseDense) {
928  IAssertR(location != 0, TStr::Fmt("NodeId %d exists for %s in sparse representation", NId, attr.CStr()));
930  NewVec[NodeH.GetKeyId(NId)] = value;
931  } else {
932  IAssertR(location != 1, TStr::Fmt("NodeId %d exists for %s in dense representation", NId, attr.CStr()));
934  NewHash.AddDat(NodeH.GetKeyId(NId), value);
935  }
936 
937  return 0;
938 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
int AddIntVAttrN(const TStr &attr, TBool UseDense=true)
Adds a new IntV node attribute to the hashmap.
Definition: network.cpp:1285
TInt CheckDenseOrSparseN(const TStr &attr) const
Return 1 if in Dense, 0 if in Sparse, -1 if neither.
Definition: network.h:2083
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
char * CStr()
Definition: dt.h:476
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddIntVAttrE ( const TStr attr,
TBool  UseDense = true 
)

Adds a new IntV edge attribute to the hashmap.

Definition at line 1362 of file network.cpp.

1362  {
1363  TInt CurrLen;
1364  if (UseDense) {
1365  CurrLen = VecOfIntVecVecsE.Len();
1366  KeyToIndexTypeE.AddDat(attr, TIntPr(IntVType, CurrLen));
1367  KeyToDenseE.AddDat(attr, true);
1368  TVec<TIntV> NewVec = TVec<TIntV>(MxEId);
1369  VecOfIntVecVecsE.Add(NewVec);
1370  } else {
1371  CurrLen = VecOfIntHashVecsE.Len();
1372  KeyToIndexTypeE.AddDat(attr, TIntPr(IntVType, CurrLen));
1373  KeyToDenseE.AddDat(attr, false);
1374  THash<TInt, TIntV> NewHash;
1375  VecOfIntHashVecsE.Add(NewHash);
1376  }
1377  return 0;
1378 }
THash< TStr, TBool > KeyToDenseE
Definition: network.h:2033
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
TInt MxEId
Definition: network.h:2027
Definition: dt.h:1134
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddIntVAttrN ( const TStr attr,
TBool  UseDense = true 
)

Adds a new IntV node attribute to the hashmap.

Definition at line 1285 of file network.cpp.

1285  {
1286  TInt CurrLen;
1287  if (UseDense) {
1288  CurrLen = VecOfIntVecVecsN.Len();
1289  KeyToIndexTypeN.AddDat(attr, TIntPr(IntVType, CurrLen));
1290  KeyToDenseN.AddDat(attr, true);
1291  TVec<TIntV> NewVec = TVec<TIntV>(MxNId);
1292  VecOfIntVecVecsN.Add(NewVec);
1293  } else {
1294  CurrLen = VecOfIntHashVecsN.Len();
1295  KeyToIndexTypeN.AddDat(attr, TIntPr(IntVType, CurrLen));
1296  KeyToDenseN.AddDat(attr, false);
1297  THash<TInt, TIntV> NewHash;
1298  VecOfIntHashVecsN.Add(NewHash);
1299  }
1300  return 0;
1301 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TInt MxNId
Definition: network.h:2027
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
Definition: dt.h:1134
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
Definition: network.h:2033
int TNEANet::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 444 of file network.cpp.

444  {
445  if (NId == -1) {
446  NId = MxNId; MxNId++;
447  } else {
448  IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
449  MxNId = TMath::Mx(NId+1, MxNId());
450  }
451  NodeH.AddDat(NId, TNode(NId));
452  AddAttributes(NId);
453  return NId;
454 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
TInt MxNId
Definition: network.h:2027
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
THash< TInt, TNode > NodeH
Definition: network.h:2028
int AddAttributes(const int NId)
Definition: network.cpp:468
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddNode ( const TNodeI NodeI)
inline

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

Definition at line 2290 of file network.h.

2290 { return AddNode(NodeI.GetId()); }
int AddNode(int NId=-1)
Adds a node of ID NId to the network.
Definition: network.cpp:444
int TNEANet::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 456 of file network.cpp.

456  {
457  if (NId == -1) {
458  NId = MxNId; MxNId++;
459  } else {
460  if (IsNode(NId)) { return -1;}
461  MxNId = TMath::Mx(NId+1, MxNId());
462  }
463  NodeH.AddDat(NId, TNode(NId));
464  AddAttributes(NId);
465  return NId;
466 }
static const T & Mx(const T &LVal, const T &RVal)
Definition: xmath.h:32
TInt MxNId
Definition: network.h:2027
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
THash< TInt, TNode > NodeH
Definition: network.h:2028
int AddAttributes(const int NId)
Definition: network.cpp:468
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddSAttrDatE ( const TInt EId,
const TStr AttrName,
const TInt Val 
)

Adds Int sparse attribute with name AttrName to the given edge with id EId.

Definition at line 1669 of file network.cpp.

1669  {
1670  if (!IsEdge(EId)) {
1671  return -1;
1672  }
1673  return SAttrE.AddSAttrDat(EId, AttrName, Val);
1674 }
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
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
TAttr SAttrE
Definition: network.h:2046
int TNEANet::AddSAttrDatE ( const TInt EId,
const TInt AttrId,
const TInt Val 
)

Adds Int sparse attribute with id AttrId to the given edge with id EId.

Definition at line 1676 of file network.cpp.

1676  {
1677  if (!IsEdge(EId)) {
1678  return -1;
1679  }
1680  return SAttrE.AddSAttrDat(EId, AttrId, Val);
1681 }
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
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
TAttr SAttrE
Definition: network.h:2046
int TNEANet::AddSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName,
const TInt Val 
)
inline

Adds Int sparse attribute with name AttrName to EdgeI.

Definition at line 2991 of file network.h.

2991  {
2992  return AddSAttrDatE(EdgeI.GetId(), AttrName, Val);
2993  }
int AddSAttrDatE(const TInt &EId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with id EId.
Definition: network.cpp:1669
int TNEANet::AddSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId,
const TInt Val 
)
inline

Adds Int sparse attribute with id AttrId to EdgeI.

Definition at line 2995 of file network.h.

2995  {
2996  return AddSAttrDatE(EdgeI.GetId(), AttrId, Val);
2997  }
int AddSAttrDatE(const TInt &EId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with id EId.
Definition: network.cpp:1669
int TNEANet::AddSAttrDatE ( const TInt EId,
const TStr AttrName,
const TFlt Val 
)

Adds Flt sparse attribute with name AttrName to the given edge with id EId.

Definition at line 1683 of file network.cpp.

1683  {
1684  if (!IsEdge(EId)) {
1685  return -1;
1686  }
1687  return SAttrE.AddSAttrDat(EId, AttrName, Val);
1688 }
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
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
TAttr SAttrE
Definition: network.h:2046
int TNEANet::AddSAttrDatE ( const TInt EId,
const TInt AttrId,
const TFlt Val 
)

Adds Flt sparse attribute with id AttrId to the given edge with id EId.

Definition at line 1690 of file network.cpp.

1690  {
1691  if (!IsEdge(EId)) {
1692  return -1;
1693  }
1694  return SAttrE.AddSAttrDat(EId, AttrId, Val);
1695 }
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
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
TAttr SAttrE
Definition: network.h:2046
int TNEANet::AddSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName,
const TFlt Val 
)
inline

Adds Flt sparse attribute with name AttrName to EdgeI.

Definition at line 3005 of file network.h.

3005  {
3006  return AddSAttrDatE(EdgeI.GetId(), AttrName, Val);
3007  }
int AddSAttrDatE(const TInt &EId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with id EId.
Definition: network.cpp:1669
int TNEANet::AddSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId,
const TFlt Val 
)
inline

Adds Flt sparse attribute with id AttrId to EdgeI.

Definition at line 3009 of file network.h.

3009  {
3010  return AddSAttrDatE(EdgeI.GetId(), AttrId, Val);
3011  }
int AddSAttrDatE(const TInt &EId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with id EId.
Definition: network.cpp:1669
int TNEANet::AddSAttrDatE ( const TInt EId,
const TStr AttrName,
const TStr Val 
)

Adds Str sparse attribute with name AttrName to the given edge with id EId.

Definition at line 1697 of file network.cpp.

1697  {
1698  if (!IsEdge(EId)) {
1699  return -1;
1700  }
1701  return SAttrE.AddSAttrDat(EId, AttrName, Val);
1702 }
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
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
TAttr SAttrE
Definition: network.h:2046
int TNEANet::AddSAttrDatE ( const TInt EId,
const TInt AttrId,
const TStr Val 
)

Adds Str sparse attribute with id AttrId to the given edge with id EId.

Definition at line 1704 of file network.cpp.

1704  {
1705  if (!IsEdge(EId)) {
1706  return -1;
1707  }
1708  return SAttrE.AddSAttrDat(EId, AttrId, Val);
1709 }
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
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
TAttr SAttrE
Definition: network.h:2046
int TNEANet::AddSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName,
const TStr Val 
)
inline

Adds Str sparse attribute with name AttrName to EdgeI.

Definition at line 3019 of file network.h.

3019  {
3020  return AddSAttrDatE(EdgeI.GetId(), AttrName, Val);
3021  }
int AddSAttrDatE(const TInt &EId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with id EId.
Definition: network.cpp:1669
int TNEANet::AddSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId,
const TStr Val 
)
inline

Adds Str sparse attribute with id AttrId to EdgeI.

Definition at line 3023 of file network.h.

3023  {
3024  return AddSAttrDatE(EdgeI.GetId(), AttrId, Val);
3025  }
int AddSAttrDatE(const TInt &EId, const TStr &AttrName, const TInt &Val)
Adds Int sparse attribute with name AttrName to the given edge with id EId.
Definition: network.cpp:1669
int TNEANet::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 1543 of file network.cpp.

1543  {
1544  if (!IsNode(NId)) {
1545  return -1;
1546  }
1547  return SAttrN.AddSAttrDat(NId, AttrName, Val);
1548 }
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:2045
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
int TNEANet::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 1550 of file network.cpp.

1550  {
1551  if (!IsNode(NId)) {
1552  return -1;
1553  }
1554  return SAttrN.AddSAttrDat(NId, AttrId, Val);
1555 }
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:2045
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
int TNEANet::AddSAttrDatN ( const TNodeI NodeI,
const TStr AttrName,
const TInt Val 
)
inline

Adds Int sparse attribute with name AttrName to NodeI.

Definition at line 2873 of file network.h.

2873  {
2874  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
2875  }
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:1543
int TNEANet::AddSAttrDatN ( const TNodeI NodeI,
const TInt AttrId,
const TInt Val 
)
inline

Adds Int sparse attribute with id AttrId to NodeI.

Definition at line 2877 of file network.h.

2877  {
2878  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
2879  }
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:1543
int TNEANet::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 1557 of file network.cpp.

1557  {
1558  if (!IsNode(NId)) {
1559  return -1;
1560  }
1561  return SAttrN.AddSAttrDat(NId, AttrName, Val);
1562 }
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:2045
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
int TNEANet::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 1564 of file network.cpp.

1564  {
1565  if (!IsNode(NId)) {
1566  return -1;
1567  }
1568  return SAttrN.AddSAttrDat(NId, AttrId, Val);
1569 }
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:2045
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
int TNEANet::AddSAttrDatN ( const TNodeI NodeI,
const TStr AttrName,
const TFlt Val 
)
inline

Adds Flt sparse attribute with name AttrName to NodeI.

Definition at line 2887 of file network.h.

2887  {
2888  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
2889  }
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:1543
int TNEANet::AddSAttrDatN ( const TNodeI NodeI,
const TInt AttrId,
const TFlt Val 
)
inline

Adds Flt sparse attribute with id AttrId to NodeI.

Definition at line 2891 of file network.h.

2891  {
2892  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
2893  }
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:1543
int TNEANet::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 1571 of file network.cpp.

1571  {
1572  if (!IsNode(NId)) {
1573  return -1;
1574  }
1575  return SAttrN.AddSAttrDat(NId, AttrName, Val);
1576 }
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:2045
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
int TNEANet::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 1578 of file network.cpp.

1578  {
1579  if (!IsNode(NId)) {
1580  return -1;
1581  }
1582  return SAttrN.AddSAttrDat(NId, AttrId, Val);
1583 }
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:2045
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
int TNEANet::AddSAttrDatN ( const TNodeI NodeI,
const TStr AttrName,
const TStr Val 
)
inline

Adds Str sparse attribute with name AttrName to NodeI.

Definition at line 2901 of file network.h.

2901  {
2902  return AddSAttrDatN(NodeI.GetId(), AttrName, Val);
2903  }
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:1543
int TNEANet::AddSAttrDatN ( const TNodeI NodeI,
const TInt AttrId,
const TStr Val 
)
inline

Adds Str sparse attribute with id AttrId to NodeI.

Definition at line 2905 of file network.h.

2905  {
2906  return AddSAttrDatN(NodeI.GetId(), AttrId, Val);
2907  }
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:1543
int TNEANet::AddSAttrE ( const TStr Name,
const TAttrType AttrType,
TInt AttrId 
)

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

Definition at line 1783 of file network.cpp.

1783  {
1784  return SAttrE.AddSAttr(Name, AttrType, AttrId);
1785 }
TAttr SAttrE
Definition: network.h:2046
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
int TNEANet::AddSAttrN ( const TStr Name,
const TAttrType AttrType,
TInt AttrId 
)

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

Definition at line 1657 of file network.cpp.

1657  {
1658  return SAttrN.AddSAttr(Name, AttrType, AttrId);
1659 }
TAttr SAttrN
Definition: network.h:2045
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
int TNEANet::AddStrAttrDatE ( const TEdgeI EdgeI,
const TStr value,
const TStr attr 
)
inline

Attribute based add function for attr to Str value.

Adds the key str value pair to the corresponding edge attribute value vector.

Definition at line 2685 of file network.h.

2685 { return AddStrAttrDatE(EdgeI.GetId(), value, attr); }
int AddStrAttrDatE(const TEdgeI &EdgeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
Definition: network.h:2685
int TNEANet::AddStrAttrDatE ( const int &  EId,
const TStr value,
const TStr attr 
)

Definition at line 1098 of file network.cpp.

1098  {
1099  int i;
1100  TInt CurrLen;
1101  if (!IsEdge(EId)) {
1102  //AddEdge(EId);
1103  return -1;
1104  }
1105  if (KeyToIndexTypeE.IsKey(attr)) {
1107  NewVec[EdgeH.GetKeyId(EId)] = value;
1108  } else {
1109  CurrLen = VecOfStrVecsE.Len();
1110  KeyToIndexTypeE.AddDat(attr, TIntPr(StrType, CurrLen));
1111  TVec<TStr> NewVec = TVec<TStr>();
1112  for (i = 0; i < MxEId; i++) {
1113  NewVec.Ins(i, GetStrAttrDefaultE(attr));
1114  }
1115  NewVec[EdgeH.GetKeyId(EId)] = value;
1116  VecOfStrVecsE.Add(NewVec);
1117  }
1118  return 0;
1119 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TStr GetStrAttrDefaultE(const TStr &attribute) const
Gets Str edge attribute val. If not a proper attr, return default.
Definition: network.h:2021
TInt MxEId
Definition: network.h:2027
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
TVal2 Val2
Definition: ds.h:35
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddStrAttrDatN ( const TNodeI NodeI,
const TStr value,
const TStr attr 
)
inline

Attribute based add function for attr to Str value.

Adds the key str value pair to the corresponding node attribute value vector.

Definition at line 2659 of file network.h.

2659 { return AddStrAttrDatN(NodeI.GetId(), value, attr); }
int AddStrAttrDatN(const TNodeI &NodeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
Definition: network.h:2659
int TNEANet::AddStrAttrDatN ( const int &  NId,
const TStr value,
const TStr attr 
)

Definition at line 987 of file network.cpp.

987  {
988  int i;
989  TInt CurrLen;
990  if (!IsNode(NId)) {
991  // AddNode(NId);
992  return -1;
993  }
994  if (KeyToIndexTypeN.IsKey(attr)) {
996  NewVec[NodeH.GetKeyId(NId)] = value;
997  } else {
998  CurrLen = VecOfStrVecsN.Len();
999  KeyToIndexTypeN.AddDat(attr, TIntPr(StrType, CurrLen));
1000  TVec<TStr> NewVec = TVec<TStr>();
1001  for (i = 0; i < MxNId; i++) {
1002  NewVec.Ins(i, GetStrAttrDefaultN(attr));
1003  }
1004  NewVec[NodeH.GetKeyId(NId)] = value;
1005  VecOfStrVecsN.Add(NewVec);
1006  }
1007  return 0;
1008 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TInt MxNId
Definition: network.h:2027
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
TStr GetStrAttrDefaultN(const TStr &attribute) const
Gets Str node attribute val. If not a proper attr, return default.
Definition: network.h:2015
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
THash< TInt, TNode > NodeH
Definition: network.h:2028
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddStrAttrE ( const TStr attr,
TStr  defaultValue = TStr::GetNullStr() 
)

Adds a new Str edge attribute to the hashmap.

Definition at line 1380 of file network.cpp.

1380  {
1381  int i;
1382  TInt CurrLen;
1383  TVec<TStr> NewVec;
1384  CurrLen = VecOfStrVecsE.Len();
1385  KeyToIndexTypeE.AddDat(attr, TIntPr(StrType, CurrLen));
1386  NewVec = TVec<TStr>();
1387  for (i = 0; i < MxEId; i++) {
1388  NewVec.Ins(i, defaultValue);
1389  }
1390  VecOfStrVecsE.Add(NewVec);
1391  if (!StrDefaultsE.IsKey(attr)) {
1392  StrDefaultsE.AddDat(attr, defaultValue);
1393  } else {
1394  return -1;
1395  }
1396  return 0;
1397 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
TInt MxEId
Definition: network.h:2027
Definition: dt.h:1134
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
THash< TStr, TStr > StrDefaultsE
Definition: network.h:2036
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AddStrAttrN ( const TStr attr,
TStr  defaultValue = TStr::GetNullStr() 
)

Adds a new Str node attribute to the hashmap.

Definition at line 1303 of file network.cpp.

1303  {
1304  int i;
1305  TInt CurrLen;
1306  TVec<TStr> NewVec;
1307  CurrLen = VecOfStrVecsN.Len();
1308  KeyToIndexTypeN.AddDat(attr, TIntPr(StrType, CurrLen));
1309  NewVec = TVec<TStr>();
1310  for (i = 0; i < MxNId; i++) {
1311  NewVec.Ins(i, defaultValue);
1312  }
1313  VecOfStrVecsN.Add(NewVec);
1314  if (!StrDefaultsN.IsKey(attr)) {
1315  StrDefaultsN.AddDat(attr, defaultValue);
1316  } else {
1317  return -1;
1318  }
1319  return 0;
1320 }
TPair< TInt, TInt > TIntPr
Definition: ds.h:83
TInt MxNId
Definition: network.h:2027
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
THash< TStr, TStr > StrDefaultsN
Definition: network.h:2036
Definition: dt.h:1134
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
Definition: ds.h:1180
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
int TNEANet::AppendIntVAttrDatE ( const TEdgeI EdgeI,
const TInt value,
const TStr attr 
)
inline

Appends value onto the TIntV attribute for the given node.

Definition at line 2698 of file network.h.

2698 { return AppendIntVAttrDatE(EdgeI.GetId(), value, attr); }
int AppendIntVAttrDatE(const TEdgeI &EdgeI, const TInt &value, const TStr &attr)
Appends value onto the TIntV attribute for the given node.
Definition: network.h:2698
int TNEANet::AppendIntVAttrDatE ( const int &  EId,
const TInt value,
const TStr attr,
TBool  UseDense = true 
)

Definition at line 1079 of file network.cpp.

1079  {
1080  if (!IsNode(EId)) {
1081  // AddNode(NId);
1082  return -1;
1083  }
1084  TInt location = CheckDenseOrSparseE(attr);
1085  if (location==-1) return -1;
1086  if (UseDense) {
1087  IAssertR(location != 0, TStr::Fmt("Edge %d exists for %s in sparse representation", EId, attr.CStr()));
1089  NewVec[EdgeH.GetKeyId(EId)].Add(value);
1090  } else {
1091  IAssertR(location != 1, TStr::Fmt("Edge %d exists for %s in dense representation", EId, attr.CStr()));
1093  NewHash[EdgeH.GetKeyId(EId)].Add(value);
1094  }
1095  return 0;
1096 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TInt CheckDenseOrSparseE(const TStr &attr) const
Definition: network.h:2089
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
char * CStr()
Definition: dt.h:476
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
int TNEANet::AppendIntVAttrDatN ( const TNodeI NodeI,
const TInt value,
const TStr attr 
)
inline

Appends value onto the TIntV attribute for the given node.

Definition at line 2672 of file network.h.

2672 { return AppendIntVAttrDatN(NodeI.GetId(), value, attr); }
int AppendIntVAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Appends value onto the TIntV attribute for the given node.
Definition: network.h:2672
int TNEANet::AppendIntVAttrDatN ( const int &  NId,
const TInt value,
const TStr attr,
TBool  UseDense = true 
)

Definition at line 940 of file network.cpp.

940  {
941  if (!IsNode(NId)) {
942  // AddNode(NId);
943  return -1;
944  }
945  TInt location = CheckDenseOrSparseN(attr);
946  if (location==-1) {
947  AddIntVAttrN(attr, UseDense);
948  location = CheckDenseOrSparseN(attr);
949  }
950  if (UseDense) {
951  IAssertR(location != 0, TStr::Fmt("NodeId %d exists for %s in sparse representation", NId, attr.CStr()));
953  NewVec[NodeH.GetKeyId(NId)].Add(value);
954  } else {
955  IAssertR(location != 1, TStr::Fmt("NodeId %d exists for %s in dense representation", NId, attr.CStr()));
957  NewHash[NodeH.GetKeyId(NId)].Add(value);
958  }
959  return 0;
960 }
#define IAssertR(Cond, Reason)
Definition: bd.h:265
int AddIntVAttrN(const TStr &attr, TBool UseDense=true)
Adds a new IntV node attribute to the hashmap.
Definition: network.cpp:1285
TInt CheckDenseOrSparseN(const TStr &attr) const
Return 1 if in Dense, 0 if in Sparse, -1 if neither.
Definition: network.h:2083
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
char * CStr()
Definition: dt.h:476
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
void TNEANet::AttrNameEI ( const TInt EId,
TStrV Names 
) const
inline

Returns a vector of attr names for edge EId.

Definition at line 2438 of file network.h.

2438  {
2439  AttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
void AttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of attr names for edge EId.
Definition: network.h:2438
TIter BegI() const
Definition: hash.h:213
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
void TNEANet::AttrNameEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Names 
) const

Definition at line 260 of file network.cpp.

260  {
261  Names = TVec<TStr>();
262  while (!EdgeHI.IsEnd()) {
263  if (!EdgeAttrIsDeleted(EId, EdgeHI)) {
264  Names.Add(EdgeHI.GetKey());
265  }
266  EdgeHI++;
267  }
268 }
bool EdgeAttrIsDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge attr iterator.
Definition: network.cpp:398
const TKey & GetKey() const
Definition: hash.h:80
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:78
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
void TNEANet::AttrNameNI ( const TInt NId,
TStrV Names 
) const
inline

Returns a vector of attr names for node NId.

Definition at line 2392 of file network.h.

2392  {
2393  AttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
TIter BegI() const
Definition: hash.h:213
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
void AttrNameNI(const TInt &NId, TStrV &Names) const
Returns a vector of attr names for node NId.
Definition: network.h:2392
void TNEANet::AttrNameNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Names 
) const

Definition at line 68 of file network.cpp.

68  {
69  Names = TVec<TStr>();
70  while (!NodeHI.IsEnd()) {
71  if (!NodeAttrIsDeleted(NId, NodeHI)) {
72  Names.Add(NodeHI.GetKey());
73  }
74  NodeHI++;
75  }
76 }
bool NodeAttrIsDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Returns true if NId attr deleted for current node attr iterator.
Definition: network.cpp:206
const TKey & GetKey() const
Definition: hash.h:80
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:78
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
void TNEANet::AttrValueEI ( const TInt EId,
TStrV Values 
) const
inline

Returns a vector of attr values for edge EId.

Definition at line 2442 of file network.h.

2442  {
2443  AttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
TIter BegI() const
Definition: hash.h:213
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
void AttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for edge EId.
Definition: network.h:2442
void TNEANet::AttrValueEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Values 
) const

Definition at line 270 of file network.cpp.

270  {
271  Values = TVec<TStr>();
272  while (!EdgeHI.IsEnd()) {
273  if (!EdgeAttrIsDeleted(EId, EdgeHI)) {
274  Values.Add(GetEdgeAttrValue(EId, EdgeHI));
275  }
276  EdgeHI++;
277  }
278 }
TStr GetEdgeAttrValue(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns edge attribute value, converted to Str type.
Definition: network.cpp:430
bool EdgeAttrIsDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge attr iterator.
Definition: network.cpp:398
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:78
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
void TNEANet::AttrValueNI ( const TInt NId,
TStrV Values 
) const
inline

Returns a vector of attr values for node NId.

Definition at line 2396 of file network.h.

2396  {
2397  AttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
TIter BegI() const
Definition: hash.h:213
void AttrValueNI(const TInt &NId, TStrV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:2396
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
void TNEANet::AttrValueNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Values 
) const

Definition at line 78 of file network.cpp.

78  {
79  Values = TVec<TStr>();
80  while (!NodeHI.IsEnd()) {
81  if (!NodeAttrIsDeleted(NId, NodeHI)) {
82  Values.Add(GetNodeAttrValue(NId, NodeHI));
83  }
84  NodeHI++;
85  }
86 }
bool NodeAttrIsDeleted(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Returns true if NId attr deleted for current node attr iterator.
Definition: network.cpp:206
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
Definition: hash.h:78
TStr GetNodeAttrValue(const int &NId, const TStrIntPrH::TIter &NodeHI) const
Returns node attribute value, converted to Str type.
Definition: network.cpp:246
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:602
TAFltI TNEANet::BegEAFltI ( const TStr attr) const
inline

Returns an iterator referring to the first edge's flt attribute.

Definition at line 2559 of file network.h.

2559  {
2560  return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, true, this);
2561  }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TVal2 Val2
Definition: ds.h:35
TAIntI TNEANet::BegEAIntI ( const TStr attr) const
inline

Returns an iterator referring to the first edge's int attribute.

Definition at line 2483 of file network.h.

2483  {
2484  return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, true, this);
2485  }
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
Definition: ds.h:593
TVal2 Val2
Definition: ds.h:35
TAIntVI TNEANet::BegEAIntVI ( const TStr attr) const
inline

Returns an iterator referring to the first edge's int attribute.

Definition at line 2496 of file network.h.

2496  {
2497  TVec<TIntV>::TIter HI = NULL;
2499  TInt location = CheckDenseOrSparseE(attr);
2500  TBool IsDense = true;
2501  if (location != -1) {
2502  TInt index = KeyToIndexTypeE.GetDat(attr).Val2;
2503  if (location == 1) {
2504  HI = VecOfIntVecVecsE[index].BegI();
2505  } else {
2506  IsDense = false;
2507  HHI = VecOfIntHashVecsE[index].BegI();
2508  }
2509  }
2510  return TAIntVI(HI, HHI, attr, true, this, IsDense);
2511  }
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TInt CheckDenseOrSparseE(const TStr &attr) const
Definition: network.h:2089
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
Definition: dt.h:1134
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
Definition: ds.h:593
Definition: hash.h:97
TVal2 Val2
Definition: ds.h:35
Definition: dt.h:971
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:430
TAStrI TNEANet::BegEAStrI ( const TStr attr) const
inline

Returns an iterator referring to the first edge's str attribute.

Definition at line 2548 of file network.h.

2548  {
2549  return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, true, this); }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVal2 Val2
Definition: ds.h:35
TEdgeI TNEANet::BegEI ( ) const
inline

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

Definition at line 2603 of file network.h.

2603 { return TEdgeI(EdgeH.BegI(), this); }
TIter BegI() const
Definition: hash.h:213
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TAFltI TNEANet::BegNAFltI ( const TStr attr) const
inline

Returns an iterator referring to the first node's flt attribute.

Definition at line 2382 of file network.h.

2382  {
2383  return TAFltI(VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr, false, this); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVal2 Val2
Definition: ds.h:35
TAIntI TNEANet::BegNAIntI ( const TStr attr) const
inline

Returns an iterator referring to the first node's int attribute.

Definition at line 2306 of file network.h.

2306  {
2307  return TAIntI(VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr, false, this); }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
Definition: ds.h:593
TVal2 Val2
Definition: ds.h:35
TAIntVI TNEANet::BegNAIntVI ( const TStr attr) const
inline

Returns an iterator referring to the first node's int attribute.

Definition at line 2316 of file network.h.

2316  {
2317  TVec<TIntV>::TIter HI = NULL;
2319  TInt location = CheckDenseOrSparseN(attr);
2320  TBool IsDense = true;
2321  if (location != -1) {
2322  TInt index = KeyToIndexTypeN.GetDat(attr).Val2;
2323  if (location == 1) {
2324  HI = VecOfIntVecVecsN[index].BegI();
2325  } else {
2326  IsDense = false;
2327  HHI = VecOfIntHashVecsN[index].BegI();
2328  }
2329  }
2330  return TAIntVI(HI, HHI, attr, false, this, IsDense);
2331  }
TInt CheckDenseOrSparseN(const TStr &attr) const
Return 1 if in Dense, 0 if in Sparse, -1 if neither.
Definition: network.h:2083
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
Definition: dt.h:1134
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
Definition: ds.h:593
Definition: hash.h:97
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
TVal2 Val2
Definition: ds.h:35
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
Definition: dt.h:971
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:430
TAStrI TNEANet::BegNAStrI ( const TStr attr) const
inline

Returns an iterator referring to the first node's str attribute.

Definition at line 2372 of file network.h.

2372  {
2373 
2374  return TAStrI(VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr, false, this); }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
TVal2 Val2
Definition: ds.h:35
TNodeI TNEANet::BegNI ( ) const
inline

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

Definition at line 2300 of file network.h.

2300 { return TNodeI(NodeH.BegI(), this); }
TIter BegI() const
Definition: hash.h:213
THash< TInt, TNode > NodeH
Definition: network.h:2028
TInt TNEANet::CheckDenseOrSparseE ( const TStr attr) const
inlineprotected

Definition at line 2089 of file network.h.

2089  {
2090  if (!KeyToDenseE.IsKey(attr)) return -1;
2091  if (KeyToDenseE.GetDat(attr)) return 1;
2092  return 0;
2093  }
THash< TStr, TBool > KeyToDenseE
Definition: network.h:2033
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
bool IsKey(const TKey &Key) const
Definition: hash.h:258
TInt TNEANet::CheckDenseOrSparseN ( const TStr attr) const
inlineprotected

Return 1 if in Dense, 0 if in Sparse, -1 if neither.

Definition at line 2083 of file network.h.

2083  {
2084  if (!KeyToDenseN.IsKey(attr)) return -1;
2085  if (KeyToDenseN.GetDat(attr)) return 1;
2086  return 0;
2087  }
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
bool IsKey(const TKey &Key) const
Definition: hash.h:258
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
Definition: network.h:2033
void TNEANet::Clr ( )
inline

Deletes all nodes and edges from the graph.

Definition at line 2627 of file network.h.

2627  { MxNId=0; MxEId=0; NodeH.Clr(); EdgeH.Clr();
2631  VecOfFltVecsN.Clr(); VecOfFltVecsE.Clr(); VecOfIntVecVecsN.Clr(); VecOfIntVecVecsE.Clr();
2632  SAttrN.Clr(); SAttrE.Clr();}
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:2037
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
THash< TStr, TInt > IntDefaultsE
Definition: network.h:2035
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
TAttr SAttrN
Definition: network.h:2045
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:2037
TInt MxNId
Definition: network.h:2027
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TAttr SAttrE
Definition: network.h:2046
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:1022
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
THash< TStr, TStr > StrDefaultsN
Definition: network.h:2036
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
TInt MxEId
Definition: network.h:2027
THash< TStr, TStr > StrDefaultsE
Definition: network.h:2036
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
Definition: hash.h:361
THash< TStr, TInt > IntDefaultsN
Definition: network.h:2035
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
void Clr()
Clears the contents of the attribute map.
Definition: attr.h:37
void TNEANet::ConvertToSparse ( )
inline

Definition at line 2228 of file network.h.

2228  {
2229  TInt VecLength = VecOfIntVecVecsN.Len();
2231  if (VecLength != 0) {
2233  for (iter = KeyToIndexTypeN.BegI(); !iter.IsEnd(); iter=iter.Next()) {
2234  if (iter.GetDat().Val1 == IntVType) {
2235  TStr attribute = iter.GetKey();
2236  TInt index = iter.GetDat().Val2();
2237  for (int i=0; i<VecOfIntVecVecsN[index].Len(); i++) {
2238  if(VecOfIntVecVecsN[index][i].Len() > 0) {
2239  VecOfIntHashVecsN[index].AddDat(TInt(i), VecOfIntVecVecsN[index][i]);
2240  }
2241  }
2242  KeyToDenseN.AddDat(attribute, TBool(false));
2243  }
2244  }
2245  }
2246  VecOfIntVecVecsN.Clr();
2247 
2248  VecLength = VecOfIntVecVecsE.Len();
2249  if (VecLength != 0) {
2251  for (iter = KeyToIndexTypeE.BegI(); !iter.IsEnd(); iter=iter.Next()) {
2252  if (iter.GetDat().Val1 == IntVType) {
2253  TStr attribute = iter.GetKey();
2254  TInt index = iter.GetDat().Val2();
2255  for (int i=0; i<VecOfIntVecVecsE[index].Len(); i++) {
2256  if(VecOfIntVecVecsE[index][i].Len() > 0) {
2257  VecOfIntHashVecsE[index].AddDat(TInt(i), VecOfIntVecVecsE[index][i]);
2258  }
2259  }
2260  KeyToDenseE.AddDat(attribute, TBool(false));
2261  }
2262  }
2263  }
2264  VecOfIntVecVecsE.Clr();
2265  }
THash< TStr, TBool > KeyToDenseE
Definition: network.h:2033
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TIter BegI() const
Definition: hash.h:213
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
Definition: dt.h:1134
Definition: dt.h:412
Definition: hash.h:97
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
TVal1 Val1
Definition: ds.h:34
TVal2 Val2
Definition: ds.h:35
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
Definition: dt.h:971
TDat & AddDat(const TKey &Key)
Definition: hash.h:238
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
Definition: network.h:2033
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:252
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:430
void TNEANet::Defrag ( const bool &  OnlyNodeLinks = false)

Defragments the graph.

After performing many node and edge insertions and deletions to a graph, the graph data structure will be fragmented in memory. This function compacts down the graph data structure and frees unneeded memory.

Definition at line 765 of file network.cpp.

765  {
766  for (int kid = NodeH.FFirstKeyId(); NodeH.FNextKeyId(kid); ) {
767  TNode& Node = NodeH[kid];
768  Node.InEIdV.Pack(); Node.OutEIdV.Pack();
769  }
770  if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) { NodeH.Defrag(); }
771  if (! OnlyNodeLinks && ! EdgeH.IsKeyIdEqKeyN()) { EdgeH.Defrag(); }
772 }
bool IsKeyIdEqKeyN() const
Definition: hash.h:233
void Defrag()
Definition: hash.h:555
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
bool FNextKeyId(int &KeyId) const
Definition: hash.h:478
int FFirstKeyId() const
Definition: hash.h:278
THash< TInt, TNode > NodeH
Definition: network.h:2028
void Pack()
Definition: hash.h:289
int TNEANet::DelAttrDatE ( const TEdgeI EdgeI,
const TStr attr 
)
inline

Deletes the edge attribute for NodeI.

Definition at line 2771 of file network.h.

2771 { return DelAttrDatE(EdgeI.GetId(), attr); }
int DelAttrDatE(const TEdgeI &EdgeI, const TStr &attr)
Deletes the edge attribute for NodeI.
Definition: network.h:2771
int TNEANet::DelAttrDatE ( const int &  EId,
const TStr attr 
)

Definition at line 1247 of file network.cpp.

1247  {
1248  // TODO(nkhadke): add error checking
1249  TInt vecType = KeyToIndexTypeE(attr).Val1;
1250  if (vecType == IntType) {
1252  } else if (vecType == StrType) {
1254  } else if (vecType == FltType) {
1256  } else if (vecType == IntVType) {
1257  TInt location = CheckDenseOrSparseE(attr);
1258  if (location == 0) VecOfIntHashVecsE[KeyToIndexTypeE.GetDat(attr).Val2][EdgeH.GetKeyId(EId)] = TIntV();
1260  } else {
1261  return -1;
1262  }
1263  return 0;
1264 }
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TInt GetIntAttrDefaultE(const TStr &attribute) const
Gets Int edge attribute val. If not a proper attr, return default.
Definition: network.h:2019
TInt CheckDenseOrSparseE(const TStr &attr) const
Definition: network.h:2089
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TStr GetStrAttrDefaultE(const TStr &attribute) const
Gets Str edge attribute val. If not a proper attr, return default.
Definition: network.h:2021
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Gets Flt edge attribute val. If not a proper attr, return default.
Definition: network.h:2023
TVec< TInt > TIntV
Definition: ds.h:1594
TVal2 Val2
Definition: ds.h:35
int TNEANet::DelAttrDatN ( const TNodeI NodeI,
const TStr attr 
)
inline

Deletes the node attribute for NodeI.

Definition at line 2768 of file network.h.

2768 { return DelAttrDatN(NodeI.GetId(), attr); }
int DelAttrDatN(const TNodeI &NodeI, const TStr &attr)
Deletes the node attribute for NodeI.
Definition: network.h:2768
int TNEANet::DelAttrDatN ( const int &  NId,
const TStr attr 
)

Definition at line 1229 of file network.cpp.

1229  {
1230  TInt vecType = KeyToIndexTypeN(attr).Val1;
1231  if (vecType == IntType) {
1233  } else if (vecType == StrType) {
1235  } else if (vecType == FltType) {
1237  } else if (vecType ==IntVType) {
1238  TInt location = CheckDenseOrSparseN(attr);
1239  if (location == 0) VecOfIntHashVecsN[KeyToIndexTypeN.GetDat(attr).Val2][NodeH.GetKeyId(NId)] = TIntV();
1241  } else {
1242  return -1;
1243  }
1244  return 0;
1245 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
TInt CheckDenseOrSparseN(const TStr &attr) const
Return 1 if in Dense, 0 if in Sparse, -1 if neither.
Definition: network.h:2083
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
TStr GetStrAttrDefaultN(const TStr &attribute) const
Gets Str node attribute val. If not a proper attr, return default.
Definition: network.h:2015
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
TVec< TInt > TIntV
Definition: ds.h:1594
TVal2 Val2
Definition: ds.h:35
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Gets Flt node attribute val. If not a proper attr, return default.
Definition: network.h:2017
TInt GetIntAttrDefaultN(const TStr &attribute) const
Gets Int node attribute val. If not a proper attr, return default.
Definition: network.h:2013
int TNEANet::DelAttrE ( const TStr attr)

Removes all the values for edge attr.

Definition at line 1447 of file network.cpp.

1447  {
1448  TInt vecType = KeyToIndexTypeE(attr).Val1;
1449  if (vecType == IntType) {
1451  if (IntDefaultsE.IsKey(attr)) {
1452  IntDefaultsE.DelKey(attr);
1453  }
1454  } else if (vecType == StrType) {
1456  if (StrDefaultsE.IsKey(attr)) {
1457  StrDefaultsE.DelKey(attr);
1458  }
1459  } else if (vecType == FltType) {
1461  if (FltDefaultsE.IsKey(attr)) {
1462  FltDefaultsE.DelKey(attr);
1463  }
1464  } else {
1465  return -1;
1466  }
1467  KeyToIndexTypeE.DelKey(attr);
1468  return 0;
1469 }
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:2037
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
THash< TStr, TInt > IntDefaultsE
Definition: network.h:2035
TStrIntPrH KeyToIndexTypeE
Definition: network.h:2031
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
void DelKey(const TKey &Key)
Definition: hash.h:404
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
Definition: dt.h:1134
THash< TStr, TStr > StrDefaultsE
Definition: network.h:2036
TVal2 Val2
Definition: ds.h:35
bool IsKey(const TKey &Key) const
Definition: hash.h:258
int TNEANet::DelAttrN ( const TStr attr)

Removes all the values for node attr.

Definition at line 1418 of file network.cpp.

1418  {
1419  TInt vecType = KeyToIndexTypeN(attr).Val1;
1420  if (vecType == IntType) {
1422  if (IntDefaultsN.IsKey(attr)) {
1423  IntDefaultsN.DelKey(attr);
1424  }
1425  } else if (vecType == StrType) {
1427  if (StrDefaultsN.IsKey(attr)) {
1428  StrDefaultsN.DelKey(attr);
1429  }
1430  } else if (vecType == FltType) {
1432  if (FltDefaultsN.IsKey(attr)) {
1433  FltDefaultsN.DelKey(attr);
1434  }
1435  } else if (vecType == IntVType) {
1436  TInt location = CheckDenseOrSparseN(attr);
1437  if (location == 1) VecOfIntVecVecsN[KeyToIndexTypeN.GetDat(attr).Val2] = TVec<TIntV>();
1439  KeyToDenseN.DelKey(attr);
1440  } else {
1441  return -1;
1442  }
1443  KeyToIndexTypeN.DelKey(attr);
1444  return 0;
1445 }
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
TInt CheckDenseOrSparseN(const TStr &attr) const
Return 1 if in Dense, 0 if in Sparse, -1 if neither.
Definition: network.h:2083
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:2037
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
void DelKey(const TKey &Key)
Definition: hash.h:404
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
THash< TStr, TStr > StrDefaultsN
Definition: network.h:2036
Definition: dt.h:1134
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
TVal2 Val2
Definition: ds.h:35
THash< TStr, TInt > IntDefaultsN
Definition: network.h:2035
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
bool IsKey(const TKey &Key) const
Definition: hash.h:258
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
Definition: network.h:2033
void TNEANet::DelEdge ( const int &  EId)

Deletes an edge with edge ID EId from the graph.

Definition at line 692 of file network.cpp.

692  {
693  int i;
694 
695  IAssert(IsEdge(EId));
696  const int SrcNId = GetEdge(EId).GetSrcNId();
697  const int DstNId = GetEdge(EId).GetDstNId();
698  GetNode(SrcNId).OutEIdV.DelIfIn(EId);
699  GetNode(DstNId).InEIdV.DelIfIn(EId);
700  TInt Id(EId);
701  SAttrE.DelSAttrId(Id);
702 
703  for (i = 0; i < VecOfIntVecsE.Len(); i++) {
704  TVec<TInt>& IntVec = VecOfIntVecsE[i];
705  IntVec[EdgeH.GetKeyId(EId)] = TInt::Mn;
706  }
707  for (i = 0; i < VecOfStrVecsE.Len(); i++) {
708  TVec<TStr>& StrVec = VecOfStrVecsE[i];
709  StrVec[EdgeH.GetKeyId(EId)] = TStr::GetNullStr();
710  }
711  for (i = 0; i < VecOfFltVecsE.Len(); i++) {
712  TVec<TFlt>& FltVec = VecOfFltVecsE[i];
713  FltVec[EdgeH.GetKeyId(EId)] = TFlt::Mn;
714  }
715 
716  EdgeH.DelKey(EId);
717 }
#define IAssert(Cond)
Definition: bd.h:262
bool DelIfIn(const TVal &Val)
Removes the first occurrence of element Val.
Definition: ds.h:1212
int GetSrcNId() const
Definition: network.h:1782
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
TNode & GetNode(const int &NId)
Definition: network.h:2005
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
TIntV OutEIdV
Definition: network.h:1749
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
void DelSAttrId(const TInt &Id)
Delete all attributes for the given id Id.
Definition: attr.cpp:124
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
void DelKey(const TKey &Key)
Definition: hash.h:404
TAttr SAttrE
Definition: network.h:2046
static const int Mn
Definition: dt.h:1138
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
int GetDstNId() const
Definition: network.h:1783
static TStr GetNullStr()
Definition: dt.cpp:1626
Definition: dt.h:1134
TEdge & GetEdge(const int &EId)
Definition: network.h:2007
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
TIntV InEIdV
Definition: network.h:1749
static const double Mn
Definition: dt.h:1387
void TNEANet::DelEdge ( const int &  SrcNId,
const int &  DstNId,
const bool &  IsDir = true 
)

Deletes all edges between node IDs SrcNId and DstNId from the graph.

If the edge (SrcNId, DstNId) does not exist in the graph function still completes. But the function aborts if SrcNId or DstNId are not nodes in the graph.

Definition at line 720 of file network.cpp.

720  {
721  int EId = 0;
722  bool Edge = IsEdge(SrcNId, DstNId, EId, IsDir);
723  IAssert(Edge); // there is at least one edge
724  while (Edge) {
725  DelEdge(EId);
726  Edge = IsEdge(SrcNId, DstNId, EId, IsDir);
727  }
728 }
#define IAssert(Cond)
Definition: bd.h:262
void DelEdge(const int &EId)
Deletes an edge with edge ID EId from the graph.
Definition: network.cpp:692
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
int TNEANet::DelFromIntVAttrDatN ( const TNodeI NodeI,
const TInt value,
const TStr attr 
)
inline

Deletes value from the TIntV attribute for the given node.

Definition at line 2675 of file network.h.

2675 { return DelFromIntVAttrDatN(NodeI.GetId(), value, attr); }
int DelFromIntVAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Deletes value from the TIntV attribute for the given node.
Definition: network.h:2675
int TNEANet::DelFromIntVAttrDatN ( const int &  NId,
const TInt value,
const TStr attr 
)

Definition at line 962 of file network.cpp.

962  {
963  TInt CurrLen;
964  if (!IsNode(NId)) {
965  // AddNode(NId);
966  return -1;
967  }
968  TInt location = CheckDenseOrSparseN(attr);
969  if (location != -1) {
970  if (location == 1) {
972  if (!NewVec[NodeH.GetKeyId(NId)].DelIfIn(value)) {
973  return -1;
974  }
975  } else {
977  if (!NewHash[NodeH.GetKeyId(NId)].DelIfIn(value)) {
978  return -1;
979  }
980  }
981  } else {
982  return -1;
983  }
984  return 0;
985 }
bool DelIfIn(const TVal &Val)
Removes the first occurrence of element Val.
Definition: ds.h:1212
TInt CheckDenseOrSparseN(const TStr &attr) const
Return 1 if in Dense, 0 if in Sparse, -1 if neither.
Definition: network.h:2083
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:262
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:2031
Definition: dt.h:1134
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
TVal2 Val2
Definition: ds.h:35
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
void TNEANet::DelNode ( const int &  NId)
virtual

Deletes node of ID NId from the graph.

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

Reimplemented in TModeNet.

Definition at line 531 of file network.cpp.

531  {
532  int i;
533  TInt Id(NId);
534  SAttrN.DelSAttrId(Id);
535  const TNode& Node = GetNode(NId);
536  for (int out = 0; out < Node.GetOutDeg(); out++) {
537  const int EId = Node.GetOutEId(out);
538  const TEdge& Edge = GetEdge(EId);
539  IAssert(Edge.GetSrcNId() == NId);
540  GetNode(Edge.GetDstNId()).InEIdV.DelIfIn(EId);
541  // Delete from Edge Attributes
542  for (i = 0; i < VecOfIntVecsE.Len(); i++) {
543  TVec<TInt>& IntVec = VecOfIntVecsE[i];
544  IntVec[EdgeH.GetKeyId(EId)] = TInt::Mn;
545  }
546  for (i = 0; i < VecOfStrVecsE.Len(); i++) {
547  TVec<TStr>& StrVec = VecOfStrVecsE[i];
548  StrVec[EdgeH.GetKeyId(EId)] = TStr::GetNullStr();
549  }
550  for (i = 0; i < VecOfFltVecsE.Len(); i++) {
551  TVec<TFlt>& FltVec = VecOfFltVecsE[i];
552  FltVec[EdgeH.GetKeyId(EId)] = TFlt::Mn;
553  }
554  for (i = 0; i < VecOfIntVecVecsE.Len(); i++) {
555  TVec<TIntV>& IntVecV = VecOfIntVecVecsE[i];
556  IntVecV[EdgeH.GetKeyId(EId)] = TIntV();
557  }
558  EdgeH.DelKey(EId);
559  for (i = 0; i < VecOfIntHashVecsE.Len(); i++) {
560  THash<TInt, TIntV>& IntHashV = VecOfIntHashVecsE[i];
561  if (IntHashV.IsKey(EdgeH.GetKeyId(EId))) {
562  IntHashV.DelKey(EdgeH.GetKeyId(EId));
563  }
564  }
565  }
566  for (int in = 0; in < Node.GetInDeg(); in++) {
567  const int EId = Node.GetInEId(in);
568  const TEdge& Edge = GetEdge(EId);
569  IAssert(Edge.GetDstNId() == NId);
570  GetNode(Edge.GetSrcNId()).OutEIdV.DelIfIn(EId);
571  // Delete from Edge Attributes
572  for (i = 0; i < VecOfIntVecsE.Len(); i++) {
573  TVec<TInt>& IntVec = VecOfIntVecsE[i];
574  IntVec[EdgeH.GetKeyId(EId)] = TInt::Mn;
575  }
576  for (i = 0; i < VecOfStrVecsE.Len(); i++) {
577  TVec<TStr>& StrVec = VecOfStrVecsE[i];
578  StrVec[EdgeH.GetKeyId(EId)] = TStr::GetNullStr();
579  }
580  for (i = 0; i < VecOfFltVecsE.Len(); i++) {
581  TVec<TFlt>& FltVec = VecOfFltVecsE[i];
582  FltVec[EdgeH.GetKeyId(EId)] = TFlt::Mn;
583  }
584  for (i = 0; i < VecOfIntVecVecsE.Len(); i++) {
585  TVec<TIntV>& IntVecV = VecOfIntVecVecsE[i];
586  IntVecV[EdgeH.GetKeyId(EId)] = TIntV();
587  }
588  for (i = 0; i < VecOfIntHashVecsE.Len(); i++) {
589  THash<TInt, TIntV>& IntHashV = VecOfIntHashVecsE[i];
590  if (IntHashV.IsKey(EdgeH.GetKeyId(EId))) {
591  IntHashV.DelKey(EdgeH.GetKeyId(EId));
592  }
593  }
594  EdgeH.DelKey(EId);
595  }
596 
597  for (i = 0; i < VecOfIntVecsN.Len(); i++) {
598  TVec<TInt>& IntVec = VecOfIntVecsN[i];
599  IntVec[NodeH.GetKeyId(NId)] = TInt::Mn;
600  }
601  for (i = 0; i < VecOfStrVecsN.Len(); i++) {
602  TVec<TStr>& StrVec = VecOfStrVecsN[i];
603  StrVec[NodeH.GetKeyId(NId)] = TStr::GetNullStr();
604  }
605  for (i = 0; i < VecOfFltVecsN.Len(); i++) {
606  TVec<TFlt>& FltVec = VecOfFltVecsN[i];
607  FltVec[NodeH.GetKeyId(NId)] = TFlt::Mn;
608  }
609  for (i = 0; i < VecOfIntVecVecsN.Len(); i++) {
610  TVec<TIntV>& IntVecV = VecOfIntVecVecsN[i];
611  IntVecV[NodeH.GetKeyId(NId)] = TIntV();
612  }
613  for (i = 0; i < VecOfIntHashVecsN.Len(); i++) {
614  THash<TInt, TIntV>& IntHashV = VecOfIntHashVecsN[i];
615  if (IntHashV.IsKey(NodeH.GetKeyId(NId))) {
616  IntHashV.DelKey(NodeH.GetKeyId(NId));
617  }
618  }
619  NodeH.DelKey(NId);
620 }
#define IAssert(Cond)
Definition: bd.h:262
TVec< TIntV > VecOfIntVecsN
Definition: network.h:2038
TVec< TStrV > VecOfStrVecsE
Definition: network.h:2039
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
Definition: network.h:2042
TNode & GetNode(const int &NId)
Definition: network.h:2005
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TAttr SAttrN
Definition: network.h:2045
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
void DelSAttrId(const TInt &Id)
Delete all attributes for the given id Id.
Definition: attr.cpp:124
TVec< TStrV > VecOfStrVecsN
Definition: network.h:2039
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
void DelKey(const TKey &Key)
Definition: hash.h:404
static const int Mn
Definition: dt.h:1138
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:2041
static TStr GetNullStr()
Definition: dt.cpp:1626
Definition: dt.h:1134
TEdge & GetEdge(const int &EId)
Definition: network.h:2007
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
TVec< TFltV > VecOfFltVecsN
Definition: network.h:2040
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
Definition: network.h:2042
TVec< TInt > TIntV
Definition: ds.h:1594
THash< TInt, TNode > NodeH
Definition: network.h:2028
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:2041
bool IsKey(const TKey &Key) const
Definition: hash.h:258
static const double Mn
Definition: dt.h:1387
void TNEANet::DelNode ( const TNode NodeI)
inline

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

Definition at line 2296 of file network.h.

2296 { DelNode(NodeI.GetId()); }
virtual void DelNode(const int &NId)
Deletes node of ID NId from the graph.
Definition: network.cpp:531
int TNEANet::DelSAttrDatE ( const TInt EId,
const TStr AttrName 
)

Deletes sparse attribute with name AttrName from edge with id EId.

Definition at line 1753 of file network.cpp.

1753  {
1754  if (!IsEdge(EId)) {
1755  return -1;
1756  }
1757  return SAttrE.DelSAttrDat(EId, AttrName);
1758 }
int DelSAttrDat(const TInt &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:103
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
TAttr SAttrE
Definition: network.h:2046
int TNEANet::DelSAttrDatE ( const TInt EId,
const TInt AttrId 
)

Deletes sparse attribute with id AttrId from edge with id EId.

Definition at line 1760 of file network.cpp.

1760  {
1761  if (!IsEdge(EId)) {
1762  return -1;
1763  }
1764  return SAttrE.DelSAttrDat(EId, AttrId);
1765 }
int DelSAttrDat(const TInt &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:103
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: network.h:2595
TAttr SAttrE
Definition: network.h:2046
int TNEANet::DelSAttrDatE ( const TEdgeI EdgeI,
const TStr AttrName 
)
inline

Deletes sparse attribute with name AttrName from EdgeI.

Definition at line 3075 of file network.h.

3075  {
3076  return DelSAttrDatE(EdgeI.GetId(), AttrName);
3077  }
int DelSAttrDatE(const TInt &EId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from edge with id EId.
Definition: network.cpp:1753
int TNEANet::DelSAttrDatE ( const TEdgeI EdgeI,
const TInt AttrId 
)
inline

Deletes sparse attribute with id AttrId from EdgeI.

Definition at line 3079 of file network.h.

3079  {
3080  return DelSAttrDatE(EdgeI.GetId(), AttrId);
3081  }
int DelSAttrDatE(const TInt &EId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from edge with id EId.
Definition: network.cpp:1753
int TNEANet::DelSAttrDatN ( const TInt NId,
const TStr AttrName 
)

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

Definition at line 1627 of file network.cpp.

1627  {
1628  if (!IsNode(NId)) {
1629  return -1;
1630  }
1631  return SAttrN.DelSAttrDat(NId, AttrName);
1632 }
int DelSAttrDat(const TInt &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:103
TAttr SAttrN
Definition: network.h:2045
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
int TNEANet::DelSAttrDatN ( const TInt NId,
const TInt AttrId 
)

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

Definition at line 1634 of file network.cpp.

1634  {
1635  if (!IsNode(NId)) {
1636  return -1;
1637  }
1638  return SAttrN.DelSAttrDat(NId, AttrId);
1639 }
int DelSAttrDat(const TInt &Id, const TStr &AttrName)
Delete attribute with name AttrName for the given id Id.
Definition: attr.cpp:103
TAttr SAttrN
Definition: network.h:2045
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: network.h:2298
int TNEANet::DelSAttrDatN ( const TNodeI NodeI,
const TStr AttrName 
)
inline

Deletes sparse attribute with name AttrName from NodeI.

Definition at line 2957 of file network.h.

2957  {
2958  return DelSAttrDatN(NodeI.GetId(), AttrName);
2959  }
int DelSAttrDatN(const TInt &NId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:1627
int TNEANet::DelSAttrDatN ( const TNodeI NodeI,
const TInt AttrId 
)
inline

Deletes sparse attribute with id AttrId from NodeI.

Definition at line 2961 of file network.h.

2961  {
2962  return DelSAttrDatN(NodeI.GetId(), AttrId);
2963  }
int DelSAttrDatN(const TInt &NId, const TStr &AttrName)
Deletes sparse attribute with name AttrName from node with id NId.
Definition: network.cpp:1627
void TNEANet::Dump ( FILE *  OutF = stdout) const

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

Definition at line 827 of file network.cpp.

827  {
828  const int NodePlaces = (int) ceil(log10((double) GetNodes()));
829  const int EdgePlaces = (int) ceil(log10((double) GetEdges()));
830  fprintf(OutF, "-------------------------------------------------\nDirected Node-Edge Network with Attributes: nodes: %d, edges: %d\n", GetNodes(), GetEdges());
831  for (TNodeI NodeI = BegNI(); NodeI < EndNI(); NodeI++) {
832  fprintf(OutF, " %*d:", NodePlaces, NodeI.GetId());
833  fprintf(OutF, " in[%d]", NodeI.GetInDeg());
834  for (int edge = 0; edge < NodeI.GetInDeg(); edge++) {
835  fprintf(OutF, " %*d", EdgePlaces, NodeI.GetInEId(edge)); }
836  //fprintf(OutF, "\n");
837  fprintf(OutF, " out[%d]", NodeI.GetOutDeg());
838  for (int edge = 0; edge < NodeI.GetOutDeg(); edge++) {
839  fprintf(OutF, " %*d", EdgePlaces, NodeI.GetOutEId(edge)); }
840  //fprintf(OutF, "\n");
841 
842  // load node attributes
843  TIntV IntAttrN;
844  IntAttrValueNI(NodeI.GetId(), IntAttrN);
845  fprintf(OutF, " nai[%d]", IntAttrN.Len());
846  for (int i = 0; i < IntAttrN.Len(); i++) {
847  fprintf(OutF, " %*i", NodePlaces, IntAttrN[i]()); }
848  //fprintf(OutF, "\n");
849 
850  TStrV StrAttrN;
851  StrAttrValueNI(NodeI.GetId(), StrAttrN);
852  fprintf(OutF, " nas[%d]", StrAttrN.Len());
853  for (int i = 0; i < StrAttrN.Len(); i++) {
854  fprintf(OutF, " %*s", NodePlaces, StrAttrN[i]()); }
855  //fprintf(OutF, "\n");
856 
857  TFltV FltAttrN;
858  FltAttrValueNI(NodeI.GetId(), FltAttrN);
859  fprintf(OutF, " naf[%d]", FltAttrN.Len());
860  for (int i = 0; i < FltAttrN.Len(); i++) {
861  fprintf(OutF, " %*f", NodePlaces, FltAttrN[i]()); }
862  //fprintf(OutF, "\n");
863  fprintf(OutF, "\n");
864  }
865  for (TEdgeI EdgeI = BegEI(); EdgeI < EndEI(); EdgeI++) {
866  fprintf(OutF, " %*d: %*d -> %*d", EdgePlaces, EdgeI.GetId(), NodePlaces, EdgeI.GetSrcNId(), NodePlaces, EdgeI.GetDstNId());
867 
868  // load edge attributes
869  TIntV IntAttrE;
870  IntAttrValueEI(EdgeI.GetId(), IntAttrE);
871  fprintf(OutF, " eai[%d]", IntAttrE.Len());
872  for (int i = 0; i < IntAttrE.Len(); i++) {
873  fprintf(OutF, " %*i", EdgePlaces, IntAttrE[i]());
874  }
875  TStrV StrAttrE;
876  StrAttrValueEI(EdgeI.GetId(), StrAttrE);
877  fprintf(OutF, " eas[%d]", StrAttrE.Len());
878  for (int i = 0; i < StrAttrE.Len(); i++) {
879  fprintf(OutF, " %*s", EdgePlaces, StrAttrE[i]());
880  }
881  TFltV FltAttrE;
882  FltAttrValueEI(EdgeI.GetId(), FltAttrE);
883  fprintf(OutF, " eaf[%d]", FltAttrE.Len());
884  for (int i = 0; i < FltAttrE.Len(); i++) {
885  fprintf(OutF, " %*f", EdgePlaces, FltAttrE[i]());
886  }
887  fprintf(OutF, "\n");
888  }
889  //fprintf(OutF, "\n");
890 }
int GetNodes() const
Returns the number of nodes in the network.
Definition: network.h:2276
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
void StrAttrValueNI(const TInt &NId, TStrV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:2425
void IntAttrValueEI(const TInt &EId, TIntV &Values) const
Returns a vector of attr values for edge EId.
Definition: network.h:2450
void StrAttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:2470
void FltAttrValueEI(const TInt &EId, TFltV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:2478
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the graph.
Definition: network.h:2603
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the graph.
Definition: network.h:2605
void FltAttrValueNI(const TInt &NId, TFltV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:2433
void IntAttrValueNI(const TInt &NId, TIntV &Values) const
Returns a vector of attr values for node NId.
Definition: network.h:2405
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
Definition: network.h:2302
int GetEdges() const
Returns the number of edges in the graph.
Definition: network.h:2576
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
Definition: network.h:2300
bool TNEANet::EdgeAttrIsDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Returns true if EId attr deleted for current edge attr iterator.

Definition at line 398 of file network.cpp.

398  {
399  bool IntDel = EdgeAttrIsIntDeleted(EId, EdgeHI);
400  bool IntVDel = EdgeAttrIsIntVDeleted(EId, EdgeHI);
401  bool StrDel = EdgeAttrIsStrDeleted(EId, EdgeHI);
402  bool FltDel = EdgeAttrIsFltDeleted(EId, EdgeHI);
403  return IntDel || StrDel || FltDel || IntVDel;
404 }
bool EdgeAttrIsFltDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge flt attr iterator.
Definition: network.cpp:424
bool EdgeAttrIsIntDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge int attr iterator.
Definition: network.cpp:406
bool EdgeAttrIsIntVDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge int vector attr iterator.
Definition: network.cpp:412
bool EdgeAttrIsStrDeleted(const int &EId, const TStrIntPrH::TIter &EdgeHI) const
Returns true if EId attr deleted for current edge str attr iterator.
Definition: network.cpp:418
bool TNEANet::EdgeAttrIsFltDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Returns true if EId attr deleted for current edge flt attr iterator.

Definition at line 424 of file network.cpp.

424  {
425  return (EdgeHI.GetDat().Val1 == FltType &&
426  GetFltAttrDefaultE(EdgeHI.GetKey()) == this->VecOfFltVecsE.GetVal(
427  this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EdgeH.GetKeyId(EId)));
428 }
const TKey & GetKey() const
Definition: hash.h:80
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
TVec< TFltV > VecOfFltVecsE
Definition: network.h:2040
const TDat & GetDat() const
Definition: hash.h:81
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Gets Flt edge attribute val. If not a proper attr, return default.
Definition: network.h:2023
bool TNEANet::EdgeAttrIsIntDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Returns true if EId attr deleted for current edge int attr iterator.

Definition at line 406 of file network.cpp.

406  {
407  return (EdgeHI.GetDat().Val1 == IntType &&
408  GetIntAttrDefaultE(EdgeHI.GetKey()) == this->VecOfIntVecsE.GetVal(
409  this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EdgeH.GetKeyId(EId)));
410 }
TInt GetIntAttrDefaultE(const TStr &attribute) const
Gets Int edge attribute val. If not a proper attr, return default.
Definition: network.h:2019
TVec< TIntV > VecOfIntVecsE
Definition: network.h:2038
const TKey & GetKey() const
Definition: hash.h:80
THash< TInt, TEdge > EdgeH
Definition: network.h:2029
const TVal & GetVal(const TSizeTy &ValN) const
Returns a reference to the element at position ValN in the vector.
Definition: ds.h:649
const TDat & GetDat() const
Definition: hash.h:81
int GetKeyId(const TKey &Key) const
Definition: hash.h:466
bool TNEANet::EdgeAttrIsIntVDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Returns true if EId attr deleted for current edge int vector attr iterator.

Definition at line 412 of file network.cpp.

412  {
413  return (EdgeHI.