56 explicit TModeNet(
const int& Nodes,
const int& Edges,
const int& TypeId) :
TNEANet(Nodes, Edges),
108 int AddNeighbor(
const int& NId,
const int& EId,
const bool outEdge,
const int linkId,
const bool sameMode,
bool isDir);
109 int AddNeighbor(
const int& NId,
const int& EId,
const bool outEdge,
const TStr& linkName,
const bool sameMode,
bool isDir);
110 int DelNeighbor(
const int& NId,
const int& EId,
bool outEdge,
const TStr& CrossName,
const bool sameMode,
bool isDir);
111 int DelNeighbor(
const int& NId,
const int& EId,
bool outEdge,
const TInt& linkId,
const bool sameMode,
bool isDir);
114 int AddNbrType(
const TStr& CrossName,
const bool sameMode,
bool isDir);
121 void ClrNbr(
const TStr& CrossNetName,
const bool& outEdge,
const bool& sameMode,
bool& isDir);
144 TCrossEdge(
const int& Id,
const int& SourceNId,
const int& DestNId) :
258 template<
typename TElem>
280 TCrossNet() :
CrossH(),
MxEId(0),
Mode1(-1),
Mode2(-1),
IsDirect(),
CrossNetId(),
Net(),
KeyToIndexTypeE(),
IntDefaultsE(),
StrDefaultsE(),
284 TCrossNet(
TInt MId1,
TInt MId2,
TBool IsDir,
TInt LId) :
CrossH(),
MxEId(0),
Mode1(MId1),
Mode2(MId2),
IsDirect(IsDir),
CrossNetId(LId),
Net(),
332 int AddEdge(
const int& sourceNId,
const int& destNId,
int EId=-1);
595 it.
GetDat().SetParentPointer(
this);
598 it.GetDat().SetParentPointer(
this);
629 it.GetDat().ConvertToSparse();
680 void ClrNbr(
const TInt& ModeId,
const TInt& CrossNetId,
const bool& outEdge,
const bool& sameMode,
bool& isDir);
TCrossNet & GetCrossNet()
Gets a reference to the crossnet.
TVec< TIntV > VecOfIntVecsN
TStr GetStrAttrDatE(const TCrossEdgeI &EdgeI, const TStr &attr)
Gets the value of str attr from the edge attr value vector.
THash< TStr, TBool > KeyToDenseE
TModeNetI GetModeNetI(const int &Id) const
Iterator over all modenets.
bool operator<(const TNodeI &NodeI) const
int GetId() const
Returns edge ID.
TIter EndI() const
Returns an iterator referring to the past-the-end element in the vector.
int AddFltAttrDatE(const TCrossEdgeI &EdgeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
void LoadShM(TShMIn &ShMIn)
Loads network from shared memory stream.
TCrossEdgeI(const TCrossEdgeI &EdgeI)
void LoadNetworkShM(TShMIn &ShMIn)
PNEANet ToNetwork2(TIntV &CrossNetTypes, TIntStrPrVH &NodeAttrMap, THash< TInt, TVec< TPair< TStr, TStr > > > &EdgeAttrMap)
Converts multimodal network to TNEANet; as attr names can collide, AttrMap specifies the Mode/Cross I...
THash< TStr, TFlt > FltDefaultsE
bool IsFltAttrDeletedE(const int &EId, const TStr &attr) const
int AddIntVAttrByVecN(const TStr &attr, TVec< TIntV > &Attrs, TBool UseDense=true)
Adds a new TIntV node attribute to the hashmap.
void FltAttrValueEI(const TInt &EId, TFltV &Values) const
Returns a vector of attr values for node NId.
bool operator<(const TCrossNetI &CrossNetI) const
int GetModeId(const TStr &ModeName) const
Gets the mode id from the mode name.
int AddIntVAttrByHashN(const TStr &attr, THash< TInt, TIntV > &Attrs)
TStrIntPrH KeyToIndexTypeE
void operator()(TVec< TElem > *Node, TShMIn &ShMIn)
bool IsDeleted() const
Returns true if the attribute has been deleted.
int AddStrAttrDatE(const TCrossEdgeI &EdgeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
TAIntI GetEAIntI(const TStr &attr, const int &EId) const
Returns an iterator referring to the edge of ID EId in the graph.
TVec< TStrV > VecOfStrVecsE
THash< TStr, TFlt > FltDefaultsE
THash< TStr, TInt > IntDefaultsE
int DelCrossNet(const TInt &CrossNetId)
Deletes a crossnet from the multimodal network.
TModeNet iterator. Only forward iteration (operator++) is supported.
TCrossNetI EndCrossNetI() const
void FltAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for node NId.
TModeNetI(const THashIter &ModeNetHIter, const TMMNet *GraphPt)
Node iterator. Only forward iteration (operator++) is supported.
TVec< TIntV > VecOfIntVecsE
void GetNeighborsByCrossNet(TStr &Name, TIntV &Neighbors, const bool isOutEId=false)
Gets the neighbors (NIds) for the given node for the given CrossNet type.
TCrossNet(const TCrossNet &OtherTCrossNet)
TModeNet & GetModeNet()
Gets a reference to the modenet.
bool EdgeAttrIsStrDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
TVec< THash< TInt, TIntV > > VecOfIntHashVecsE
void GetPartitionRanges(TIntPrV &Partitions, const TInt &NumPartitions, const TInt &MxVal) const
void AttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for edge EId.
void Save(TSOut &SOut) const
TStr GetCrossName()
Gets the name of the crossnet.
PMMNet GetSubgraphByCrossNet(TStrV &CrossNetTypes)
Gets the induced subgraph given a vector of crossnet type names.
THash< TInt, TModeNet >::TIter THashIter
int GetSrcModeId() const
Returns the source mode of the crossnet.
int GetSrcNId() const
Returns the source of the edge.
THash< TInt, TNode >::TIter THashIter
TNodeI GetMMNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
void DelNode(const int &NId)
Deletes the given node from this mode.
Tests (at compile time) if the graph is directed.
bool IsDeleted() const
Returns true if the attribute has been deleted.
TAIntI BegEAIntI(const TStr &attr) const
Returns an iterator referring to the first edge's int attribute.
bool operator==(const TCrossEdgeI &EdgeI) const
TAStrI(const TStrVecIter &HIter, TStr attribute, const TCrossNet *GraphPt)
TCrossNet iterator. Only forward iteration (operator++) is supported.
TInt GetIntAttrDefaultE(const TStr &attribute) const
Gets Int edge attribute val. If not a proper attr, return default.
void Save(TSOut &SOut) const
TModeNet(const int &TypeId)
TStrIntPrH KeyToIndexTypeE
TCrossEdgeI BegEdgeI() const
A single edge in the cross net. Has an Edge Id, and the source and destination node ids...
bool operator==(const TAIntI &I) const
TFlt GetDat() const
Returns an attribute of the node.
TAFltI BegEAFltI(const TStr &attr) const
Returns an iterator referring to the first edge's flt attribute.
THash< TStr, TFlt > FltDefaultsN
bool operator==(const TAStrI &I) const
void Save(TSOut &SOut) const
int DelNeighbor(const int &NId, const int &EId, bool outEdge, const TStr &CrossName, const bool sameMode, bool isDir)
int GetModeId()
Gets the mode id.
TModeNet(const int &Nodes, const int &Edges, const int &TypeId)
static PMMNet Load(TSIn &SIn)
Loads the TMMNet from binary stream.
TAStrI GetEAStrI(const TStr &attr, const int &EId) const
Returns an iterator referring to the edge of ID EId in the graph.
bool operator<(const TAStrI &I) const
Edge iterator. Only forward iteration (operator++) is supported.
const TDat & GetDat(const TKey &Key) const
Node iterator. Only forward iteration (operator++) is supported.
TVec< TIntV > VecOfIntVecsE
TCrossEdge & GetEdge(int eid)
THash< TInt, TStr > ModeIdToNameH
int DelEdge(const int &EId)
Deletes an edge by its id.
TAStrI EndEAStrI(const TStr &attr) const
Returns an iterator referring to the past-the-end edge's attribute.
int DelAttrDatE(const TCrossEdgeI &EdgeI, const TStr &attr)
Deletes the edge attribute for NodeI.
THash< TInt, TCrossNet > TCrossNetH
int DelModeNet(const TInt &ModeId)
Deletes a mode from the multimodal network.
bool operator==(const TModeNetI &ModeNetI) const
void LoadShM(TShMIn &ShMIn)
Load THash from shared memory file. Copying/Deleting Keys is illegal.
TAIntI EndEAIntI(const TStr &attr) const
Returns an iterator referring to the past-the-end edge's attribute.
bool EdgeAttrIsDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
TCrossEdgeI EndEdgeI() const
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Gets Flt edge attribute val. If not a proper attr, return default.
TCrossNetI BegCrossNetI() const
bool operator<(const TAIntI &I) const
TCrossEdgeI & operator=(const TCrossEdgeI &EdgeI)
TModeNet(const TModeNet &Graph)
TVec< TStrV > VecOfStrVecsN
TNodeI & operator=(const TNodeI &NodeI)
TCrossNet(TInt MId1, TInt MId2, TBool IsDir, TInt LId)
TAStrI BegEAStrI(const TStr &attr) const
Returns an iterator referring to the first edge's str attribute.
void Save(TSOut &SOut) const
TCrossEdge(const int &Id, const int &SourceNId, const int &DestNId)
PNEANet ToNetwork(TIntV &CrossNetTypes, TIntStrStrTrV &NodeAttrMap, TVec< TTriple< TInt, TStr, TStr > > &EdgeAttrMap)
Converts multimodal network to TNEANet; as attr names can collide, AttrMap specifies the (Mode/Cross ...
bool operator==(const TAFltI &I) const
THash< TInt, TEdge > EdgeH
void GetNeighborsByCrossNet(const int &NId, TStr &Name, TIntV &Neighbors, const bool isOutEId=false) const
For the given node, gets all the neighbors for the crossnet type. If this mode is both the source and...
void IntAttrValueEI(const TInt &EId, TIntV &Values) const
Returns a vector of attr values for edge EId.
TCrossNetI(const TCrossNetI &CrossNetI)
int AddCrossNet(const TStr &ModeName1, const TStr &ModeName2, const TStr &CrossNetName, bool isDir=true)
Adds a crossnet to the multimodal network. Specify modes by id or names; by default, crossnet is directed.
Node/edge float attribute iterator. Iterates through all nodes/edges for one float attribute...
int AddModeNet(const TStr &ModeName)
Adds a mode to the multimodal network.
TModeNet(const int &Nodes, const int &Edges)
Constructor that reserves enough memory for a graph of nodes and edges.
int GetCrossNets()
Returns the number of crossnets in the multimodal network.
THash< TStr, TStr > StrDefaultsE
TModeNet & operator=(const TModeNet &Graph)
int GetId() const
Returns ID of the current node.
bool IsDeleted() const
Returns true if the attribute has been deleted.
TVec< TStrV > VecOfStrVecsE
TNodeI EndMMNI() const
Returns an iterator referring to the past-the-end node in the graph.
int AddIntAttrDatE(const TCrossEdgeI &EdgeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
THash< TStr, TInt > ModeNameToIdH
TCrossNetI GetCrossNetI(const int &Id) const
Iterator over all crossnets.
void StrAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of str attr names for node NId.
TVec< TFltV > VecOfFltVecsE
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
void GetCrossNetNames(TStrV &Names)
Gets all the CrossNets that include the given node.
void GetCrossNetNames(TStrV &Names) const
Gets a list of CrossNets that have this Mode as either a source or destination type.
TAFltI GetEAFltI(const TStr &attr, const int &EId) const
Returns an iterator referring to the edge of ID EId in the graph.
TAFltI & operator=(const TAFltI &I)
int GetMode2() const
Gets the id of the dst mode.
TAFltI(const TFltVecIter &HIter, TStr attribute, const TCrossNet *GraphPt)
void RemoveCrossNets(TModeNet &Result, TStrV &CrossNets)
TCrossNet(TInt MId1, TInt MId2, TInt LId)
TCrossEdge(const TCrossEdge &MultiEdge)
bool operator==(const TNodeI &NodeI) const
THash< TInt, TCrossNet >::TIter THashIter
TCrossEdgeI & operator++(int)
Increment iterator.
THash< TStr, TInt > CrossNameToIdH
Node/edge integer attribute iterator. Iterates through all nodes/edges for one integer attribute...
int AddNbrType(const TStr &CrossName, const bool sameMode, bool isDir)
int AddStrAttrE(const TStr &attr, TStr defaultValue=TStr::GetNullStr())
Adds a new Str edge attribute to the hashmap.
int GetModeNets()
Returns the number of modes in the multimodal network.
TInt GetDat() const
Returns an attribute of the node.
TAFltI EndEAFltI(const TStr &attr) const
Returns an iterator referring to the past-the-end edge's attribute.
bool operator<(const TCrossEdgeI &EdgeI) const
THash< TStr, TStr > StrDefaultsN
int AddFltAttrE(const TStr &attr, TFlt defaultValue=TFlt::Mn)
Adds a new Flt edge attribute to the hashmap.
Tests (at compile time) if the graph is a multigraph with multiple edges between the same nodes...
Node/edge string attribute iterator. Iterates through all nodes/edges for one string attribute...
int DelNbrType(const TStr &CrossName)
TStr GetModeName(const TInt &ModeId) const
Gets the mode name from the mode id.
TNodeI BegMMNI() const
Returns an iterator referring to the first node in the graph.
bool operator<(const TAFltI &I) const
bool EdgeAttrIsIntDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
bool EdgeAttrIsFltDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
TCrossNetI & operator=(const TCrossNetI &CrossNetI)
TModeNetI EndModeNetI() const
void Clr()
Deletes all nodes and edges from the graph.
TStr GetCrossName(const TInt &CrossId) const
Gets the crossnet name from the crossnet id.
int GetDstNId() const
Returns the destination of the edge.
void LoadShM(TShMIn &ShMIn)
Loads graph from shared memory.
PNEANetMP ToNetworkMP(TStrV &CrossNetNames)
TVec< TVec< TIntV > > VecOfIntVecVecsE
TStr GetDat() const
Returns an attribute of the node.
THash< TStr, TInt > IntDefaultsE
bool IsIntAttrDeletedE(const int &EId, const TStr &attr) const
int AddNodeAttributes(PNEANet &NewNet, TModeNet &Net, TVec< TPair< TStr, TStr > > &Attrs, int ModeId, int oldId, int NId)
int GetCrossId()
Gets the crossnet id.
Directed multigraph with node edge attributes.
The nodes of one particular mode in a TMMNet, and their neighbor vectors as TIntV attributes...
void LoadNetworkShM(TShMIn &ShMIn)
load network from shared memory for this network
void Save(TSOut &SOut) const
Saves the TMMNet to binary stream.
TMMNet(const TMMNet &OtherTMMNet)
THash< TInt, TCrossEdge >::TIter THashIter
TModeNetI & operator=(const TModeNetI &ModeNetI)
void ClrNbr(const TStr &CrossNetName, const bool &outEdge, const bool &sameMode, bool &isDir)
void operator()(TModeNet *Node, TShMIn &ShMIn)
TVal * TIter
Random access iterator to TVal.
THash< TInt, TModeNet > TModeNetH
Keeps track of the max crossnet id.
TNodeI & operator++(int)
Increments the iterator.
bool operator==(const TCrossNetI &CrossNetI) const
int GetKeyId(const TKey &Key) const
static PMMNet LoadShM(TShMIn &ShMIn)
Loads network from mmapped shared memory.
void AttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of attr names for edge EId.
void Save(TSOut &SOut) const
Saves the TCrossNet to the binary stream.
TModeNet(const TModeNet &Graph, bool isSubModeGraph)
void SetParentPointer(TMMNet *parent)
THash< TStr, TBool > NeighborTypes
void IntAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for edge EId.
TCrossNetI & operator++(int)
Increments iterator.
TModeNetI BegModeNetI() const
void LoadShM(TShMIn &ShMIn)
Constructs the vector from a shared memory input.
void Save(TSOut &SOut) const
int GetEdges() const
Returns the number of edges in the graph.
TModeNet & GetModeNetById(const TInt &ModeId) const
bool IsDirected() const
Returns whether the edge is directed.
TModeNetI & operator++(int)
Increment iterator.
THash< TStr, TStr > StrDefaultsE
size_t GetMemUsed() const
int AddEdge(const int &sourceNId, const int &destNId, int EId=-1)
Adds an edge to the CrossNet; Mode1 NId should be the sourceNId always, regardless of whether edge is...
void GetKeyV(TVec< TKey > &KeyV) const
TFlt GetFltAttrDatE(const TCrossEdgeI &EdgeI, const TStr &attr)
Gets the value of flt attr from the edge attr value vector.
TModeNet(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. Expects data structures for sparse attributes.
TAStrI & operator=(const TAStrI &I)
bool IsStrAttrDeletedE(const int &EId, const TStr &attr) const
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
TInt Mode2
The first mode. In the case of directed crossnets, this is implicitly understood to be the source mod...
TVec< TFltV > VecOfFltVecsN
TNodeI(const THashIter &NodeHIter, const TModeNet *GraphPt)
TCrossEdgeI GetEdgeI(const int &EId) const
Edge iterators.
int GetCrossId(const TStr &CrossName) const
Gets the crossnet id from the crossnet name.
bool operator<(const TModeNetI &ModeNetI) const
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
int GetMode1() const
Gets the id of the src mode.
TStr GetNeighborCrossName(const TStr &CrossName, bool isOutEdge, const bool sameMode, bool isDir) const
TBool IsDirect
The second mode. In the case of directed crossnets, this is implicitly understood to be the destinati...
THash< TStr, TInt > IntDefaultsN
void operator()(TCrossNet *Node, TShMIn &ShMIn)
TAIntI(const TIntVecIter &HIter, TStr attribute, const TCrossNet *GraphPt)
TAIntI & operator=(const TAIntI &I)
bool IsAttrDeletedE(const int &EId, const TStr &attr) const
THash< TInt, TNode > NodeH
int DelAttrE(const TStr &attr)
Removes all the values for edge attr.
TModeNetI(const TModeNetI &ModeNetI)
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
TVec< TVec< TIntV > > VecOfIntVecVecsN
int AddMode(const TStr &ModeName, const TInt &ModeId, const TModeNet &ModeNet)
int AddIntAttrE(const TStr &attr, TInt defaultValue=TInt::Mn)
Adds a new Int edge attribute to the hashmap.
TVec< TFltV > VecOfFltVecsE
TInt MxEId
The HashTable from Edge id to the corresponding Edge.
void ClrNbr(const TInt &ModeId, const TInt &CrossNetId, const bool &outEdge, const bool &sameMode, bool &isDir)
TStr GetEdgeAttrValue(const int &EId, const TStrIntPrH::TIter &CrossHI) const
TCrossNet & GetCrossNetByName(const TStr &CrossName) const
Gets a reference to the crossnet.
bool IsKey(const TKey &Key) const
int AddEdgeAttributes(PNEANet &NewNet, TCrossNet &Net, TVec< TPair< TStr, TStr > > &Attrs, int CrossId, int oldId, int EId)
void Save(TSOut &SOut) const
Saves the graph to a (binary) stream SOut.
TStr GetModeName()
Gets the name of the mode.
TInt MxCrossNetId
Keeps track of the max mode id.
TNodeI(const TNodeI &NodeI)
THash< TInt, TCrossEdge > CrossH
TIter GetI(const TSizeTy &ValN) const
Returns an iterator an element at position ValN.
TCrossNet & GetCrossNetById(const TInt &CrossId) const
TInt GetIntAttrDatE(const TCrossEdgeI &EdgeI, const TStr &attr)
Gets the value of int attr from the edge attr value vector.
bool IsDirected() const
Whether edges in the crossnet are directed.
TCrossNetI(const THashIter &CrossNetHIter, const TMMNet *GraphPt)
PMMNet GetSubgraphByModeNet(TStrV &ModeNetTypes)
Gets the induced subgraph given a vector of mode type names.
THash< TStr, TBool > KeyToDenseN
KeyToDense[N|E]: Key->(True if Vec, False if Hash)
TCrossEdgeI(const THashIter &CrossHIter, const TCrossNet *GraphPt)
TModeNet & GetModeNetByName(const TStr &ModeName) const
Gets a reference to the modenet.
TCrossNet & operator=(const TCrossNet &OtherTCrossNet)
void Clr()
Deletes all nodes from this mode and edges from associated crossnets.
int GetAttrTypeN(const TStr &attr) const
void SetParentPointer(TMMNet *parent)
void StrAttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for node NId.
int GetAttrTypeE(const TStr &attr) const
TStr GetStrAttrDefaultE(const TStr &attribute) const
Gets Str edge attribute val. If not a proper attr, return default.
int GetDstModeId() const
Returns the destination mode of the crossnet.
THash< TInt, TStr > CrossIdToNameH
TIter GetI(const TKey &Key) const
Implements a single CrossNet consisting of edges between two TModeNets (could be the same TModeNet) ...
int AddNeighbor(const int &NId, const int &EId, const bool outEdge, const int linkId, const bool sameMode, bool isDir)