SNAP Library 2.1, User Reference  2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TNEANet Class Reference

TODO TNEANet describe time complexity for basic operations. More...

#include <network.h>

List of all members.

Classes

class  TAFltI
 NodeEdge Attr iterator. Iterate through all node for one attr value. More...
class  TAIntI
 Node/Edge Attr iterator. Iterate through all node for one attr value. More...
class  TAStrI
 Node/Edge Attr iterator. Iterate through all node for one attr value. 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.
 TNEANet (const TNEANet &Graph)
 TNEANet (TSIn &SIn)
 Constructor for loading the graph from a (binary) stream SIn.
void Save (TSOut &SOut) const
 Saves the graph to a (binary) stream SOut.
bool HasFlag (const TGraphFlag &Flag) const
 Allows for run-time checking the type of the graph (see the TGraphFlag for flags).
TNEANetoperator= (const TNEANet &Graph)
int GetNodes () const
 Returns the number of nodes in the graph.
int AddNode (int NId=-1)
 Adds a node of ID NId to the graph.
int AddNode (const TNodeI &NodeId)
 Adds a node of ID NodeI.GetId() to the graph.
void DelNode (const int &NId)
 Deletes node of ID NId from the graph.
void DelNode (const TNode &NodeI)
 Deletes node of ID NodeI.GetId() from the graph.
bool IsNode (const int &NId) const
 Tests whether ID NId is a node.
TNodeI BegNI () const
 Returns an iterator referring to the first node in the graph.
TNodeI EndNI () const
 Returns an iterator referring to the past-the-end node in the graph.
TNodeI GetNI (const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph.
TAIntI BegNAIntI (const TStr &attr) const
 Returns an iterator referring to the first node's int attribute.
TAIntI EndNAIntI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute.
TAIntI GetNAIntI (const TStr &attr, const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph.
TAStrI BegNAStrI (const TStr &attr) const
 Returns an iterator referring to the first node's str attribute.
TAStrI EndNAStrI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute.
TAStrI GetNAStrI (const TStr &attr, const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph.
TAFltI BegNAFltI (const TStr &attr) const
 Returns an iterator referring to the first node's flt attribute.
TAFltI EndNAFltI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute.
TAFltI GetNAFltI (const TStr &attr, const int &NId) const
 Returns an iterator referring to the node of ID NId in the graph.
void AttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of attr names for node NId.
void AttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
void AttrValueNI (const TInt &NId, TStrV &Values) const
 Returns a vector of attr avlues for node NId.
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.
void IntAttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
void IntAttrValueNI (const TInt &NId, TIntV &Values) const
 Returns a vector of attr avlues for node NId.
void IntAttrValueNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TIntV &Values) const
void StrAttrNameNI (const TInt &NId, TStrV &Names) const
 Returns a vector of str attr names for node NId.
void StrAttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
void StrAttrValueNI (const TInt &NId, TStrV &Values) const
 Returns a vector of attr avlues for node NId.
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.
void FltAttrNameNI (const TInt &NId, TStrIntPrH::TIter NodeHI, TStrV &Names) const
void FltAttrValueNI (const TInt &NId, TFltV &Values) const
 Returns a vector of attr avlues for node NId.
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.
void AttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
void AttrValueEI (const TInt &EId, TStrV &Values) const
 Returns a vector of attr avlues for edge EId.
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.
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.
void IntAttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TIntV &Values) const
void StrAttrNameEI (const TInt &EId, TStrV &Names) const
 Returns a vector of str attr names for node NId.
void StrAttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
void StrAttrValueEI (const TInt &EId, TStrV &Values) const
 Returns a vector of attr avlues for node NId.
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.
void FltAttrNameEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TStrV &Names) const
void FltAttrValueEI (const TInt &EId, TFltV &Values) const
 Returns a vector of attr avlues for node NId.
void FltAttrValueEI (const TInt &EId, TStrIntPrH::TIter EdgeHI, TFltV &Values) const
TAIntI BegEAIntI (const TStr &attr) const
 Returns an iterator referring to the first node's int attribute.
TAIntI EndEAIntI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute.
TAIntI GetEAIntI (const TStr &attr, const int &EId) const
 Returns an iterator referring to the node of ID EId in the graph.
TAStrI BegEAStrI (const TStr &attr) const
 Returns an iterator referring to the first node's str attribute.
TAStrI EndEAStrI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute.
TAStrI GetEAStrI (const TStr &attr, const int &EId) const
 Returns an iterator referring to the node of ID EId in the graph.
TAFltI BegEAFltI (const TStr &attr) const
 Returns an iterator referring to the first node's flt attribute.
TAFltI EndEAFltI (const TStr &attr) const
 Returns an iterator referring to the past-the-end node's attribute.
TAFltI GetEAFltI (const TStr &attr, const int &EId) const
 Returns an iterator referring to the node of ID EId in the graph.
int GetMxNId () const
 Returns the maximum id of a any node in the graph.
int GetEdges () const
 Returns the number of edges in the graph.
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.
int AddEdge (const TEdgeI &EdgeI)
 Adds an edge between EdgeI.GetSrcNId() and EdgeI.GetDstNId() to the graph.
void DelEdge (const int &EId)
 Deletes an edge with edge ID EId from the graph.
void DelEdge (const int &SrcNId, const int &DstNId, const bool &IsDir=true)
 Deletes all edges between node IDs SrcNId and DstNId from the graph.
bool IsEdge (const int &EId) const
 Tests whether an edge with edge ID EId exists in the graph.
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.
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.
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.
TEdgeI BegEI () const
 Returns an iterator referring to the first edge in the graph.
TEdgeI EndEI () const
 Returns an iterator referring to the past-the-end edge in the graph.
TEdgeI GetEI (const int &EId) const
TEdgeI GetEI (const int &SrcNId, const int &DstNId) const
int GetRndNId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random node in the graph.
TNodeI GetRndNI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random node in the graph.
int GetRndEId (TRnd &Rnd=TInt::Rnd)
 Returns an ID of a random edge in the graph.
TEdgeI GetRndEI (TRnd &Rnd=TInt::Rnd)
 Returns an interator referring to a random edge in the graph.
void GetNIdV (TIntV &NIdV) const
 Gets a vector IDs of all nodes in the graph.
void GetEIdV (TIntV &EIdV) const
 Gets a vector IDs of all edges in the graph.
bool Empty () const
 Tests whether the graph is empty (has zero nodes).
void Clr ()
 Deletes all nodes and edges from the graph.
void Reserve (const int &Nodes, const int &Edges)
 Reserves memory for a graph of Nodes nodes and Edges edges.
void Defrag (const bool &OnlyNodeLinks=false)
 Defragments the graph.
bool IsOk (const bool &ThrowExcept=true) const
 Checks the graph data structure for internal consistency.
void Dump (FILE *OutF=stdout) const
 Print the graph in a human readable form to an output stream OutF.
int AddIntAttrDatN (const TNodeI &NodeId, const TInt &value, const TStr &attr)
 Attribute based add function for attr to Int value.
int AddIntAttrDatN (const int &NId, const TInt &value, const TStr &attr)
int AddStrAttrDatN (const TNodeI &NodeId, const TStr &value, const TStr &attr)
 Attribute based add function for attr to Str value.
int AddStrAttrDatN (const int &NId, const TStr &value, const TStr &attr)
int AddFltAttrDatN (const TNodeI &NodeId, const TFlt &value, const TStr &attr)
 Attribute based add function for attr to Flt value.
int AddFltAttrDatN (const int &NId, const TFlt &value, const TStr &attr)
int AddIntAttrDatE (const TEdgeI &EdgeId, const TInt &value, const TStr &attr)
 Attribute based add function for attr to Int value.
int AddIntAttrDatE (const int &EId, const TInt &value, const TStr &attr)
int AddStrAttrDatE (const TEdgeI &EdgeId, const TStr &value, const TStr &attr)
 Attribute based add function for attr to Str value.
int AddStrAttrDatE (const int &EId, const TStr &value, const TStr &attr)
int AddFltAttrDatE (const TEdgeI &EdgeId, const TFlt &value, const TStr &attr)
 Attribute based add function for attr to Flt value.
int AddFltAttrDatE (const int &EId, const TFlt &value, const TStr &attr)
TInt GetIntAttrDatN (const TNodeI &NodeId, const TStr &attr)
 Gets the value of int attr from the node attr value vector.
TInt GetIntAttrDatN (const int &NId, const TStr &attr)
TStr GetStrAttrDatN (const TNodeI &NodeId, const TStr &attr)
 Gets the value of str attr from the node attr value vector.
TStr GetStrAttrDatN (const int &NId, const TStr &attr)
TFlt GetFltAttrDatN (const TNodeI &NodeId, const TStr &attr)
 Gets the value of flt attr from the node attr value vector.
TFlt GetFltAttrDatN (const int &NId, const TStr &attr)
TInt GetIntAttrDatE (const TEdgeI &EdgeId, const TStr &attr)
 Gets the value of int attr from the edge attr value vector.
TInt GetIntAttrDatE (const int &EId, const TStr &attr)
TStr GetStrAttrDatE (const TEdgeI &EdgeId, const TStr &attr)
 Gets the value of str attr from the edge attr value vector.
TStr GetStrAttrDatE (const int &EId, const TStr &attr)
TFlt GetFltAttrDatE (const TEdgeI &EdgeId, const TStr &attr)
 Gets the value of flt attr from the edge attr value vector.
TFlt GetFltAttrDatE (const int &EId, const TStr &attr)
int DelAttrDatN (const TNodeI &NodeId, const TStr &attr)
 Deletes the node attribute for NodeId.
int DelAttrDatN (const int &NId, const TStr &attr)
int DelAttrDatE (const TEdgeI &EdgeId, const TStr &attr)
 Deletes the edge attribute for NodeId.
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.
int AddStrAttrN (const TStr &attr, TStr defaultValue=TStr::GetNullStr())
 Adds a new Str node attribute to the hashmap.
int AddFltAttrN (const TStr &attr, TFlt defaultValue=TFlt::Mn)
 Adds a new Flt node attribute to the hashmap.
int AddIntAttrE (const TStr &attr, TInt defaultValue=TInt::Mn)
 Adds a new Int edge attribute to the hashmap.
int AddStrAttrE (const TStr &attr, TStr defaultValue=TStr::GetNullStr())
 Adds a new Str edge attribute to the hashmap.
int AddFltAttrE (const TStr &attr, TFlt defaultValue=TFlt::Mn)
 Adds a new Flt edge attribute to the hashmap.
int DelAttrN (const TStr &attr)
 Removes all the values for node attr.
int DelAttrE (const TStr &attr)
 Removes all the values for edge attr.
bool NodeAttrIsDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
bool NodeAttrIsIntDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
bool NodeAttrIsStrDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
bool NodeAttrIsFltDeleted (const int &NId, const TStrIntPrH::TIter &NodeHI) const
bool EdgeAttrIsDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
bool EdgeAttrIsIntDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
bool EdgeAttrIsStrDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
bool EdgeAttrIsFltDeleted (const int &EId, const TStrIntPrH::TIter &EdgeHI) const
TStr GetNodeAttrValue (const int &NId, const TStrIntPrH::TIter &NodeHI) const
TStr GetEdgeAttrValue (const int &EId, const TStrIntPrH::TIter &EdgeHI) const

Static Public Member Functions

static PNEANet New ()
 Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New().
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.
static PNEANet Load (TSIn &SIn)
 Static constructor that loads the graph from a stream SIn and returns a pointer to it.
static PNEGraph GetSmallGraph ()
 TODO implement and document TNEANet::GetSmallGraph()

Private Types

enum  { IntType, StrType, FltType }

Private Member Functions

TNodeGetNode (const int &NId)
const TNodeGetNode (const int &NId) const
TEdgeGetEdge (const int &EId)
const TEdgeGetEdge (const int &EId) const
TInt GetIntAttrDefaultN (const TStr &attribute) const
 Get Int node attribute val. If not a proper attr, return default.
TStr GetStrAttrDefaultN (const TStr &attribute) const
 Get Str node attribute val. If not a proper attr, return default.
TFlt GetFltAttrDefaultN (const TStr &attribute) const
 Get Flt node attribute val. If not a proper attr, return default.
TInt GetIntAttrDefaultE (const TStr &attribute) const
 Get Int edge attribute val. If not a proper attr, return default.
TStr GetStrAttrDefaultE (const TStr &attribute) const
 Get Str edge attribute val. If not a proper attr, return default.
TFlt GetFltAttrDefaultE (const TStr &attribute) const
 Get Flt edge attribute val. If not a proper attr, return default.

Private Attributes

TCRef CRef
TInt MxNId
TInt MxEId
THash< TInt, TNodeNodeH
THash< TInt, TEdgeEdgeH
TStrIntPrH KeyToIndexTypeN
 KeyToIndexType[N|E]: Key->(Type,Index).
TStrIntPrH KeyToIndexTypeE
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

Friends

class TPt< TNEANet >

Detailed Description

TODO TNEANet describe time complexity for basic operations.

Definition at line 1575 of file network.h.


Member Typedef Documentation

Definition at line 1578 of file network.h.

Definition at line 1577 of file network.h.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
IntType 
StrType 
FltType 

Definition at line 1828 of file network.h.


Constructor & Destructor Documentation

TNEANet::TNEANet ( const int &  Nodes,
const int &  Edges 
) [inline, explicit]

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

Definition at line 1836 of file network.h.

TNEANet::TNEANet ( TSIn SIn) [inline]

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

Definition at line 1848 of file network.h.


Member Function Documentation

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

                                                                  {
  int i;

  if (EId == -1) { EId = MxEId;  MxEId++; }
  else { MxEId = TMath::Mx(EId+1, MxEId()); }
  IAssertR(!IsEdge(EId), TStr::Fmt("EdgeId %d already exists", EId));
  IAssertR(IsNode(SrcNId) && IsNode(DstNId), TStr::Fmt("%d or %d not a node.", SrcNId, DstNId).CStr());
  EdgeH.AddDat(EId, TEdge(EId, SrcNId, DstNId));
  GetNode(SrcNId).OutEIdV.AddSorted(EId);
  GetNode(DstNId).InEIdV.AddSorted(EId);

  // update attribute columns
  for (i = 0; i < VecOfIntVecsE.Len(); i++) {
    TVec<TInt>& IntVec = VecOfIntVecsE[i];
    IntVec.Ins(EdgeH.GetKeyId(EId), TInt::Mn);
  }
  TVec<TStr> DefIntVec = TVec<TStr>();
  IntDefaultsE.GetKeyV(DefIntVec);
  for (i = 0; i < DefIntVec.Len(); i++) {
    TStr attr = DefIntVec[i];
    TVec<TInt>& IntVec = VecOfIntVecsE[KeyToIndexTypeE.GetDat(DefIntVec[i]).Val2];
    IntVec[EdgeH.GetKeyId(EId)] = GetIntAttrDefaultE(attr);
  }

  for (i = 0; i < VecOfStrVecsE.Len(); i++) {
    TVec<TStr>& StrVec = VecOfStrVecsE[i];
    StrVec.Ins(EdgeH.GetKeyId(EId), TStr::GetNullStr());
  }
  TVec<TStr> DefStrVec = TVec<TStr>();
  IntDefaultsE.GetKeyV(DefStrVec);
  for (i = 0; i < DefStrVec.Len(); i++) {
    TStr attr = DefStrVec[i];
    TVec<TStr>& StrVec = VecOfStrVecsE[KeyToIndexTypeE.GetDat(DefStrVec[i]).Val2];
    StrVec[EdgeH.GetKeyId(EId)] = GetStrAttrDefaultE(attr);
  }

  for (i = 0; i < VecOfFltVecsE.Len(); i++) {
    TVec<TFlt>& FltVec = VecOfFltVecsE[i];
    FltVec.Ins(EdgeH.GetKeyId(EId), TFlt::Mn);
  }
  TVec<TStr> DefFltVec = TVec<TStr>();
  FltDefaultsE.GetKeyV(DefFltVec);
  for (i = 0; i < DefFltVec.Len(); i++) {
    TStr attr = DefFltVec[i];
    TVec<TFlt>& FltVec = VecOfFltVecsE[KeyToIndexTypeE.GetDat(DefFltVec[i]).Val2];
    FltVec[NodeH.GetKeyId(EId)] = GetFltAttrDefaultE(attr);
  }
  return EId;
}
int TNEANet::AddEdge ( const TEdgeI EdgeI) [inline]

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

Definition at line 2044 of file network.h.

{ return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId(), EdgeI.GetId()); }
int TNEANet::AddFltAttrDatE ( const TEdgeI EdgeId,
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 2138 of file network.h.

{ return AddFltAttrDatE(EdgeId.GetId(), value, attr); }
int TNEANet::AddFltAttrDatE ( const int &  EId,
const TFlt value,
const TStr attr 
)

Definition at line 730 of file network.cpp.

                                                                               {
  int i;
  TInt CurrLen;

  if (!IsEdge(EId)) {
    //AddEdge(EId);
     return -1;
  }
  if (KeyToIndexTypeE.IsKey(attr)) {
    TVec<TFlt>& NewVec = VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2];
    NewVec[EdgeH.GetKeyId(EId)] = value;
  } else {
    CurrLen = VecOfFltVecsE.Len();
    KeyToIndexTypeE.AddDat(attr, TIntPr(FltType, CurrLen));
    TVec<TFlt> NewVec = TVec<TFlt>();
    for (i = 0; i < MxEId; i++) {
      NewVec.Ins(i, GetFltAttrDefaultE(attr));
    }
    NewVec[EdgeH.GetKeyId(EId)] = value;
    VecOfFltVecsE.Add(NewVec);
  }
  return 0;
} 
int TNEANet::AddFltAttrDatN ( const TNodeI NodeId,
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 2122 of file network.h.

{ return AddFltAttrDatN(NodeId.GetId(), value, attr); }
int TNEANet::AddFltAttrDatN ( const int &  NId,
const TFlt value,
const TStr attr 
)

Definition at line 660 of file network.cpp.

                                                                               {
  int i;
  TInt CurrLen;

  if (!IsNode(NId)) {
    // AddNode(NId);
    return -1;
  }
  if (KeyToIndexTypeN.IsKey(attr)) {
    TVec<TFlt>& NewVec = VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2];
    NewVec[NodeH.GetKeyId(NId)] = value;
  } else {
    CurrLen = VecOfFltVecsN.Len();
    KeyToIndexTypeN.AddDat(attr, TIntPr(FltType, CurrLen));
    TVec<TFlt> NewVec = TVec<TFlt>();
    for (i = 0; i < MxNId; i++) {
      NewVec.Ins(i, GetFltAttrDefaultN(attr));
    }
    NewVec[NodeH.GetKeyId(NId)] = value;
    VecOfFltVecsN.Add(NewVec);
  }
  return 0;
} 
int TNEANet::AddFltAttrE ( const TStr attr,
TFlt  defaultValue = TFlt::Mn 
)

Adds a new Flt edge attribute to the hashmap.

Definition at line 904 of file network.cpp.

                                                            {
  int i;
  TInt CurrLen;
  TVec<TFlt> NewVec;
  CurrLen = VecOfStrVecsE.Len();
  KeyToIndexTypeE.AddDat(attr, TIntPr(FltType, CurrLen));
  NewVec = TVec<TFlt>();
  for (i = 0; i < MxEId; i++) {
    NewVec.Ins(i, defaultValue);
  }
  VecOfFltVecsE.Add(NewVec);
  if (!FltDefaultsE.IsKey(attr)) {
    FltDefaultsE.AddDat(attr, defaultValue);
  } else {
    return -1;
  }
  return 0;
}
int TNEANet::AddFltAttrN ( const TStr attr,
TFlt  defaultValue = TFlt::Mn 
)

Adds a new Flt node attribute to the hashmap.

Definition at line 845 of file network.cpp.

                                                            {
  // TODO(nkhadke): add error checking
  int i;
  TInt CurrLen;
  TVec<TFlt> NewVec;
  CurrLen = VecOfStrVecsN.Len();
  KeyToIndexTypeN.AddDat(attr, TIntPr(FltType, CurrLen));
  NewVec = TVec<TFlt>();
  for (i = 0; i < MxNId; i++) {
    NewVec.Ins(i, defaultValue);
  }
  VecOfFltVecsN.Add(NewVec);
  if (!FltDefaultsN.IsKey(attr)) {
    FltDefaultsN.AddDat(attr, defaultValue);
  } else {
    return -1;
  }
  return 0;
}
int TNEANet::AddIntAttrDatE ( const TEdgeI EdgeId,
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 2128 of file network.h.

{ return AddIntAttrDatE(EdgeId.GetId(), value, attr); }
int TNEANet::AddIntAttrDatE ( const int &  EId,
const TInt value,
const TStr attr 
)

Definition at line 684 of file network.cpp.

                                                                               {
  int i;
  TInt CurrLen;
  if (!IsEdge(EId)) {
    //AddEdge(EId);
     return -1;
  }
  if (KeyToIndexTypeE.IsKey(attr)) {
    TVec<TInt>& NewVec = VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2];
    NewVec[EdgeH.GetKeyId(EId)] = value;
  } else {
    CurrLen = VecOfIntVecsE.Len();
    KeyToIndexTypeE.AddDat(attr, TIntPr(IntType, CurrLen));
    TVec<TInt> NewVec = TVec<TInt>();
    for (i = 0; i < MxEId; i++) {
      NewVec.Ins(i, GetIntAttrDefaultE(attr));
    }
    NewVec[EdgeH.GetKeyId(EId)] = value;
    VecOfIntVecsE.Add(NewVec);
  }
  return 0;
} 
int TNEANet::AddIntAttrDatN ( const TNodeI NodeId,
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 2112 of file network.h.

{ return AddIntAttrDatN(NodeId.GetId(), value, attr); }
int TNEANet::AddIntAttrDatN ( const int &  NId,
const TInt value,
const TStr attr 
)

Definition at line 614 of file network.cpp.

                                                                               {
  int i;
  TInt CurrLen;
  if (!IsNode(NId)) {
    // AddNode(NId);
    return -1;
  }
  if (KeyToIndexTypeN.IsKey(attr)) {
    TVec<TInt>& NewVec = VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2];
    NewVec[NodeH.GetKeyId(NId)] = value;
  } else {
    CurrLen = VecOfIntVecsN.Len();
    KeyToIndexTypeN.AddDat(attr, TIntPr(IntType, CurrLen));
    TVec<TInt> NewVec = TVec<TInt>();
    for (i = 0; i < MxNId; i++) {
      NewVec.Ins(i, GetIntAttrDefaultN(attr));
    }
    NewVec[NodeH.GetKeyId(NId)] = value;
    VecOfIntVecsN.Add(NewVec);
  }
  return 0;
} 
int TNEANet::AddIntAttrE ( const TStr attr,
TInt  defaultValue = TInt::Mn 
)

Adds a new Int edge attribute to the hashmap.

Definition at line 865 of file network.cpp.

                                                           {
  // TODO(nkhadke): add error checking
  int i;
  TInt CurrLen;
  TVec<TInt> NewVec;
  CurrLen = VecOfIntVecsE.Len();
  KeyToIndexTypeE.AddDat(attr, TIntPr(IntType, CurrLen));
  NewVec = TVec<TInt>();
  for (i = 0; i < MxEId; i++) {
    NewVec.Ins(i, defaultValue);
  }
  VecOfIntVecsE.Add(NewVec);
  if (!IntDefaultsE.IsKey(attr)) {
    IntDefaultsE.AddDat(attr, defaultValue);
  } else {
    return -1;
  }
  return 0;
}
int TNEANet::AddIntAttrN ( const TStr attr,
TInt  defaultValue = TInt::Mn 
)

Adds a new Int node attribute to the hashmap.

Definition at line 807 of file network.cpp.

                                                           {
  int i;
  TInt CurrLen;
  TVec<TInt> NewVec;
  CurrLen = VecOfIntVecsN.Len();
  KeyToIndexTypeN.AddDat(attr, TIntPr(IntType, CurrLen));
  NewVec = TVec<TInt>();
  for (i = 0; i < MxNId; i++) {
    NewVec.Ins(i, defaultValue);
  }
  VecOfIntVecsN.Add(NewVec);
  if (!IntDefaultsN.IsKey(attr)) {
    IntDefaultsN.AddDat(attr, defaultValue);
  } else {
    return -1;
  }
  return 0;
}
int TNEANet::AddNode ( int  NId = -1)

Adds a node of ID NId to the graph.

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

Definition at line 269 of file network.cpp.

                            {
  int i;
  if (NId == -1) {
    NId = MxNId;  MxNId++;
  } else {
    IAssertR(!IsNode(NId), TStr::Fmt("NodeId %d already exists", NId));
    MxNId = TMath::Mx(NId+1, MxNId());
  }
  // update attribute columns
  NodeH.AddDat(NId, TNode(NId));
  for (i = 0; i < VecOfIntVecsN.Len(); i++) {
    TVec<TInt>& IntVec = VecOfIntVecsN[i];
    IntVec.Ins(NodeH.GetKeyId(NId), TInt::Mn);
  }
  TVec<TStr> DefIntVec = TVec<TStr>();
  IntDefaultsN.GetKeyV(DefIntVec);
  for (i = 0; i < DefIntVec.Len(); i++) {
    TStr attr = DefIntVec[i];
    TVec<TInt>& IntVec = VecOfIntVecsN[KeyToIndexTypeN.GetDat(DefIntVec[i]).Val2];
    IntVec[NodeH.GetKeyId(NId)] = GetIntAttrDefaultN(attr);
  }
  for (i = 0; i < VecOfStrVecsN.Len(); i++) {
    TVec<TStr>& StrVec = VecOfStrVecsN[i];
    StrVec.Ins(NodeH.GetKeyId(NId), TStr::GetNullStr());
  }
  TVec<TStr> DefStrVec = TVec<TStr>();
  IntDefaultsN.GetKeyV(DefStrVec);
  for (i = 0; i < DefStrVec.Len(); i++) {
    TStr attr = DefStrVec[i];
    TVec<TStr>& StrVec = VecOfStrVecsN[KeyToIndexTypeN.GetDat(DefStrVec[i]).Val2];
    StrVec[NodeH.GetKeyId(NId)] = GetStrAttrDefaultN(attr);
  }
  for (i = 0; i < VecOfFltVecsN.Len(); i++) {
    TVec<TFlt>& FltVec = VecOfFltVecsN[i];
    FltVec.Ins(NodeH.GetKeyId(NId), TFlt::Mn);
  }
  TVec<TStr> DefFltVec = TVec<TStr>();
  FltDefaultsN.GetKeyV(DefFltVec);
  for (i = 0; i < DefFltVec.Len(); i++) {
    TStr attr = DefFltVec[i];
    TVec<TFlt>& FltVec = VecOfFltVecsN[KeyToIndexTypeN.GetDat(DefFltVec[i]).Val2];
    FltVec[NodeH.GetKeyId(NId)] = GetFltAttrDefaultN(attr);
  }
  return NId;
}
int TNEANet::AddNode ( const TNodeI NodeId) [inline]

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

Definition at line 1886 of file network.h.

{ return AddNode(NodeId.GetId()); }
int TNEANet::AddStrAttrDatE ( const TEdgeI EdgeId,
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 2133 of file network.h.

{ return AddStrAttrDatE(EdgeId.GetId(), value, attr); }
int TNEANet::AddStrAttrDatE ( const int &  EId,
const TStr value,
const TStr attr 
)

Definition at line 707 of file network.cpp.

                                                                               {
  int i;
  TInt CurrLen;
  if (!IsEdge(EId)) {
    //AddEdge(EId);
     return -1;
  }
  if (KeyToIndexTypeE.IsKey(attr)) {
    TVec<TStr>& NewVec = VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2];
    NewVec[EdgeH.GetKeyId(EId)] = value;
  } else {
    CurrLen = VecOfStrVecsE.Len();
    KeyToIndexTypeE.AddDat(attr, TIntPr(StrType, CurrLen));
    TVec<TStr> NewVec = TVec<TStr>();
    for (i = 0; i < MxEId; i++) {
      NewVec.Ins(i, GetStrAttrDefaultE(attr));
    }
    NewVec[EdgeH.GetKeyId(EId)] = value;
    VecOfStrVecsE.Add(NewVec);
  }
  return 0;
} 
int TNEANet::AddStrAttrDatN ( const TNodeI NodeId,
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 2117 of file network.h.

{ return AddStrAttrDatN(NodeId.GetId(), value, attr); }
int TNEANet::AddStrAttrDatN ( const int &  NId,
const TStr value,
const TStr attr 
)

Definition at line 637 of file network.cpp.

                                                                               {
  int i;
  TInt CurrLen;
  if (!IsNode(NId)) {
    // AddNode(NId);
    return -1;
  }
  if (KeyToIndexTypeN.IsKey(attr)) {
    TVec<TStr>& NewVec = VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2];
    NewVec[NodeH.GetKeyId(NId)] = value;
  } else {
    CurrLen = VecOfStrVecsN.Len();
    KeyToIndexTypeN.AddDat(attr, TIntPr(StrType, CurrLen));
    TVec<TStr> NewVec = TVec<TStr>();
    for (i = 0; i < MxNId; i++) {
        NewVec.Ins(i, GetStrAttrDefaultN(attr));
    }
    NewVec[NodeH.GetKeyId(NId)] = value;
    VecOfStrVecsN.Add(NewVec);
  }
  return 0;
} 
int TNEANet::AddStrAttrE ( const TStr attr,
TStr  defaultValue = TStr::GetNullStr() 
)

Adds a new Str edge attribute to the hashmap.

Definition at line 885 of file network.cpp.

                                                            {
  int i;
  TInt CurrLen;
  TVec<TStr> NewVec;
  CurrLen = VecOfStrVecsE.Len();
  KeyToIndexTypeE.AddDat(attr, TIntPr(StrType, CurrLen));
  NewVec = TVec<TStr>();
  for (i = 0; i < MxEId; i++) {
    NewVec.Ins(i, defaultValue);
  }
  VecOfStrVecsE.Add(NewVec);
  if (!StrDefaultsE.IsKey(attr)) {
    StrDefaultsE.AddDat(attr, defaultValue);
  } else {
    return -1;
  }
  return 0;
}
int TNEANet::AddStrAttrN ( const TStr attr,
TStr  defaultValue = TStr::GetNullStr() 
)

Adds a new Str node attribute to the hashmap.

Definition at line 826 of file network.cpp.

                                                            {
  int i;
  TInt CurrLen;
  TVec<TStr> NewVec;
  CurrLen = VecOfStrVecsN.Len();
  KeyToIndexTypeN.AddDat(attr, TIntPr(StrType, CurrLen));
  NewVec = TVec<TStr>();
  for (i = 0; i < MxNId; i++) {
    NewVec.Ins(i, defaultValue);
  }
  VecOfStrVecsN.Add(NewVec);
  if (!StrDefaultsN.IsKey(attr)) {
    StrDefaultsN.AddDat(attr, defaultValue);
  } else {
    return -1;
  }
  return 0;
}
void TNEANet::AttrNameEI ( const TInt EId,
TStrV Names 
) const [inline]

Returns a vector of attr names for edge EId.

Definition at line 1964 of file network.h.

                                                       {
    AttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
void TNEANet::AttrNameEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Names 
) const

Definition at line 147 of file network.cpp.

                                                                                    {
  Names = TVec<TStr>();
  while (!EdgeHI.IsEnd()) {
    if (!EdgeAttrIsDeleted(EId, EdgeHI)) {
      Names.Add(EdgeHI.GetKey());
    }
    EdgeHI++;
  }  
}
void TNEANet::AttrNameNI ( const TInt NId,
TStrV Names 
) const [inline]

Returns a vector of attr names for node NId.

Definition at line 1931 of file network.h.

                                                       {
    AttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
void TNEANet::AttrNameNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Names 
) const

Definition at line 25 of file network.cpp.

                                                                                    {
  Names = TVec<TStr>();
  while (!NodeHI.IsEnd()) {
    if (!NodeAttrIsDeleted(NId, NodeHI)) {
      Names.Add(NodeHI.GetKey());
    }
    NodeHI++;
  }  
}
void TNEANet::AttrValueEI ( const TInt EId,
TStrV Values 
) const [inline]

Returns a vector of attr avlues for edge EId.

Definition at line 1968 of file network.h.

                                                         {
    AttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
void TNEANet::AttrValueEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Values 
) const

Definition at line 157 of file network.cpp.

                                                                                      {
  Values = TVec<TStr>();
  while (!EdgeHI.IsEnd()) {
    if (!EdgeAttrIsDeleted(EId, EdgeHI)) {
      Values.Add(GetNodeAttrValue(EId, EdgeHI));
    }
    EdgeHI++;
  }  
}
void TNEANet::AttrValueNI ( const TInt NId,
TStrV Values 
) const [inline]

Returns a vector of attr avlues for node NId.

Definition at line 1935 of file network.h.

                                                         {
    AttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
void TNEANet::AttrValueNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Values 
) const

Definition at line 35 of file network.cpp.

                                                                                       {
  Values = TVec<TStr>();
  while (!NodeHI.IsEnd()) {
    if (!NodeAttrIsDeleted(NId, NodeHI)) {
      Values.Add(GetNodeAttrValue(NId, NodeHI));
    }
    NodeHI++;
  }
}
TAFltI TNEANet::BegEAFltI ( const TStr attr) const [inline]

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

Definition at line 2020 of file network.h.

                                           {
    return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, true, this);
  }
TAIntI TNEANet::BegEAIntI ( const TStr attr) const [inline]

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

Definition at line 1997 of file network.h.

                                           {
    return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, true, this);
  }
TAStrI TNEANet::BegEAStrI ( const TStr attr) const [inline]

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

Definition at line 2009 of file network.h.

                                           {
    return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, true, this);   }
TEdgeI TNEANet::BegEI ( ) const [inline]

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

Definition at line 2062 of file network.h.

{ return TEdgeI(EdgeH.BegI(), this); }
TAFltI TNEANet::BegNAFltI ( const TStr attr) const [inline]

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

Definition at line 1921 of file network.h.

                                           {
    return TAFltI(VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr, false, this); }
TAIntI TNEANet::BegNAIntI ( const TStr attr) const [inline]

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

Definition at line 1902 of file network.h.

                                           {
    return TAIntI(VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr, false, this); }
TAStrI TNEANet::BegNAStrI ( const TStr attr) const [inline]

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

Definition at line 1911 of file network.h.

                                           {

    return TAStrI(VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2].BegI(), attr, false, this); }
TNodeI TNEANet::BegNI ( ) const [inline]

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

Definition at line 1896 of file network.h.

{ return TNodeI(NodeH.BegI(), this); }
void TNEANet::Clr ( ) [inline]
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 495 of file network.cpp.

                                              {
  for (int kid = NodeH.FFirstKeyId(); NodeH.FNextKeyId(kid); ) {
    TNode& Node = NodeH[kid];
    Node.InEIdV.Pack();  Node.OutEIdV.Pack();
  }
  if (! OnlyNodeLinks && ! NodeH.IsKeyIdEqKeyN()) { NodeH.Defrag(); }
  if (! OnlyNodeLinks && ! EdgeH.IsKeyIdEqKeyN()) { EdgeH.Defrag(); }
}
int TNEANet::DelAttrDatE ( const TEdgeI EdgeId,
const TStr attr 
) [inline]

Deletes the edge attribute for NodeId.

Definition at line 2165 of file network.h.

{ return DelAttrDatE(EdgeId.GetId(), attr); } 
int TNEANet::DelAttrDatE ( const int &  EId,
const TStr attr 
)

Definition at line 792 of file network.cpp.

                                                         {
  // TODO(nkhadke): add error checking
  TInt vecType = KeyToIndexTypeE(attr).Val1;
  if (vecType == IntType) {
    VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2][EId] = GetIntAttrDefaultE(attr);
  } else if (vecType == StrType) {
    VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2][EId] = GetStrAttrDefaultE(attr);
  } else if (vecType == FltType) {
    VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2][EId] = GetFltAttrDefaultE(attr);
  } else {
    return -1;
  }
  return 0;
}
int TNEANet::DelAttrDatN ( const TNodeI NodeId,
const TStr attr 
) [inline]

Deletes the node attribute for NodeId.

Definition at line 2162 of file network.h.

{ return DelAttrDatN(NodeId.GetId(), attr); } 
int TNEANet::DelAttrDatN ( const int &  NId,
const TStr attr 
)

Definition at line 778 of file network.cpp.

                                                         {
  TInt vecType = KeyToIndexTypeN(attr).Val1;
  if (vecType == IntType) {
    VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2][NId] = GetIntAttrDefaultN(attr);
  } else if (vecType == StrType) {
    VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2][NId] = GetStrAttrDefaultN(attr);
  } else if (vecType == FltType) {
    VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2][NId] = GetFltAttrDefaultN(attr);
  } else {
    return -1;
  }
  return 0;
}
int TNEANet::DelAttrE ( const TStr attr)

Removes all the values for edge attr.

Definition at line 947 of file network.cpp.

                                      {
  TInt vecType = KeyToIndexTypeE(attr).Val1;
  if (vecType == IntType) {
    VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2] = TVec<TInt>();
    if (IntDefaultsE.IsKey(attr)) {
      IntDefaultsE.DelKey(attr);
    }
  } else if (vecType == StrType) {
    VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2] = TVec<TStr>();
    if (StrDefaultsE.IsKey(attr)) {
      StrDefaultsE.DelKey(attr);
    }  
  } else if (vecType == FltType) {
    VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2] = TVec<TFlt>();
    if (FltDefaultsE.IsKey(attr)) {
      FltDefaultsE.DelKey(attr);
    }
  } else {
    return -1;
  }
  KeyToIndexTypeE.DelKey(attr);
  return 0;
}
int TNEANet::DelAttrN ( const TStr attr)

Removes all the values for node attr.

Definition at line 923 of file network.cpp.

                                      {
  TInt vecType = KeyToIndexTypeN(attr).Val1;
  if (vecType == IntType) {
    VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2] = TVec<TInt>();
    if (IntDefaultsN.IsKey(attr)) {
      IntDefaultsN.DelKey(attr);
    }
  } else if (vecType == StrType) {
    VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2] = TVec<TStr>();  
    if (StrDefaultsN.IsKey(attr)) {
      StrDefaultsN.DelKey(attr);
    }
  } else if (vecType == FltType) {
    VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2] = TVec<TFlt>();
    if (FltDefaultsN.IsKey(attr)) {
      FltDefaultsN.DelKey(attr);
    }
  } else {
    return -1;
  }
  KeyToIndexTypeN.DelKey(attr);
  return 0;
}
void TNEANet::DelEdge ( const int &  EId)

Deletes an edge with edge ID EId from the graph.

Definition at line 425 of file network.cpp.

                                    {
  int i;

  IAssert(IsEdge(EId));
  const int SrcNId = GetEdge(EId).GetSrcNId();
  const int DstNId = GetEdge(EId).GetDstNId();
  GetNode(SrcNId).OutEIdV.DelIfIn(EId);
  GetNode(DstNId).InEIdV.DelIfIn(EId);
  EdgeH.DelKey(EId);

  for (i = 0; i < VecOfIntVecsE.Len(); i++) {
    TVec<TInt>& IntVec = VecOfIntVecsE[i];
    IntVec.Ins(EdgeH.GetKeyId(EId), TInt::Mn);
  }
  for (i = 0; i < VecOfStrVecsE.Len(); i++) {
    TVec<TStr>& StrVec = VecOfStrVecsE[i];
    StrVec.Ins(EdgeH.GetKeyId(EId), TStr::GetNullStr());
  }
  for (i = 0; i < VecOfFltVecsE.Len(); i++) {
    TVec<TFlt>& FltVec = VecOfFltVecsE[i];
    FltVec.Ins(EdgeH.GetKeyId(EId), TFlt::Mn);
  }
}
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 450 of file network.cpp.

                                                                             {
  int EId;
  IAssert(IsEdge(SrcNId, DstNId, EId, IsDir)); // there is at least one edge
  while (IsEdge(SrcNId, DstNId, EId, IsDir)) {
    GetNode(SrcNId).OutEIdV.DelIfIn(EId);
    GetNode(DstNId).InEIdV.DelIfIn(EId);
  }
  EdgeH.DelKey(EId);
}
void TNEANet::DelNode ( const int &  NId)

Deletes node of ID NId from the graph.

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

Definition at line 315 of file network.cpp.

                                    {
  int i;
  
  const TNode& Node = GetNode(NId);
  for (int out = 0; out < Node.GetOutDeg(); out++) {
    const int EId = Node.GetOutEId(out);
    const TEdge& Edge = GetEdge(EId);
    IAssert(Edge.GetSrcNId() == NId);
    GetNode(Edge.GetDstNId()).InEIdV.DelIfIn(EId);
    EdgeH.DelKey(EId);
    // Delete from Edge Attributes
    for (i = 0; i < VecOfIntVecsE.Len(); i++) {
      TVec<TInt>& IntVec = VecOfIntVecsE[i];
      IntVec.Ins(EdgeH.GetKeyId(EId), TInt::Mn);
    }
    for (i = 0; i < VecOfStrVecsE.Len(); i++) {
      TVec<TStr>& StrVec = VecOfStrVecsE[i];
      StrVec.Ins(EdgeH.GetKeyId(EId), TStr::GetNullStr());
    }
    for (i = 0; i < VecOfFltVecsE.Len(); i++) {
      TVec<TFlt>& FltVec = VecOfFltVecsE[i];
      FltVec.Ins(EdgeH.GetKeyId(EId), TFlt::Mn);
    }
  }
  for (int in = 0; in < Node.GetInDeg(); in++) {
    const int EId = Node.GetInEId(in);
    const TEdge& Edge = GetEdge(EId);
    IAssert(Edge.GetDstNId() == NId);
    GetNode(Edge.GetSrcNId()).OutEIdV.DelIfIn(EId);
    EdgeH.DelKey(EId);
    // Delete from Edge Attributes
    for (i = 0; i < VecOfIntVecsE.Len(); i++) {
      TVec<TInt>& IntVec = VecOfIntVecsE[i];
      IntVec.Ins(EdgeH.GetKeyId(EId), TInt::Mn);
    }
    for (i = 0; i < VecOfStrVecsE.Len(); i++) {
      TVec<TStr>& StrVec = VecOfStrVecsE[i];
      StrVec.Ins(EdgeH.GetKeyId(EId), TStr::GetNullStr());
    }
    for (i = 0; i < VecOfFltVecsE.Len(); i++) {
      TVec<TFlt>& FltVec = VecOfFltVecsE[i];
      FltVec.Ins(EdgeH.GetKeyId(EId), TFlt::Mn);
    }
  }

  for (i = 0; i < VecOfIntVecsN.Len(); i++) {
    TVec<TInt>& IntVec = VecOfIntVecsN[i];
    IntVec.Ins(NodeH.GetKeyId(NId), TInt::Mn);
  }
  for (i = 0; i < VecOfStrVecsN.Len(); i++) {
    TVec<TStr>& StrVec = VecOfStrVecsN[i];
    StrVec.Ins(NodeH.GetKeyId(NId), TStr::GetNullStr());
  }
  for (i = 0; i < VecOfFltVecsN.Len(); i++) {
    TVec<TFlt>& FltVec = VecOfFltVecsN[i];
    FltVec.Ins(NodeH.GetKeyId(NId), TFlt::Mn);
  }
  NodeH.DelKey(NId);
}
void TNEANet::DelNode ( const TNode NodeI) [inline]

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

Definition at line 1892 of file network.h.

{ DelNode(NodeI.GetId()); }
void TNEANet::Dump ( FILE *  OutF = stdout) const

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

Definition at line 557 of file network.cpp.

                                   {
  const int NodePlaces = (int) ceil(log10((double) GetNodes()));
  const int EdgePlaces = (int) ceil(log10((double) GetEdges()));
  fprintf(OutF, "-------------------------------------------------\nDirected Node-Edge Network: nodes: %d, edges: %d\n", GetNodes(), GetEdges());
  for (TNodeI NodeI = BegNI(); NodeI < EndNI(); NodeI++) {
    fprintf(OutF, "  %*d]\n", NodePlaces, NodeI.GetId());
    // load node attributes
    TIntV IntAttrN;
    IntAttrValueNI(NodeI.GetId(), IntAttrN);
    fprintf(OutF, "    nai[%d]", IntAttrN.Len());
    for (int i = 0; i < IntAttrN.Len(); i++) {
      fprintf(OutF, " %*i", NodePlaces, IntAttrN[i]()); }
    TStrV StrAttrN;
    StrAttrValueNI(NodeI.GetId(), StrAttrN);
    fprintf(OutF, "    nas[%d]", StrAttrN.Len());
    for (int i = 0; i < StrAttrN.Len(); i++) {
      fprintf(OutF, " %*s", NodePlaces, StrAttrN[i]()); }
    TFltV FltAttrN;
    FltAttrValueNI(NodeI.GetId(), FltAttrN);
    fprintf(OutF, "    naf[%d]", FltAttrN.Len());
    for (int i = 0; i < FltAttrN.Len(); i++) {
      fprintf(OutF, " %*f", NodePlaces, FltAttrN[i]()); }

    fprintf(OutF, "    in[%d]", NodeI.GetInDeg());
    for (int edge = 0; edge < NodeI.GetInDeg(); edge++) {
      fprintf(OutF, " %*d", EdgePlaces, NodeI.GetInEId(edge)); }
    fprintf(OutF, "\n    out[%d]", NodeI.GetOutDeg());
    for (int edge = 0; edge < NodeI.GetOutDeg(); edge++) {
      fprintf(OutF, " %*d", EdgePlaces, NodeI.GetOutEId(edge)); }
   
    fprintf(OutF, "\n");
  }
  for (TEdgeI EdgeI = BegEI(); EdgeI < EndEI(); EdgeI++) {
    fprintf(OutF, "  %*d]  %*d  ->  %*d\n", EdgePlaces, EdgeI.GetId(), NodePlaces, EdgeI.GetSrcNId(), NodePlaces, EdgeI.GetDstNId());

    // load edge attributes
    TIntV IntAttrE;
    IntAttrValueEI(EdgeI.GetId(), IntAttrE);
    fprintf(OutF, "    eai[%d]", IntAttrE.Len());
    for (int i = 0; i < IntAttrE.Len(); i++) {
      fprintf(OutF, " %*i", EdgePlaces, IntAttrE[i]()); }
    TStrV StrAttrE;
    StrAttrValueEI(EdgeI.GetId(), StrAttrE);
    fprintf(OutF, "    eas[%d]", StrAttrE.Len());
    for (int i = 0; i < StrAttrE.Len(); i++) {
      fprintf(OutF, " %*s", EdgePlaces, StrAttrE[i]()); }
    TFltV FltAttrE;
    FltAttrValueEI(EdgeI.GetId(), FltAttrE);
    fprintf(OutF, "    eaf[%d]", FltAttrE.Len());
    for (int i = 0; i < FltAttrE.Len(); i++) {
      fprintf(OutF, " %*f", EdgePlaces, FltAttrE[i]()); }
  }
  fprintf(OutF, "\n");
}
bool TNEANet::EdgeAttrIsDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Definition at line 230 of file network.cpp.

                                                                                   {
  bool IntDel = EdgeAttrIsIntDeleted(EId, EdgeHI);
  bool StrDel = EdgeAttrIsStrDeleted(EId, EdgeHI);
  bool FltDel = EdgeAttrIsFltDeleted(EId, EdgeHI);
  return IntDel || StrDel || FltDel;
}
bool TNEANet::EdgeAttrIsFltDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Definition at line 249 of file network.cpp.

                                                                                      {
  return (EdgeHI.GetDat().Val1 == FltType &&
    GetFltAttrDefaultE(EdgeHI.GetKey()) == this->VecOfFltVecsE.GetVal(
    this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EId));
}
bool TNEANet::EdgeAttrIsIntDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Definition at line 237 of file network.cpp.

                                                                                      {
  return (EdgeHI.GetDat().Val1 == IntType &&
    GetIntAttrDefaultE(EdgeHI.GetKey()) == this->VecOfIntVecsE.GetVal(
    this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EId));
}
bool TNEANet::EdgeAttrIsStrDeleted ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Definition at line 243 of file network.cpp.

                                                                                      {
  return (EdgeHI.GetDat().Val1 == StrType &&
    GetStrAttrDefaultE(EdgeHI.GetKey()) == this->VecOfStrVecsE.GetVal(
    this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EId));
}
bool TNEANet::Empty ( ) const [inline]

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

Definition at line 2084 of file network.h.

{ return GetNodes()==0; }
TAFltI TNEANet::EndEAFltI ( const TStr attr) const [inline]

Returns an iterator referring to the past-the-end node's attribute.

Definition at line 2024 of file network.h.

                                           {
    return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr, true, this);
  }
TAIntI TNEANet::EndEAIntI ( const TStr attr) const [inline]

Returns an iterator referring to the past-the-end node's attribute.

Definition at line 2001 of file network.h.

                                           {
    return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr, true, this);
  }
TAStrI TNEANet::EndEAStrI ( const TStr attr) const [inline]

Returns an iterator referring to the past-the-end node's attribute.

Definition at line 2012 of file network.h.

                                           {
    return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr, true, this);
  }
TEdgeI TNEANet::EndEI ( ) const [inline]

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

Definition at line 2064 of file network.h.

{ return TEdgeI(EdgeH.EndI(), this); }
TAFltI TNEANet::EndNAFltI ( const TStr attr) const [inline]

Returns an iterator referring to the past-the-end node's attribute.

Definition at line 1924 of file network.h.

                                           {
    return TAFltI(VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2].EndI(), attr, false, this); }
TAIntI TNEANet::EndNAIntI ( const TStr attr) const [inline]

Returns an iterator referring to the past-the-end node's attribute.

Definition at line 1905 of file network.h.

                                           {
    return TAIntI(VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2].EndI(), attr, false, this); }
TAStrI TNEANet::EndNAStrI ( const TStr attr) const [inline]

Returns an iterator referring to the past-the-end node's attribute.

Definition at line 1915 of file network.h.

                                           {
    return TAStrI(VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2].EndI(), attr, false, this); }
TNodeI TNEANet::EndNI ( ) const [inline]

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

Definition at line 1898 of file network.h.

{ return TNodeI(NodeH.EndI(), this); }
void TNEANet::FltAttrNameEI ( const TInt EId,
TStrV Names 
) const [inline]

Returns a vector of int attr names for node NId.

Definition at line 1988 of file network.h.

                                                          {
    FltAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
void TNEANet::FltAttrNameEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Names 
) const

Definition at line 209 of file network.cpp.

                                                                                       {
  Names = TVec<TStr>();
  while (!EdgeHI.IsEnd()) {
    if (EdgeHI.GetDat().Val1 == FltType && !EdgeAttrIsFltDeleted(EId, EdgeHI)) {
      Names.Add(EdgeHI.GetKey());
    }
    EdgeHI++;
  }  
}
void TNEANet::FltAttrNameNI ( const TInt NId,
TStrV Names 
) const [inline]

Returns a vector of int attr names for node NId.

Definition at line 1955 of file network.h.

                                                          {
    FltAttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
void TNEANet::FltAttrNameNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Names 
) const

Definition at line 87 of file network.cpp.

                                                                                       {
  Names = TVec<TStr>();
  while (!NodeHI.IsEnd()) {
    if (NodeHI.GetDat().Val1 == FltType && !NodeAttrIsFltDeleted(NId, NodeHI)) {
      Names.Add(NodeHI.GetKey());
    }
    NodeHI++;
  }  
}
void TNEANet::FltAttrValueEI ( const TInt EId,
TFltV Values 
) const [inline]

Returns a vector of attr avlues for node NId.

Definition at line 1992 of file network.h.

                                                            {
    FltAttrValueNI(EId, KeyToIndexTypeE.BegI(), Values);}
void TNEANet::FltAttrValueEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TFltV Values 
) const

Definition at line 219 of file network.cpp.

                                                                                         {
  Values = TVec<TFlt>();
  while (!EdgeHI.IsEnd()) {
    if (EdgeHI.GetDat().Val1 == FltType && !EdgeAttrIsFltDeleted(EId, EdgeHI)) {
      TFlt val = (this->VecOfFltVecsE.GetVal(EdgeHI.GetDat().Val2).GetVal(EId));
      Values.Add(val);
    }
    EdgeHI++;
  }  
}
void TNEANet::FltAttrValueNI ( const TInt NId,
TFltV Values 
) const [inline]

Returns a vector of attr avlues for node NId.

Definition at line 1959 of file network.h.

                                                            {
    FltAttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
void TNEANet::FltAttrValueNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TFltV Values 
) const

Definition at line 97 of file network.cpp.

                                                                                         {
  Values = TVec<TFlt>();
  while (!NodeHI.IsEnd()) {
    if (NodeHI.GetDat().Val1 == FltType && !NodeAttrIsFltDeleted(NId, NodeHI)) {
      TFlt val = (this->VecOfFltVecsN.GetVal(NodeHI.GetDat().Val2).GetVal(NId));
      Values.Add(val);
    }
    NodeHI++;
  }  
}
TAFltI TNEANet::GetEAFltI ( const TStr attr,
const int &  EId 
) const [inline]

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

Definition at line 2028 of file network.h.

                                                           {
    return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(EId), attr, true, this);
  }
TAIntI TNEANet::GetEAIntI ( const TStr attr,
const int &  EId 
) const [inline]

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

Definition at line 2005 of file network.h.

                                                           {
    return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(EId), attr, true, this);
  }
TAStrI TNEANet::GetEAStrI ( const TStr attr,
const int &  EId 
) const [inline]

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

Definition at line 2016 of file network.h.

                                                           {
    return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(EId), attr, true, this);
  }
TEdge& TNEANet::GetEdge ( const int &  EId) [inline, private]

Definition at line 1798 of file network.h.

{ return EdgeH.GetDat(EId); }
const TEdge& TNEANet::GetEdge ( const int &  EId) const [inline, private]

Definition at line 1799 of file network.h.

{ return EdgeH.GetDat(EId); }
TStr TNEANet::GetEdgeAttrValue ( const int &  EId,
const TStrIntPrH::TIter EdgeHI 
) const

Definition at line 255 of file network.cpp.

                                                                                  {
  if (EdgeHI.GetDat().Val1 == IntType) {
    return (this->VecOfIntVecsE.GetVal(
      this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EId)).GetStr();
  } else if(EdgeHI.GetDat().Val1 == StrType) {
    return this->VecOfStrVecsE.GetVal(
    this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EId);
  } else if (EdgeHI.GetDat().Val1 == FltType) {
    return (this->VecOfFltVecsE.GetVal(
      this->KeyToIndexTypeE.GetDat(EdgeHI.GetKey()).Val2).GetVal(EId)).GetStr();
  }
  return TStr::GetNullStr();
}
int TNEANet::GetEdges ( ) const [inline]

Returns the number of edges in the graph.

Definition at line 2035 of file network.h.

{ return EdgeH.Len(); }
TEdgeI TNEANet::GetEI ( const int &  EId) const [inline]

Definition at line 2066 of file network.h.

{ return TEdgeI(EdgeH.GetI(EId), this); }
TEdgeI TNEANet::GetEI ( const int &  SrcNId,
const int &  DstNId 
) const [inline]

Definition at line 2068 of file network.h.

{ return GetEI(GetEId(SrcNId, DstNId)); }
int TNEANet::GetEId ( const int &  SrcNId,
const int &  DstNId 
) const [inline]

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

Definition at line 2060 of file network.h.

{ int EId; return IsEdge(SrcNId, DstNId, EId)?EId:-1; }
void TNEANet::GetEIdV ( TIntV EIdV) const

Gets a vector IDs of all edges in the graph.

Definition at line 488 of file network.cpp.

                                       {
  EIdV.Gen(GetEdges(), 0);
  for (int E=EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E); ) {
    EIdV.Add(EdgeH.GetKey(E));
  }
}
TFlt TNEANet::GetFltAttrDatE ( const TEdgeI EdgeId,
const TStr attr 
) [inline]

Gets the value of flt attr from the edge attr value vector.

Definition at line 2158 of file network.h.

{ return GetFltAttrDatE(EdgeId.GetId(), attr); }
TFlt TNEANet::GetFltAttrDatE ( const int &  EId,
const TStr attr 
)

Definition at line 774 of file network.cpp.

                                                             {
  return VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2][EId];
}
TFlt TNEANet::GetFltAttrDatN ( const TNodeI NodeId,
const TStr attr 
) [inline]

Gets the value of flt attr from the node attr value vector.

Definition at line 2148 of file network.h.

{ return GetFltAttrDatN(NodeId.GetId(), attr); }
TFlt TNEANet::GetFltAttrDatN ( const int &  NId,
const TStr attr 
)

Definition at line 762 of file network.cpp.

                                                             {
  return VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2][NId];
}
TFlt TNEANet::GetFltAttrDefaultE ( const TStr attribute) const [inline, private]

Get Flt edge attribute val. If not a proper attr, return default.

Definition at line 1812 of file network.h.

{ return FltDefaultsE.IsKey(attribute) ? FltDefaultsE.GetDat(attribute) : (TFlt) TFlt::Mn; }
TFlt TNEANet::GetFltAttrDefaultN ( const TStr attribute) const [inline, private]

Get Flt node attribute val. If not a proper attr, return default.

Definition at line 1806 of file network.h.

{ return FltDefaultsN.IsKey(attribute) ? FltDefaultsN.GetDat(attribute) : (TFlt) TFlt::Mn; }
TInt TNEANet::GetIntAttrDatE ( const TEdgeI EdgeId,
const TStr attr 
) [inline]

Gets the value of int attr from the edge attr value vector.

Definition at line 2152 of file network.h.

{ return GetIntAttrDatE(EdgeId.GetId(), attr); }
TInt TNEANet::GetIntAttrDatE ( const int &  EId,
const TStr attr 
)

Definition at line 766 of file network.cpp.

                                                             {
  return VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2][EId];
}
TInt TNEANet::GetIntAttrDatN ( const TNodeI NodeId,
const TStr attr 
) [inline]

Gets the value of int attr from the node attr value vector.

Definition at line 2142 of file network.h.

{ return GetIntAttrDatN(NodeId.GetId(), attr); }
TInt TNEANet::GetIntAttrDatN ( const int &  NId,
const TStr attr 
)

Definition at line 754 of file network.cpp.

                                                             {
  return VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2][NId];
}
TInt TNEANet::GetIntAttrDefaultE ( const TStr attribute) const [inline, private]

Get Int edge attribute val. If not a proper attr, return default.

Definition at line 1808 of file network.h.

{ return IntDefaultsE.IsKey(attribute) ? IntDefaultsE.GetDat(attribute) : (TInt) TInt::Mn; }
TInt TNEANet::GetIntAttrDefaultN ( const TStr attribute) const [inline, private]

Get Int node attribute val. If not a proper attr, return default.

Definition at line 1802 of file network.h.

{ return IntDefaultsN.IsKey(attribute) ? IntDefaultsN.GetDat(attribute) : (TInt) TInt::Mn; }
int TNEANet::GetMxNId ( ) const [inline]

Returns the maximum id of a any node in the graph.

Definition at line 2032 of file network.h.

{ return MxNId; }
TAFltI TNEANet::GetNAFltI ( const TStr attr,
const int &  NId 
) const [inline]

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

Definition at line 1927 of file network.h.

                                                           {
    return TAFltI(VecOfFltVecsN[KeyToIndexTypeN.GetDat(attr).Val2].GetI(NId), attr, false, this); }
TAIntI TNEANet::GetNAIntI ( const TStr attr,
const int &  NId 
) const [inline]

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

Definition at line 1908 of file network.h.

                                                           {
    return TAIntI(VecOfIntVecsN[KeyToIndexTypeN.GetDat(attr).Val2].GetI(NId), attr, false, this); }
TAStrI TNEANet::GetNAStrI ( const TStr attr,
const int &  NId 
) const [inline]

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

Definition at line 1918 of file network.h.

                                                           {
    return TAStrI(VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2].GetI(NId), attr, false, this); }
TNodeI TNEANet::GetNI ( const int &  NId) const [inline]

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

Definition at line 1900 of file network.h.

{ return TNodeI(NodeH.GetI(NId), this); }
void TNEANet::GetNIdV ( TIntV NIdV) const

Gets a vector IDs of all nodes in the graph.

Definition at line 481 of file network.cpp.

                                       {
  NIdV.Gen(GetNodes(), 0);
  for (int N=NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
    NIdV.Add(NodeH.GetKey(N));
  }
}
TNode& TNEANet::GetNode ( const int &  NId) [inline, private]

Definition at line 1796 of file network.h.

{ return NodeH.GetDat(NId); }
const TNode& TNEANet::GetNode ( const int &  NId) const [inline, private]

Definition at line 1797 of file network.h.

{ return NodeH.GetDat(NId); }
TStr TNEANet::GetNodeAttrValue ( const int &  NId,
const TStrIntPrH::TIter NodeHI 
) const

Definition at line 133 of file network.cpp.

                                                                                  {
  if (NodeHI.GetDat().Val1 == IntType) {
    return (this->VecOfIntVecsN.GetVal(
      this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NId)).GetStr();
  } else if(NodeHI.GetDat().Val1 == StrType) {
    return this->VecOfStrVecsN.GetVal(
    this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NId);
  } else if (NodeHI.GetDat().Val1 == FltType) {
    return (this->VecOfFltVecsN.GetVal(
      this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NId)).GetStr();
  }
  return TStr::GetNullStr();
}
int TNEANet::GetNodes ( ) const [inline]

Returns the number of nodes in the graph.

Definition at line 1878 of file network.h.

{ return NodeH.Len(); }
TEdgeI TNEANet::GetRndEI ( TRnd Rnd = TInt::Rnd) [inline]

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

Definition at line 2077 of file network.h.

{ return GetEI(GetRndEId(Rnd)); }
int TNEANet::GetRndEId ( TRnd Rnd = TInt::Rnd) [inline]

Returns an ID of a random edge in the graph.

Definition at line 2075 of file network.h.

{ return EdgeH.GetKey(EdgeH.GetRndKeyId(Rnd, 0.8)); }
TNodeI TNEANet::GetRndNI ( TRnd Rnd = TInt::Rnd) [inline]

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

Definition at line 2073 of file network.h.

{ return GetNI(GetRndNId(Rnd)); }
int TNEANet::GetRndNId ( TRnd Rnd = TInt::Rnd) [inline]

Returns an ID of a random node in the graph.

Definition at line 2071 of file network.h.

{ return NodeH.GetKey(NodeH.GetRndKeyId(Rnd, 0.8)); }
static PNEGraph TNEANet::GetSmallGraph ( ) [static]

TODO implement and document TNEANet::GetSmallGraph()

TStr TNEANet::GetStrAttrDatE ( const TEdgeI EdgeId,
const TStr attr 
) [inline]

Gets the value of str attr from the edge attr value vector.

Definition at line 2155 of file network.h.

{ return GetStrAttrDatE(EdgeId.GetId(), attr); }
TStr TNEANet::GetStrAttrDatE ( const int &  EId,
const TStr attr 
)

Definition at line 770 of file network.cpp.

                                                             {
  return VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2][EId];
}
TStr TNEANet::GetStrAttrDatN ( const TNodeI NodeId,
const TStr attr 
) [inline]

Gets the value of str attr from the node attr value vector.

Definition at line 2145 of file network.h.

{ return GetStrAttrDatN(NodeId.GetId(), attr); }
TStr TNEANet::GetStrAttrDatN ( const int &  NId,
const TStr attr 
)

Definition at line 758 of file network.cpp.

                                                             {
  return VecOfStrVecsN[KeyToIndexTypeN.GetDat(attr).Val2][NId];
}
TStr TNEANet::GetStrAttrDefaultE ( const TStr attribute) const [inline, private]

Get Str edge attribute val. If not a proper attr, return default.

Definition at line 1810 of file network.h.

{ return StrDefaultsE.IsKey(attribute) ? StrDefaultsE.GetDat(attribute) : (TStr) TStr::GetNullStr(); }
TStr TNEANet::GetStrAttrDefaultN ( const TStr attribute) const [inline, private]

Get Str node attribute val. If not a proper attr, return default.

Definition at line 1804 of file network.h.

{ return StrDefaultsN.IsKey(attribute) ? StrDefaultsN.GetDat(attribute) : (TStr) TStr::GetNullStr(); }
bool TNEANet::HasFlag ( const TGraphFlag Flag) const

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

Definition at line 3 of file network.cpp.

                                                  {
  return HasGraphFlag(TNEANet::TNet, Flag);
}
void TNEANet::IntAttrNameEI ( const TInt EId,
TStrV Names 
) const [inline]

Returns a vector of int attr names for edge EId.

Definition at line 1972 of file network.h.

                                                          {
    IntAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
void TNEANet::IntAttrNameEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Names 
) const

Definition at line 167 of file network.cpp.

                                                                                       {
  Names = TVec<TStr>();
  while (!EdgeHI.IsEnd()) {
    if (EdgeHI.GetDat().Val1 == IntType && !EdgeAttrIsIntDeleted(EId, EdgeHI)) {
      Names.Add(EdgeHI.GetKey());
    }
    EdgeHI++;
  }  
}
void TNEANet::IntAttrNameNI ( const TInt NId,
TStrV Names 
) const [inline]

Returns a vector of int attr names for node NId.

Definition at line 1939 of file network.h.

                                                          {
    IntAttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
void TNEANet::IntAttrNameNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Names 
) const

Definition at line 45 of file network.cpp.

                                                                                       {
  Names = TVec<TStr>();
  while (!NodeHI.IsEnd()) {
    if (NodeHI.GetDat().Val1 == IntType && !NodeAttrIsIntDeleted(NId, NodeHI)) {
      Names.Add(NodeHI.GetKey());
    }
    NodeHI++;
  }  
}
void TNEANet::IntAttrValueEI ( const TInt EId,
TIntV Values 
) const [inline]

Returns a vector of attr values for edge EId.

Definition at line 1976 of file network.h.

                                                            {
    IntAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
void TNEANet::IntAttrValueEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TIntV Values 
) const

Definition at line 177 of file network.cpp.

                                                                                         {
  Values = TVec<TInt>();
  while (!EdgeHI.IsEnd()) {
    if (EdgeHI.GetDat().Val1 == IntType && !EdgeAttrIsIntDeleted(EId, EdgeHI)) {
      TInt val = (this->VecOfIntVecsE.GetVal(EdgeHI.GetDat().Val2).GetVal(EId));
      Values.Add(val);
    }
    EdgeHI++;
  }  
}
void TNEANet::IntAttrValueNI ( const TInt NId,
TIntV Values 
) const [inline]

Returns a vector of attr avlues for node NId.

Definition at line 1943 of file network.h.

                                                            {
    IntAttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
void TNEANet::IntAttrValueNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TIntV Values 
) const

Definition at line 55 of file network.cpp.

                                                                                         {
  Values = TVec<TInt>();
  while (!NodeHI.IsEnd()) {
    if (NodeHI.GetDat().Val1 == IntType && !NodeAttrIsIntDeleted(NId, NodeHI)) {
      TInt val = this->VecOfIntVecsN.GetVal(NodeHI.GetDat().Val2).GetVal(NId);
      Values.Add(val);
    }
    NodeHI++;
  }  
}
bool TNEANet::IsEdge ( const int &  EId) const [inline]

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

Definition at line 2054 of file network.h.

{ return EdgeH.IsKey(EId); }
bool TNEANet::IsEdge ( const int &  SrcNId,
const int &  DstNId,
const bool &  IsDir = true 
) const [inline]

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

Definition at line 2056 of file network.h.

{ int EId; return IsEdge(SrcNId, DstNId, EId, IsDir); }
bool TNEANet::IsEdge ( const int &  SrcNId,
const int &  DstNId,
int &  EId,
const bool &  IsDir = true 
) const

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

Definition at line 460 of file network.cpp.

                                                                                            {
  const TNode& SrcNode = GetNode(SrcNId);
  for (int edge = 0; edge < SrcNode.GetOutDeg(); edge++) {
    const TEdge& Edge = GetEdge(SrcNode.GetOutEId(edge));
    if (DstNId == Edge.GetDstNId()) {
      EId = Edge.GetId();
      return true;
    }
  }
  if (! IsDir) {
    for (int edge = 0; edge < SrcNode.GetInDeg(); edge++) {
      const TEdge& Edge = GetEdge(SrcNode.GetInEId(edge));
      if (DstNId == Edge.GetSrcNId()) {
        EId = Edge.GetId();
        return true;
      }
    }
  }
  return false;
}
bool TNEANet::IsNode ( const int &  NId) const [inline]

Tests whether ID NId is a node.

Definition at line 1894 of file network.h.

{ return NodeH.IsKey(NId); }
bool TNEANet::IsOk ( const bool &  ThrowExcept = true) const

Checks the graph data structure for internal consistency.

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

Definition at line 504 of file network.cpp.

                                                {
  bool RetVal = true;
  for (int N = NodeH.FFirstKeyId(); NodeH.FNextKeyId(N); ) {
    const TNode& Node = NodeH[N];
    if (! Node.OutEIdV.IsSorted()) {
      const TStr Msg = TStr::Fmt("Out-edge list of node %d is not sorted.", Node.GetId());
      if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
    }
    if (! Node.InEIdV.IsSorted()) {
      const TStr Msg = TStr::Fmt("In-edge list of node %d is not sorted.", Node.GetId());
      if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
    }
    // check out-edge ids
    int prevEId = -1;
    for (int e = 0; e < Node.GetOutDeg(); e++) {
      if (! IsEdge(Node.GetOutEId(e))) {
        const TStr Msg = TStr::Fmt("Out-edge id %d of node %d does not exist.",  Node.GetOutEId(e), Node.GetId());
        if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
      }
      if (e > 0 && prevEId == Node.GetOutEId(e)) {
        const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge id %d.", Node.GetId(), Node.GetOutEId(e));
        if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
      }
      prevEId = Node.GetOutEId(e);
    }
    // check in-edge ids
    prevEId = -1;
    for (int e = 0; e < Node.GetInDeg(); e++) {
      if (! IsEdge(Node.GetInEId(e))) {
      const TStr Msg = TStr::Fmt("Out-edge id %d of node %d does not exist.",  Node.GetInEId(e), Node.GetId());
      if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
      }
      if (e > 0 && prevEId == Node.GetInEId(e)) {
        const TStr Msg = TStr::Fmt("Node %d has duplidate out-edge id %d.", Node.GetId(), Node.GetInEId(e));
        if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
      }
      prevEId = Node.GetInEId(e);
    }
  }
  for (int E = EdgeH.FFirstKeyId(); EdgeH.FNextKeyId(E); ) {
    const TEdge& Edge = EdgeH[E];
    if (! IsNode(Edge.GetSrcNId())) {
      const TStr Msg = TStr::Fmt("Edge %d source node %d does not exist.", Edge.GetId(), Edge.GetSrcNId());
      if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
    }
    if (! IsNode(Edge.GetDstNId())) {
      const TStr Msg = TStr::Fmt("Edge %d destination node %d does not exist.", Edge.GetId(), Edge.GetDstNId());
      if (ThrowExcept) { EAssertR(false, Msg); } else { ErrNotify(Msg.CStr()); } RetVal=false;
    }
  }
  return RetVal;
}
static PNEANet TNEANet::Load ( TSIn SIn) [inline, static]

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

Definition at line 1870 of file network.h.

{ return PNEANet(new TNEANet(SIn)); }
static PNEANet TNEANet::New ( ) [inline, static]

Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New().

Definition at line 1864 of file network.h.

{ return PNEANet(new TNEANet()); }
static PNEANet TNEANet::New ( const int &  Nodes,
const int &  Edges 
) [inline, static]

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

Call: PNEANet Graph = TNEANet::New(Nodes, Edges).

Definition at line 1868 of file network.h.

{ return PNEANet(new TNEANet(Nodes, Edges)); }
bool TNEANet::NodeAttrIsDeleted ( const int &  NId,
const TStrIntPrH::TIter NodeHI 
) const

Definition at line 108 of file network.cpp.

                                                                                   {
  bool IntDel = NodeAttrIsIntDeleted(NId, NodeHI);
  bool StrDel = NodeAttrIsStrDeleted(NId, NodeHI);
  bool FltDel = NodeAttrIsFltDeleted(NId, NodeHI);
  return IntDel || StrDel || FltDel;
}
bool TNEANet::NodeAttrIsFltDeleted ( const int &  NId,
const TStrIntPrH::TIter NodeHI 
) const

Definition at line 127 of file network.cpp.

                                                                                      {
  return (NodeHI.GetDat().Val1 == FltType &&
    GetFltAttrDefaultN(NodeHI.GetKey()) == this->VecOfFltVecsN.GetVal(
    this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NId));
}
bool TNEANet::NodeAttrIsIntDeleted ( const int &  NId,
const TStrIntPrH::TIter NodeHI 
) const

Definition at line 115 of file network.cpp.

                                                                                      {
  return (NodeHI.GetDat().Val1 == IntType &&
    GetIntAttrDefaultN(NodeHI.GetKey()) == this->VecOfIntVecsN.GetVal(
    this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NId));
}
bool TNEANet::NodeAttrIsStrDeleted ( const int &  NId,
const TStrIntPrH::TIter NodeHI 
) const

Definition at line 121 of file network.cpp.

                                                                                      {
  return (NodeHI.GetDat().Val1 == StrType &&
    GetStrAttrDefaultN(NodeHI.GetKey()) == this->VecOfStrVecsN.GetVal(
    this->KeyToIndexTypeN.GetDat(NodeHI.GetKey()).Val2).GetVal(NId));
}
TNEANet& TNEANet::operator= ( const TNEANet Graph) [inline]

Definition at line 1873 of file network.h.

                                             { if (this!=&Graph) {
    MxNId=Graph.MxNId; MxEId=Graph.MxEId; NodeH=Graph.NodeH; EdgeH=Graph.EdgeH; }
    return *this; }
void TNEANet::Reserve ( const int &  Nodes,
const int &  Edges 
) [inline]

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

Definition at line 2092 of file network.h.

                                                   {
    if (Nodes>0) { NodeH.Gen(Nodes/2); } if (Edges>0) { EdgeH.Gen(Edges/2); } }
void TNEANet::Save ( TSOut SOut) const [inline]

Saves the graph to a (binary) stream SOut.

Definition at line 1854 of file network.h.

void TNEANet::StrAttrNameEI ( const TInt EId,
TStrV Names 
) const [inline]

Returns a vector of str attr names for node NId.

Definition at line 1980 of file network.h.

                                                          {
    StrAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
void TNEANet::StrAttrNameEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Names 
) const

Definition at line 188 of file network.cpp.

                                                                                       {
  Names = TVec<TStr>();
  while (!EdgeHI.IsEnd()) {
    if (EdgeHI.GetDat().Val1 == StrType && !EdgeAttrIsStrDeleted(EId, EdgeHI)) {
      Names.Add(EdgeHI.GetKey());
    }
    EdgeHI++;
  }  
}
void TNEANet::StrAttrNameNI ( const TInt NId,
TStrV Names 
) const [inline]

Returns a vector of str attr names for node NId.

Definition at line 1947 of file network.h.

                                                          {
    StrAttrNameNI(NId, KeyToIndexTypeN.BegI(), Names);}
void TNEANet::StrAttrNameNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Names 
) const

Definition at line 66 of file network.cpp.

                                                                                       {
  Names = TVec<TStr>();
  while (!NodeHI.IsEnd()) {
    if (NodeHI.GetDat().Val1 == StrType && !NodeAttrIsStrDeleted(NId, NodeHI)) {
      Names.Add(NodeHI.GetKey());
    }
    NodeHI++;
  }  
}
void TNEANet::StrAttrValueEI ( const TInt EId,
TStrV Values 
) const [inline]

Returns a vector of attr avlues for node NId.

Definition at line 1984 of file network.h.

                                                            {
    StrAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
void TNEANet::StrAttrValueEI ( const TInt EId,
TStrIntPrH::TIter  EdgeHI,
TStrV Values 
) const

Definition at line 198 of file network.cpp.

                                                                                         {
  Values = TVec<TStr>();
  while (!EdgeHI.IsEnd()) {
    if (EdgeHI.GetDat().Val1 == StrType && !EdgeAttrIsStrDeleted(EId, EdgeHI)) {
      TStr val = this->VecOfStrVecsE.GetVal(EdgeHI.GetDat().Val2).GetVal(EId);
      Values.Add(val);
    }
    EdgeHI++;
  }  
}
void TNEANet::StrAttrValueNI ( const TInt NId,
TStrV Values 
) const [inline]

Returns a vector of attr avlues for node NId.

Definition at line 1951 of file network.h.

                                                            {
    StrAttrValueNI(NId, KeyToIndexTypeN.BegI(), Values);}
void TNEANet::StrAttrValueNI ( const TInt NId,
TStrIntPrH::TIter  NodeHI,
TStrV Values 
) const

Definition at line 76 of file network.cpp.

                                                                                         {
  Values = TVec<TStr>();
  while (!NodeHI.IsEnd()) {
    if (NodeHI.GetDat().Val1 == StrType && !NodeAttrIsStrDeleted(NId, NodeHI)) {
      TStr val = this->VecOfStrVecsN.GetVal(NodeHI.GetDat().Val2).GetVal(NId);
      Values.Add(val);
    }
    NodeHI++;
  }  
}

Friends And Related Function Documentation

friend class TPt< TNEANet > [friend]

Definition at line 2212 of file network.h.


Member Data Documentation

TCRef TNEANet::CRef [private]

Definition at line 1815 of file network.h.

Definition at line 1818 of file network.h.

Definition at line 1824 of file network.h.

Definition at line 1824 of file network.h.

Definition at line 1822 of file network.h.

Definition at line 1822 of file network.h.

Definition at line 1820 of file network.h.

KeyToIndexType[N|E]: Key->(Type,Index).

Definition at line 1820 of file network.h.

TInt TNEANet::MxEId [private]

Definition at line 1816 of file network.h.

TInt TNEANet::MxNId [private]

Definition at line 1816 of file network.h.

Definition at line 1817 of file network.h.

Definition at line 1823 of file network.h.

Definition at line 1823 of file network.h.

Definition at line 1827 of file network.h.

Definition at line 1827 of file network.h.

Definition at line 1825 of file network.h.

Definition at line 1825 of file network.h.

Definition at line 1826 of file network.h.

Definition at line 1826 of file network.h.


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