SNAP Library 6.0, Developer Reference
2020-12-09 16:24:20
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
Multimodal networks. More...
#include <mmnet.h>
Classes | |
class | TCrossNetI |
TCrossNet iterator. Only forward iteration (operator++) is supported. More... | |
class | TCrossNetInit |
class | TModeNetI |
TModeNet iterator. Only forward iteration (operator++) is supported. More... | |
class | TModeNetInit |
Public Member Functions | |
TMMNet () | |
TMMNet (const TMMNet &OtherTMMNet) | |
TMMNet (TSIn &SIn) | |
int | AddModeNet (const TStr &ModeName) |
Adds a mode to the multimodal network. More... | |
int | DelModeNet (const TInt &ModeId) |
Deletes a mode from the multimodal network. More... | |
int | DelModeNet (const TStr &ModeName) |
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. More... | |
int | AddCrossNet (const TInt &ModeId1, const TInt &ModeId2, const TStr &CrossNetName, bool isDir=true) |
int | DelCrossNet (const TInt &CrossNetId) |
Deletes a crossnet from the multimodal network. More... | |
int | DelCrossNet (const TStr &CrossNet) |
void | Save (TSOut &SOut) const |
Saves the TMMNet to binary stream. More... | |
void | ConvertToSparse () |
int | GetModeId (const TStr &ModeName) const |
Gets the mode id from the mode name. More... | |
TStr | GetModeName (const TInt &ModeId) const |
Gets the mode name from the mode id. More... | |
int | GetCrossId (const TStr &CrossName) const |
Gets the crossnet id from the crossnet name. More... | |
TStr | GetCrossName (const TInt &CrossId) const |
Gets the crossnet name from the crossnet id. More... | |
TModeNet & | GetModeNetByName (const TStr &ModeName) const |
Gets a reference to the modenet. More... | |
TModeNet & | GetModeNetById (const TInt &ModeId) const |
TCrossNet & | GetCrossNetByName (const TStr &CrossName) const |
Gets a reference to the crossnet. More... | |
TCrossNet & | GetCrossNetById (const TInt &CrossId) const |
TCrossNetI | GetCrossNetI (const int &Id) const |
Iterator over all crossnets. More... | |
TCrossNetI | BegCrossNetI () const |
TCrossNetI | EndCrossNetI () const |
TModeNetI | GetModeNetI (const int &Id) const |
Iterator over all modenets. More... | |
TModeNetI | BegModeNetI () const |
TModeNetI | EndModeNetI () const |
int | GetModeNets () |
Returns the number of modes in the multimodal network. More... | |
int | GetCrossNets () |
Returns the number of crossnets in the multimodal network. More... | |
PMMNet | GetSubgraphByCrossNet (TStrV &CrossNetTypes) |
Gets the induced subgraph given a vector of crossnet type names. More... | |
PMMNet | GetSubgraphByModeNet (TStrV &ModeNetTypes) |
Gets the induced subgraph given a vector of mode type names. More... | |
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 Id, old att name, new attr name) More... | |
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 Id -> vec of pairs (old att name, new attr name) More... | |
PNEANetMP | ToNetworkMP (TStrV &CrossNetNames) |
Static Public Member Functions | |
static PMMNet | Load (TSIn &SIn) |
Loads the TMMNet from binary stream. More... | |
static PMMNet | LoadShM (TShMIn &ShMIn) |
Loads network from mmapped shared memory. More... | |
static PMMNet | New () |
Public Attributes | |
TCRef | CRef |
Private Member Functions | |
void | LoadNetworkShM (TShMIn &ShMIn) |
void | ClrNbr (const TInt &ModeId, const TInt &CrossNetId, const bool &outEdge, const bool &sameMode, bool &isDir) |
int | AddMode (const TStr &ModeName, const TInt &ModeId, const TModeNet &ModeNet) |
int | AddCrossNet (const TStr &CrossNetName, const TInt &CrossNetId, const TCrossNet &CrossNet) |
int | AddNodeAttributes (PNEANet &NewNet, TModeNet &Net, TVec< TPair< TStr, TStr > > &Attrs, int ModeId, int oldId, int NId) |
int | AddEdgeAttributes (PNEANet &NewNet, TCrossNet &Net, TVec< TPair< TStr, TStr > > &Attrs, int CrossId, int oldId, int EId) |
void | GetPartitionRanges (TIntPrV &Partitions, const TInt &NumPartitions, const TInt &MxVal) const |
Private Attributes | |
TInt | MxModeId |
TInt | MxCrossNetId |
Keeps track of the max mode id. More... | |
THash< TInt, TModeNet > | TModeNetH |
Keeps track of the max crossnet id. More... | |
THash< TInt, TCrossNet > | TCrossNetH |
THash< TInt, TStr > | ModeIdToNameH |
THash< TStr, TInt > | ModeNameToIdH |
THash< TInt, TStr > | CrossIdToNameH |
THash< TStr, TInt > | CrossNameToIdH |
Friends | |
class | TCrossNet |
class | TModeNet |
Multimodal networks.
Represents a multimodal network. A mutimodal network is represented by composing TModeNets (disjoint sets of nodes) and TCrossNets (disjoint sets of edges that connect nodes in two TModeNets). TMMNet contains methods to create TModeNets and TCrossNets by name, and returns pointers to them. All operations more granular than this, like adding nodes and edges, are run directly using methods provided in the ModeNets and CrossNets.
|
inline |
Definition at line 590 of file mmnet.h.
Referenced by Load(), LoadShM(), and New().
|
inline |
Definition at line 591 of file mmnet.h.
|
inline |
Definition at line 593 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::BegI(), THash< TKey, TDat, THashFunc >::EndI(), and THash< TKey, TDat, THashFunc >::GetDat().
int TMMNet::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.
Definition at line 683 of file mmnet.cpp.
References GetModeId().
int TMMNet::AddCrossNet | ( | const TInt & | ModeId1, |
const TInt & | ModeId2, | ||
const TStr & | CrossNetName, | ||
bool | isDir = true |
||
) |
Definition at line 689 of file mmnet.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), TModeNet::AddNbrType(), CrossIdToNameH, CrossNameToIdH, THash< TKey, TDat, THashFunc >::GetDat(), THash< TKey, TDat, THashFunc >::IsKey(), MxCrossNetId, TCrossNet::SetParentPointer(), TCrossNet, TCrossNetH, and TModeNetH.
|
private |
Definition at line 777 of file mmnet.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), CrossIdToNameH, CrossNameToIdH, and TCrossNetH.
|
private |
Definition at line 1341 of file mmnet.cpp.
References TCrossNet::FltType, TCrossNet::GetAttrTypeE(), TCrossNet::GetFltAttrDatE(), TCrossNet::GetIntAttrDatE(), TCrossNet::GetStrAttrDatE(), TCrossNet::IntType, and TCrossNet::StrType.
Referenced by ToNetwork2().
|
private |
Definition at line 768 of file mmnet.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), ModeIdToNameH, ModeNameToIdH, and TModeNetH.
int TMMNet::AddModeNet | ( | const TStr & | ModeName | ) |
Adds a mode to the multimodal network.
Definition at line 668 of file mmnet.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), THash< TKey, TDat, THashFunc >::IsKey(), ModeIdToNameH, ModeNameToIdH, MxModeId, TModeNet::SetParentPointer(), and TModeNetH.
|
private |
Definition at line 1314 of file mmnet.cpp.
References TNEANet::FltType, TModeNet::GetAttrTypeN(), TNEANet::GetFltAttrDatN(), TNEANet::GetIntAttrDatN(), TNEANet::GetIntVAttrDatN(), TNEANet::GetStrAttrDatN(), TNEANet::IntType, TNEANet::IntVType, and TNEANet::StrType.
Referenced by ToNetwork2().
|
inline |
Definition at line 652 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::BegI().
|
inline |
Definition at line 657 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::BegI().
|
private |
Definition at line 786 of file mmnet.cpp.
References CrossIdToNameH, and TModeNetH.
Referenced by TCrossNet::Clr().
|
inline |
Definition at line 627 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::BegI(), and THash< TKey, TDat, THashFunc >::EndI().
int TMMNet::DelCrossNet | ( | const TInt & | CrossNetId | ) |
Deletes a crossnet from the multimodal network.
Definition at line 708 of file mmnet.cpp.
References CrossIdToNameH, and THash< TKey, TDat, THashFunc >::GetDat().
Referenced by DelModeNet().
int TMMNet::DelCrossNet | ( | const TStr & | CrossNet | ) |
Definition at line 712 of file mmnet.cpp.
References CrossIdToNameH, CrossNameToIdH, TStr::CStr(), THash< TKey, TDat, THashFunc >::DelKey(), TStr::Fmt(), GetCrossNetById(), THash< TKey, TDat, THashFunc >::GetDat(), GetModeNetById(), IAssertR, THash< TKey, TDat, THashFunc >::IsKey(), TCrossNet::Mode1, TCrossNet::Mode2, TCrossNet::SetParentPointer(), and TCrossNetH.
int TMMNet::DelModeNet | ( | const TInt & | ModeId | ) |
Deletes a mode from the multimodal network.
Definition at line 727 of file mmnet.cpp.
References DelCrossNet(), THash< TKey, TDat, THashFunc >::DelKey(), TModeNet::GetCrossNetNames(), THash< TKey, TDat, THashFunc >::GetDat(), GetModeNetById(), TVec< TVal, TSizeTy >::Len(), ModeIdToNameH, ModeNameToIdH, TModeNet::SetParentPointer(), and TModeNetH.
Referenced by DelModeNet().
int TMMNet::DelModeNet | ( | const TStr & | ModeName | ) |
Definition at line 743 of file mmnet.cpp.
References TStr::CStr(), DelModeNet(), TStr::Fmt(), THash< TKey, TDat, THashFunc >::GetDat(), IAssertR, THash< TKey, TDat, THashFunc >::IsKey(), and ModeNameToIdH.
|
inline |
Definition at line 653 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::EndI().
|
inline |
Definition at line 658 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::EndI().
|
inline |
Gets the crossnet id from the crossnet name.
Definition at line 638 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::GetDat(), and THash< TKey, TDat, THashFunc >::IsKey().
Referenced by ToNetworkMP().
Gets the crossnet name from the crossnet id.
Definition at line 640 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::GetDat(), TStr::GetNullStr(), and THash< TKey, TDat, THashFunc >::IsKey().
Referenced by TCrossNet::AddEdge(), TModeNet::AddNeighbor(), TCrossNet::DelEdge(), TModeNet::DelNeighbor(), and TMMNet::TCrossNetI::GetCrossName().
Definition at line 762 of file mmnet.cpp.
Referenced by DelCrossNet(), TMMNet::TCrossNetI::GetCrossNet(), GetCrossNetByName(), ToNetwork(), and ToNetwork2().
Gets a reference to the crossnet.
Definition at line 758 of file mmnet.cpp.
References CrossNameToIdH, GetCrossNetById(), and THash< TKey, TDat, THashFunc >::GetDat().
Referenced by TModeNet::Clr(), TModeNet::DelNode(), and ToNetworkMP().
|
inline |
Iterator over all crossnets.
Definition at line 651 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::GetI().
|
inline |
Returns the number of crossnets in the multimodal network.
Definition at line 663 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::Len().
|
inline |
Gets the mode id from the mode name.
Definition at line 634 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::GetDat(), and THash< TKey, TDat, THashFunc >::IsKey().
Referenced by AddCrossNet().
Gets the mode name from the mode id.
Definition at line 636 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::GetDat(), TStr::GetNullStr(), and THash< TKey, TDat, THashFunc >::IsKey().
Referenced by TMMNet::TModeNetI::GetModeName().
Definition at line 753 of file mmnet.cpp.
Referenced by DelCrossNet(), TCrossNet::DelEdge(), DelModeNet(), TMMNet::TModeNetI::GetModeNet(), GetModeNetByName(), ToNetwork(), ToNetwork2(), and ToNetworkMP().
Gets a reference to the modenet.
Definition at line 748 of file mmnet.cpp.
References THash< TKey, TDat, THashFunc >::GetDat(), GetModeNetById(), and ModeNameToIdH.
|
inline |
Iterator over all modenets.
Definition at line 656 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::GetI().
|
inline |
Returns the number of modes in the multimodal network.
Definition at line 661 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::Len().
|
private |
Definition at line 1115 of file mmnet.cpp.
References TVec< TVal, TSizeTy >::Add().
Referenced by ToNetworkMP().
Gets the induced subgraph given a vector of crossnet type names.
Definition at line 791 of file mmnet.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), THash< TKey, TDat, THashFunc >::BegI(), CrossNameToIdH, THash< TKey, TDat, THashFunc >::EndI(), THash< TKey, TDat, THashFunc >::GetDat(), THash< TKey, TDat, THashFunc >::IsKey(), TVec< TVal, TSizeTy >::Len(), TModeNet::ModeId, ModeIdToNameH, New(), TCrossNetH, and TModeNetH.
Referenced by GetSubgraphByModeNet().
Gets the induced subgraph given a vector of mode type names.
Definition at line 834 of file mmnet.cpp.
References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::AddDat(), THash< TKey, TDat, THashFunc >::BegI(), CrossIdToNameH, THash< TKey, TDat, THashFunc >::EndI(), THash< TKey, TDat, THashFunc >::GetDat(), GetSubgraphByCrossNet(), THash< TKey, TDat, THashFunc >::IsKey(), TVec< TVal, TSizeTy >::Len(), TCrossNet::Mode1, TCrossNet::Mode2, TModeNet::ModeId, ModeIdToNameH, ModeNameToIdH, TCrossNetH, and TModeNetH.
|
private |
Definition at line 649 of file mmnet.cpp.
References THash< TKey, TDat, THashFunc >::BegI(), CrossIdToNameH, CrossNameToIdH, THash< TKey, TDat, THashFunc >::EndI(), THash< TKey, TDat, THashFunc >::LoadShM(), ModeIdToNameH, ModeNameToIdH, MxCrossNetId, MxModeId, TCrossNetH, and TModeNetH.
Referenced by LoadShM().
Loads network from mmapped shared memory.
Definition at line 620 of file mmnet.h.
References LoadNetworkShM(), and TMMNet().
|
inlinestatic |
Definition at line 625 of file mmnet.h.
References TMMNet().
Referenced by GetSubgraphByCrossNet().
|
inline |
Saves the TMMNet to binary stream.
Definition at line 614 of file mmnet.h.
References THash< TKey, TDat, THashFunc >::Save(), and TInt::Save().
PNEANet TMMNet::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 Id, old att name, new attr name)
Definition at line 866 of file mmnet.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), THashSet< TKey, THashFunc >::AddKey(), TCrossNet::BegEdgeI(), THash< TKey, TDat, THashFunc >::BegI(), THashSet< TKey, THashFunc >::BegI(), TModeNet::BegMMNI(), TCrossNet::EndEdgeI(), THash< TKey, TDat, THashFunc >::EndI(), THashSet< TKey, THashFunc >::EndI(), TModeNet::EndMMNI(), TCrossNet::FltType, TNEANet::FltType, TCrossNet::GetAttrTypeE(), TModeNet::GetAttrTypeN(), GetCrossNetById(), THash< TKey, TDat, THashFunc >::GetDat(), TCrossNet::GetFltAttrDatE(), TNEANet::GetFltAttrDatN(), TCrossNet::GetFltAttrDefaultE(), TNEANet::GetFltAttrDefaultN(), TCrossNet::GetIntAttrDatE(), TNEANet::GetIntAttrDatN(), TCrossNet::GetIntAttrDefaultE(), TNEANet::GetIntAttrDefaultN(), TNEANet::GetIntVAttrDatN(), TCrossNet::GetMode1(), TCrossNet::GetMode2(), GetModeNetById(), TCrossNet::GetStrAttrDatE(), TNEANet::GetStrAttrDatN(), TCrossNet::GetStrAttrDefaultE(), TNEANet::GetStrAttrDefaultN(), TCrossNet::IntType, TNEANet::IntType, TNEANet::IntVType, TCrossNet::IsDirected(), THash< TKey, TDat, THashFunc >::IsKey(), TVec< TVal, TSizeTy >::Len(), TNEANet::New(), TCrossNet::StrType, and TNEANet::StrType.
PNEANet TMMNet::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 Id -> vec of pairs (old att name, new attr name)
Definition at line 1028 of file mmnet.cpp.
References THash< TKey, TDat, THashFunc >::AddDat(), AddEdgeAttributes(), THashSet< TKey, THashFunc >::AddKey(), AddNodeAttributes(), TCrossNet::BegEdgeI(), THashSet< TKey, THashFunc >::BegI(), TModeNet::BegMMNI(), TCrossNet::EndEdgeI(), THashSet< TKey, THashFunc >::EndI(), TModeNet::EndMMNI(), GetCrossNetById(), THash< TKey, TDat, THashFunc >::GetDat(), TVec< TVal, TSizeTy >::GetDat(), TCrossNet::GetMode1(), TCrossNet::GetMode2(), GetModeNetById(), TCrossNet::IsDirected(), THash< TKey, TDat, THashFunc >::IsKey(), TVec< TVal, TSizeTy >::Len(), and TNEANet::New().
Definition at line 1136 of file mmnet.cpp.
References TVec< TVal, TSizeTy >::Add(), THashMP< TKey, TDat, THashFunc >::AddDat(), THash< TKey, TDat, THashFunc >::AddDat(), THashSet< TKey, THashFunc >::AddKey(), TVec< TVal, TSizeTy >::AddV(), THashSet< TKey, THashFunc >::BegI(), edge, THashSet< TKey, THashFunc >::EndI(), GetCrossId(), GetCrossNetByName(), THashMP< TKey, TDat, THashFunc >::GetDat(), THash< TKey, TDat, THashFunc >::GetDat(), TCrossNet::TCrossEdgeI::GetDstNId(), TCrossNet::GetEdge(), TCrossNet::GetEdgeI(), TCrossNet::GetEdges(), THashMP< TKey, TDat, THashFunc >::GetKeyV(), THash< TKey, TDat, THashFunc >::GetKeyV(), TCrossNet::GetMode1(), TCrossNet::GetMode2(), GetModeNetById(), TCrossNet::GetMxEId(), TModeNet::GetNeighborsByCrossNet(), TNEANet::GetNodes(), GetPartitionRanges(), TCrossNet::TCrossEdge::GetSrcNId(), TCrossNet::TCrossEdgeI::GetSrcNId(), TPair< TVal1, TVal2 >::GetVal1(), TPair< TVal1, TVal2 >::GetVal2(), TCrossNet::IsDirected(), TCrossNet::IsEdge(), THash< TKey, TDat, THashFunc >::IsKey(), TNEANet::IsNode(), TVec< TVal, TSizeTy >::Len(), TCrossNet::MxEId, TModeNet::NeighborTypes, TNEANetMP::New(), and TNEANet::NodeH.
|
friend |
Definition at line 572 of file mmnet.h.
Referenced by AddCrossNet().
Definition at line 568 of file mmnet.h.
Referenced by AddCrossNet(), ClrNbr(), DelCrossNet(), GetSubgraphByModeNet(), and LoadNetworkShM().
Definition at line 569 of file mmnet.h.
Referenced by AddCrossNet(), DelCrossNet(), GetCrossNetByName(), GetSubgraphByCrossNet(), and LoadNetworkShM().
Definition at line 565 of file mmnet.h.
Referenced by AddMode(), AddModeNet(), DelModeNet(), GetSubgraphByCrossNet(), GetSubgraphByModeNet(), and LoadNetworkShM().
Definition at line 566 of file mmnet.h.
Referenced by AddMode(), AddModeNet(), DelModeNet(), GetModeNetByName(), GetSubgraphByModeNet(), and LoadNetworkShM().
|
private |
Keeps track of the max mode id.
Definition at line 561 of file mmnet.h.
Referenced by AddCrossNet(), and LoadNetworkShM().
|
private |
Definition at line 560 of file mmnet.h.
Referenced by AddModeNet(), and LoadNetworkShM().
Definition at line 563 of file mmnet.h.
Referenced by AddCrossNet(), DelCrossNet(), GetSubgraphByCrossNet(), GetSubgraphByModeNet(), and LoadNetworkShM().
Keeps track of the max crossnet id.
Definition at line 562 of file mmnet.h.
Referenced by AddCrossNet(), TCrossNet::AddEdge(), AddMode(), AddModeNet(), ClrNbr(), DelModeNet(), GetSubgraphByCrossNet(), GetSubgraphByModeNet(), and LoadNetworkShM().