5 if (!isDir || !sameMode) {
return Cpy; }
32 for (
int i=0; i < CNets.
Len(); i++) {
38 int TModeNet::AddNeighbor(
const int& NId,
const int& EId,
bool outEdge,
const int linkId,
const bool sameMode,
bool isDir){
40 return AddNeighbor(NId, EId, outEdge, CrossName, sameMode, isDir);
61 return DelNeighbor(NId, EId, outEdge, CrossName, sameMode, isDir);
67 for (
int i=0; i < Names.
Len(); i++) {
71 for (
int j=0; j < OutEIds.
Len(); j++) {
77 for (
int j=0; j < InEIds.
Len(); j++) {
92 bool hasSingleVector = (!isDir || !sameMode);
101 if (hasSingleVector) {
116 if (hasSingleVector) {
136 for (
int i=0; i< Attrs.
Len(); i++) {
137 NewHash.
AddDat(i, Attrs[i]);
150 for (
int i=0; i< Attrs.
Len(); i++) {
151 NewHash.
AddDat(i, Attrs[i]);
161 TStr AttrName = it.GetKey();
162 TInt AttrType = it.GetDat().GetVal1();
163 TInt AttrIndex = it.GetDat().GetVal2();
167 TStr WithoutSuffix = AttrName;
168 bool removeSuffix =
false;
170 WithoutSuffix = AttrName.
GetSubStr(0, AttrName.
Len()-5);
175 if (isSingleVNbrAttr || isMultiVNbrAttr) {
176 TStr NbrName = isSingleVNbrAttr ? AttrName : WithoutSuffix;
177 if (CrossNets.
IsIn(NbrName)) {
178 Result.
AddNbrType(NbrName, removeSuffix, removeSuffix);
239 if (!M1.
IsNode(sourceNId) || !M2.
IsNode(destNId)) {
return -1; }
251 if (IntVec.
Len() > KeyId) {
259 for (i = 0; i < DefIntVec.
Len(); i++) {
260 TStr attr = DefIntVec[i];
268 if (StrVec.
Len() > KeyId) {
276 for (i = 0; i < DefStrVec.
Len(); i++) {
277 TStr attr = DefStrVec[i];
285 if (FltVec.
Len() > KeyId) {
293 for (i = 0; i < DefFltVec.
Len(); i++) {
294 TStr attr = DefFltVec[i];
303 int srcNode = Edge.
SrcNId;
304 int dstNode = Edge.
DstNId;
331 while (!CrossHI.
IsEnd()) {
341 while (!CrossHI.
IsEnd()) {
351 while (!CrossHI.
IsEnd()) {
361 while (!CrossHI.
IsEnd()) {
372 while (!CrossHI.
IsEnd()) {
382 while (!CrossHI.
IsEnd()) {
393 while (!CrossHI.
IsEnd()) {
403 while (!CrossHI.
IsEnd()) {
416 return IntDel || StrDel || FltDel;
435 return IntDel || StrDel || FltDel;
484 for (i = 0; i <
MxEId; i++) {
507 for (i = 0; i <
MxEId; i++) {
531 for (i = 0; i <
MxEId; i++) {
557 }
else if (vecType ==
StrType) {
559 }
else if (vecType ==
FltType) {
575 for (i = 0; i <
MxEId; i++) {
576 NewVec.
Ins(i, defaultValue);
594 for (i = 0; i <
MxEId; i++) {
595 NewVec.
Ins(i, defaultValue);
613 for (i = 0; i <
MxEId; i++) {
614 NewVec.
Ins(i, defaultValue);
632 }
else if (vecType ==
StrType) {
637 }
else if (vecType ==
FltType) {
661 it.GetDat().SetParentPointer(
this);
664 it.GetDat().SetParentPointer(
this);
686 return AddCrossNet(ModeId1, ModeId2, CrossNetName, isDir);
730 for (
int i = 0; i < CrossNets.
Len(); i++) {
755 TModeNet &Net = (
const_cast<TMMNet *
>(
this))->TModeNetH.GetDat(ModeId);
764 TCrossNet& CrossNet = (
const_cast<TMMNet *
>(
this))->TCrossNetH.GetDat(CrossId);
773 TModeNetH[ModeId].SetParentPointer(
this);
782 TCrossNetH[CrossNetId].SetParentPointer(
this);
786 void TMMNet::ClrNbr(
const TInt& ModeId,
const TInt& CrossNetId,
const bool& outEdge,
const bool& sameMode,
bool& isDir) {
788 TModeNetH[ModeId].ClrNbr(CrossNetName, outEdge, sameMode, isDir);
796 for(
int i = 0; i < CrossNetTypes.
Len(); i++) {
797 TStr CrossName = CrossNetTypes[i];
799 TInt NewId = MxCross++;
801 TInt OldModeId1 = NewCrossNet.Mode1;
802 TInt OldModeId2 = NewCrossNet.Mode2;
803 TInt NewModeId1, NewModeId2;
804 if (ModeH.
IsKey(OldModeId1)) {
805 NewModeId1 = ModeH.
GetDat(OldModeId1);
807 NewModeId1 = MxMode++;
808 ModeH.
AddDat(OldModeId1, NewModeId1);
810 if (ModeH.
IsKey(OldModeId2)) {
811 NewModeId2 = ModeH.
GetDat(OldModeId2);
813 NewModeId2 = MxMode++;
814 ModeH.
AddDat(OldModeId2, NewModeId2);
816 NewCrossNet.Mode1 = NewModeId1;
817 NewCrossNet.Mode2 = NewModeId2;
818 NewCrossNet.CrossNetId = NewId;
819 Result->AddCrossNet(CrossName, NewId, NewCrossNet);
823 TInt NewModeId = it.GetDat();
825 TModeNetH.
GetDat(it.GetKey()).RemoveCrossNets(NewModeNet, CrossNetTypes);
826 NewModeNet.
ModeId = NewModeId;
827 Result->AddMode(ModeName, NewModeId, NewModeNet);
829 Result->MxModeId = MxMode;
830 Result->MxCrossNetId = MxCross;
836 for (
int i = 0; i < ModeNetTypes.
Len(); i++) {
844 ModeTypeIds[CrossNet.
Mode1] =
false;
845 ModeTypeIds[CrossNet.
Mode2] =
false;
850 TInt MxMode = Result->MxModeId;
851 TStrV EmptyCrossNetTypes;
853 if (it.GetDat().Val) {
855 TInt NewModeId = MxMode++;
857 TModeNetH.
GetDat(it.GetKey()).RemoveCrossNets(NewModeNet, EmptyCrossNetTypes);
858 NewModeNet.
ModeId = NewModeId;
859 Result->AddMode(ModeName, NewModeId, NewModeNet);
862 Result->MxModeId = MxMode;
872 for (
int i = 0; i < CrossNetTypes.
Len(); i++) {
880 int srcNode = EdgeI.GetSrcNId();
881 int dstNode = EdgeI.GetDstNId();
882 TIntPr SrcNodeMapping(Mode1, srcNode);
884 if (NodeMap.
IsKey(SrcNodeMapping)) {
885 srcId = NodeMap.
GetDat(SrcNodeMapping);
887 srcId = NewNet->AddNode();
888 NodeMap.
AddDat(SrcNodeMapping, srcId);
890 TIntPr DstNodeMapping(Mode2, dstNode);
892 if (NodeMap.
IsKey(DstNodeMapping)) {
893 dstId = NodeMap.
GetDat(DstNodeMapping);
895 dstId = NewNet->AddNode();
896 NodeMap.
AddDat(DstNodeMapping, dstId);
898 int edgeId = EdgeI.GetId();
899 TIntPr EdgeMapping(CrossNetTypes[i], edgeId);
900 int newEId = NewNet->AddEdge(srcId, dstId);
903 otherEId = NewNet->AddEdge(dstId, srcId);
911 TInt ModeId = it.GetKey();
913 TIntPr NodeKey(ModeId, NodeIt.GetId());
914 if (!NodeMap.
IsKey(NodeKey)) {
915 int newId = NewNet->AddNode();
916 NodeMap.
AddDat(NodeKey, newId);
922 NewNet->AddIntAttrN(
TStr(
"Mode"));
923 NewNet->AddIntAttrN(
TStr(
"Id"));
924 NewNet->AddIntAttrE(
TStr(
"CrossNet"));
925 NewNet->AddIntAttrE(
TStr(
"Id"));
927 NewNet->AddIntAttrDatN(it.GetDat(), it.GetKey().GetVal1(),
TStr(
"Mode"));
928 NewNet->AddIntAttrDatN(it.GetDat(), it.GetKey().GetVal2(),
TStr(
"Id"));
931 NewNet->AddIntAttrDatE(it.GetDat().GetVal1(), it.GetKey().GetVal1(),
TStr(
"CrossNet"));
932 NewNet->AddIntAttrDatE(it.GetDat().GetVal1(), it.GetKey().GetVal2(),
TStr(
"Id"));
933 if (it.GetDat().GetVal2() != -1) {
934 NewNet->AddIntAttrDatE(it.GetDat().GetVal2(), it.GetKey().GetVal1(),
TStr(
"CrossNet"));
935 NewNet->AddIntAttrDatE(it.GetDat().GetVal2(), it.GetKey().GetVal2(),
TStr(
"Id"));
939 for (
int i = 0; i < NodeAttrMap.
Len(); i++) {
941 TInt ModeId = NodeAttrMap[i].Val1;
942 TStr OrigAttr = NodeAttrMap[i].Val2;
943 TStr NewAttr = NodeAttrMap[i].Val3;
949 TIntPr OldNId(ModeId, it.GetId());
950 int NewId = NodeMap.
GetDat(OldNId);
952 NewNet->AddIntAttrDatN(NewId, Val, NewAttr);
957 TIntPr OldNId(ModeId, it.GetId());
958 int NewId = NodeMap.
GetDat(OldNId);
960 NewNet->AddFltAttrDatN(NewId, Val, NewAttr);
966 TIntPr OldNId(ModeId, it.GetId());
967 int NewId = NodeMap.
GetDat(OldNId);
969 NewNet->AddStrAttrDatN(NewId, Val, NewAttr);
972 NewNet->AddIntVAttrN(NewAttr);
974 TIntPr OldNId(ModeId, it.GetId());
975 int NewId = NodeMap.
GetDat(OldNId);
977 NewNet->AddIntVAttrDatN(NewId, Val, NewAttr);
982 for (
int i = 0; i < EdgeAttrMap.Len(); i++) {
984 TInt CrossId = EdgeAttrMap[i].Val1;
985 TStr OrigAttr = EdgeAttrMap[i].Val2;
986 TStr NewAttr = EdgeAttrMap[i].Val3;
992 TIntPr OldNId(CrossId, it.GetId());
995 NewNet->AddIntAttrDatE(NewId.Val1, Val, NewAttr);
996 if (NewId.Val2 != -1) {
997 NewNet->AddIntAttrDatE(NewId.Val2, Val, NewAttr);
1003 TIntPr OldNId(CrossId, it.GetId());
1006 NewNet->AddFltAttrDatE(NewId.Val1, Val, NewAttr);
1007 if (NewId.Val2 != -1) {
1008 NewNet->AddFltAttrDatE(NewId.Val2, Val, NewAttr);
1015 TIntPr OldNId(CrossId, it.GetId());
1018 NewNet->AddStrAttrDatE(NewId.Val1, Val, NewAttr);
1019 if (NewId.Val2 != -1) {
1020 NewNet->AddStrAttrDatE(NewId.Val2, Val, NewAttr);
1032 NewNet->AddIntAttrN(
TStr(
"Mode"));
1033 NewNet->AddIntAttrN(
TStr(
"Id"));
1034 NewNet->AddIntAttrE(
TStr(
"CrossNet"));
1035 NewNet->AddIntAttrE(
TStr(
"Id"));
1038 for (
int i = 0; i < CrossNetTypes.
Len(); i++) {
1041 if (EdgeAttrMap.IsKey(CrossNetTypes[i])) {
1042 CNetAttrs = EdgeAttrMap.
GetDat(CrossNetTypes[i]);
1049 if (NodeAttrMap.
IsKey(Mode1)) {
1050 Mode1Attrs = NodeAttrMap.
GetDat(Mode1);
1053 if (NodeAttrMap.
IsKey(Mode2)) {
1054 Mode2Attrs = NodeAttrMap.
GetDat(Mode2);
1060 int srcNode = EdgeI.GetSrcNId();
1061 int dstNode = EdgeI.GetDstNId();
1062 TIntPr SrcNodeMapping(Mode1, srcNode);
1064 if (NodeMap.
IsKey(SrcNodeMapping)) {
1065 srcId = NodeMap.
GetDat(SrcNodeMapping);
1067 srcId = NewNet->AddNode();
1068 NodeMap.
AddDat(SrcNodeMapping, srcId);
1069 NewNet->AddIntAttrDatN(srcId, srcNode,
TStr(
"Id"));
1070 NewNet->AddIntAttrDatN(srcId, Mode1,
TStr(
"Mode"));
1073 TIntPr DstNodeMapping(Mode2, dstNode);
1075 if (NodeMap.
IsKey(DstNodeMapping)) {
1076 dstId = NodeMap.
GetDat(DstNodeMapping);
1078 dstId = NewNet->AddNode();
1079 NodeMap.
AddDat(DstNodeMapping, dstId);
1080 NewNet->AddIntAttrDatN(dstId, dstNode,
TStr(
"Id"));
1081 NewNet->AddIntAttrDatN(dstId, Mode2,
TStr(
"Mode"));
1084 int edgeId = EdgeI.GetId();
1085 int newEId = NewNet->AddEdge(srcId, dstId);
1086 NewNet->AddIntAttrDatE(newEId, edgeId,
TStr(
"Id"));
1087 NewNet->AddIntAttrDatE(newEId, CrossNetTypes[i],
TStr(
"CrossNet"));
1088 AddEdgeAttributes(NewNet, CrossNet, CNetAttrs, CrossNetTypes[i], edgeId, newEId);
1090 int otherEId = NewNet->AddEdge(dstId, srcId);
1091 NewNet->AddIntAttrDatE(otherEId, edgeId,
TStr(
"Id"));
1092 NewNet->AddIntAttrDatE(otherEId, CrossNetTypes[i],
TStr(
"CrossNet"));
1093 AddEdgeAttributes(NewNet, CrossNet, CNetAttrs, CrossNetTypes[i], edgeId, otherEId);
1099 TInt ModeId = it.GetKey();
1103 TIntPr NodeKey(ModeId, NodeIt.GetId());
1104 if (!NodeMap.
IsKey(NodeKey)) {
1105 int newId = NewNet->AddNode();
1106 NodeMap.
AddDat(NodeKey, newId);
1116 if (MxLen <= NumPartitions) {
1119 TInt PartitionSize = MxLen/NumPartitions;
1123 TInt CurrEnd = CurrStart + PartitionSize;
1124 if (MxLen - CurrEnd < PartitionSize) {
1128 Partitions.
Add(
TIntPr(CurrStart, CurrEnd));
1129 CurrStart = CurrEnd;
1143 for (
int i=0; i < CrossNetNames.
Len(); i++) {
1145 CrossNetStart.
AddDat(CrossNetNames[i], offset);
1148 offset += (CrossNet.
GetMxEId() * factor);
1149 NumEdges += (CrossNet.
GetEdges() * factor);
1163 int num_threads = omp_get_max_threads();
1166 TInt ModeId = MI.GetKey();
1174 #pragma omp parallel for schedule(static) private(curr_nid)
1175 for (
int i = 0; i < NodePartitions.
Len(); i++) {
1176 TInt CurrStart = NodePartitions[i].GetVal1();
1177 TInt CurrEnd = NodePartitions[i].GetVal2();
1178 curr_nid = offset + CurrStart;
1179 for (
int idx = CurrStart; idx < CurrEnd ; idx++) {
1180 int n_i = KeyIds[idx];
1181 if (ModeNet.
IsNode(n_i)) {
1185 for (
int j=0; j < CrossNetNames.
Len(); j++) {
1186 TStr CrossNetName =
TStr(CrossNetNames[j].CStr());
1192 int edge_offset = CrossNetStart.
GetDat(CrossNetName);
1196 bool isOutNbr = CrossNet.
GetMode1() == ModeId;
1197 int factor = isDir ? 1 : 2;
1199 int id_offset = isDir || isOutNbr ? 0 : 1;
1204 for (
int k = 0; k < Neighbors.
Len(); k++) {
1205 if (isOutNbr && id_offset == 0) {
1206 OutNbrs.
Add(edge_offset + Neighbors[k]*factor + id_offset);
1208 InNbrs.
Add(edge_offset + Neighbors[k]*factor + id_offset);
1211 int opp_offset = id_offset == 1 ? 0 : 1;
1212 if (isOutNbr && id_offset == 0) {
1213 InNbrs.
Add(edge_offset + Neighbors[k]*factor + opp_offset);
1215 OutNbrs.
Add(edge_offset + Neighbors[k]*factor + opp_offset);
1222 OutNbrs.
AddV(TempOut);
1225 InNbrs.
AddV(TempIn);
1230 NewNet->AddNodeWithEdges(curr_nid, InNbrs, OutNbrs);
1231 TIntPr NodeKey(MI.GetKey(), n_i);
1232 NodeMap.
AddDat(NodeKey, curr_nid);
1237 offset += KeyIds.
Len();
1239 NewNet->SetNodes(offset);
1241 for (
int j=0; j < CrossNetNames.
Len(); j++) {
1242 TStr CrossNetName = CrossNetNames[j];
1250 offset = CrossNetStart.
GetDat(CrossNetNames[j]);
1252 #pragma omp parallel for schedule(static) private(curr_eid)
1253 for (
int i = 0; i < EdgePartitions.
Len(); i++) {
1254 TInt CurrStart = EdgePartitions[i].GetVal1();
1255 TInt CurrEnd = EdgePartitions[i].GetVal2();
1256 for (
int e_i = CurrStart; e_i < CurrEnd ; e_i++) {
1257 curr_eid = offset + factor*e_i;
1258 if (CrossNet.
IsEdge(e_i)) {
1259 int new_eid = curr_eid;
1260 TIntPr EdgeKey(CrossNetId, e_i);
1264 TIntPr NodeKeySrc(Mode1, srcNode);
1265 TIntPr NodeKeyDst(Mode2, dstNode);
1266 int newSrc = NodeMap.
GetDat(NodeKeySrc);
1267 int newDst = NodeMap.
GetDat(NodeKeyDst);
1268 NewNet->AddEdgeUnchecked(curr_eid, newSrc, newDst);
1272 otherEId = curr_eid;
1273 NewNet->AddEdgeUnchecked(otherEId, newDst, newSrc);
1280 NewNet->SetEdges(MxEId);
1281 NewNet->ReserveAttr(2, 0, 0, 2, 0, 0);
1284 NewNet->AddIntAttrN(
TStr(
"Mode"));
1285 NewNet->AddIntAttrN(
TStr(
"Id"));
1286 NewNet->AddIntAttrE(
TStr(
"CrossNet"));
1287 NewNet->AddIntAttrE(
TStr(
"Id"));
1292 #pragma omp parallel for schedule(static)
1293 for(
int i = 0; i < NewNodeIds.
Len(); i++) {
1294 NewNet->AddIntAttrDatN(NodeMap.
GetDat(NewNodeIds[i]), NewNodeIds[i].GetVal1(),
TStr(
"Mode"));
1295 NewNet->AddIntAttrDatN(NodeMap.
GetDat(NewNodeIds[i]), NewNodeIds[i].GetVal2(),
TStr(
"Id"));
1300 #pragma omp parallel for schedule(static)
1301 for(
int i = 0; i < NewEdgeIds.
Len(); i++) {
1302 NewNet->AddIntAttrDatE(EdgeMap.
GetDat(NewEdgeIds[i]).
GetVal1(), NewEdgeIds[i].GetVal2(),
TStr(
"Id"));
1303 NewNet->AddIntAttrDatE(EdgeMap.
GetDat(NewEdgeIds[i]).
GetVal1(), NewEdgeIds[i].GetVal1(),
TStr(
"CrossNet"));
1305 NewNet->AddIntAttrDatE(EdgeMap.
GetDat(NewEdgeIds[i]).
GetVal2(), NewEdgeIds[i].GetVal1(),
TStr(
"CrossNet"));
1306 NewNet->AddIntAttrDatE(EdgeMap.
GetDat(NewEdgeIds[i]).
GetVal2(), NewEdgeIds[i].GetVal2(),
TStr(
"Id"));
1312 #endif // GCC_ATOMIC
1315 for (
int i = 0; i < Attrs.Len(); i++) {
1317 TStr OrigAttr = Attrs[i].Val1;
1318 TStr NewAttr = Attrs[i].Val2;
1321 TIntPr OldNId(ModeId, oldId);
1323 NewNet->AddIntAttrDatN(NId, Val, NewAttr);
1325 TIntPr OldNId(ModeId, oldId);
1327 NewNet->AddFltAttrDatN(NId, Val, NewAttr);
1329 TIntPr OldNId(ModeId, oldId);
1331 NewNet->AddStrAttrDatN(NId, Val, NewAttr);
1333 TIntPr OldNId(ModeId, oldId);
1335 NewNet->AddIntVAttrDatN(NId, Val, NewAttr);
1342 for (
int i = 0; i < Attrs.Len(); i++) {
1344 TStr OrigAttr = Attrs[i].Val1;
1345 TStr NewAttr = Attrs[i].Val2;
1348 TIntPr OldNId(CrossId, oldId);
1350 NewNet->AddIntAttrDatE(EId, Val, NewAttr);
1352 TIntPr OldNId(CrossId, oldId);
1354 NewNet->AddFltAttrDatE(EId, Val, NewAttr);
1356 TIntPr OldNId(CrossId, oldId);
1358 NewNet->AddStrAttrDatE(EId, Val, NewAttr);
TStr GetStrAttrDatE(const TCrossEdgeI &EdgeI, const TStr &attr)
Gets the value of str attr from the edge attr value vector.
TPair< TInt, TInt > TIntPr
TInt GetIntAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of int attr from the node attr value vector.
int AddFltAttrDatE(const TCrossEdgeI &EdgeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
int GetNodes() const
Returns the number of nodes in the network.
#define IAssertR(Cond, Reason)
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...
TStr GetStrAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of str attr from the node attr value vector.
int AppendIntVAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Appends value onto the TIntV attribute for the given node.
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.
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
int AddStrAttrDatE(const TCrossEdgeI &EdgeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
THash< TStr, TFlt > FltDefaultsE
int DelCrossNet(const TInt &CrossNetId)
Deletes a crossnet from the multimodal network.
int DelAttrN(const TStr &attr)
Removes all the values for node attr.
void FltAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for node NId.
Node iterator. Only forward iteration (operator++) is supported.
TVec< TIntV > VecOfIntVecsE
TInt CheckDenseOrSparseN(const TStr &attr) const
Return 1 if in Dense, 0 if in Sparse, -1 if neither.
static const T & Mx(const T &LVal, const T &RVal)
bool EdgeAttrIsStrDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
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.
bool IsIn(const TVal &Val) const
Checks whether element Val is a member of the vector.
PMMNet GetSubgraphByCrossNet(TStrV &CrossNetTypes)
Gets the induced subgraph given a vector of crossnet type names.
static PNEANetMP New()
Static cons returns pointer to graph. Ex: PNEANetMP Graph=TNEANetMP::New().
int GetSrcNId() const
Returns the source of the edge.
const TVal1 & GetVal1() const
void DelNode(const int &NId)
Deletes the given node from this mode.
TSizeTy Len() const
Returns the number of elements in the vector.
TInt GetIntAttrDefaultE(const TStr &attribute) const
Gets Int edge attribute val. If not a proper attr, return default.
TCrossEdgeI BegEdgeI() const
A single edge in the cross net. Has an Edge Id, and the source and destination node ids...
void GetKeyV(TVec< TKey > &KeyV) const
TStr GetSubStr(const int &BChN, const int &EChN) const
const TVal2 & GetVal2() const
int DelNeighbor(const int &NId, const int &EId, bool outEdge, const TStr &CrossName, const bool sameMode, bool isDir)
Edge iterator. Only forward iteration (operator++) is supported.
const TDat & GetDat(const TKey &Key) const
TIntV GetIntVAttrDatN(const TNodeI &NodeI, const TStr &attr) const
Gets the value of the intv attr from the node attr value vector.
TCrossEdge & GetEdge(int eid)
THash< TInt, TStr > ModeIdToNameH
int DelEdge(const int &EId)
Deletes an edge by its id.
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.
virtual void DelNode(const int &NId)
Deletes node of ID NId from the graph.
void LoadShM(TShMIn &ShMIn)
Load THash from shared memory file. Copying/Deleting Keys is illegal.
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.
const TKey & GetKey() const
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 ...
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.
int DelFromIntVAttrDatN(const TNodeI &NodeI, const TInt &value, const TStr &attr)
Deletes value from the TIntV attribute for the given node.
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.
int AddModeNet(const TStr &ModeName)
Adds a mode to the multimodal network.
THash< TStr, TStr > StrDefaultsE
void DelKey(const TKey &Key)
TVec< TStrV > VecOfStrVecsE
const TVal & GetVal(const TSizeTy &ValN) const
Returns a reference to the element at position ValN in the vector.
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
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
void StrAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of str attr names for node NId.
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
const TDat & GetDat() const
void GetCrossNetNames(TStrV &Names) const
Gets a list of CrossNets that have this Mode as either a source or destination type.
int GetMode2() const
Gets the id of the dst mode.
void RemoveCrossNets(TModeNet &Result, TStrV &CrossNets)
bool IsEnd() const
Tests whether the iterator is pointing to the past-end element.
THash< TStr, TInt > CrossNameToIdH
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.
const TVal & GetDat(const TVal &Val) const
Returns reference to the first occurrence of element Val.
bool IsSuffix(const char *Str) const
int AddFltAttrE(const TStr &attr, TFlt defaultValue=TFlt::Mn)
Adds a new Flt edge attribute to the hashmap.
TFlt GetFltAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of flt attr from the node attr value vector.
int DelNbrType(const TStr &CrossName)
TNodeI BegMMNI() const
Returns an iterator referring to the first node in the graph.
bool EdgeAttrIsIntDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
bool EdgeAttrIsFltDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
int AddKey(const TKey &Key)
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.
TStr GetStrAttrDefaultN(const TStr &attribute) const
Gets Str node attribute val. If not a proper attr, return default.
PNEANetMP ToNetworkMP(TStrV &CrossNetNames)
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)
The nodes of one particular mode in a TMMNet, and their neighbor vectors as TIntV attributes...
void ClrNbr(const TStr &CrossNetName, const bool &outEdge, const bool &sameMode, bool &isDir)
THash< TInt, TModeNet > TModeNetH
Keeps track of the max crossnet id.
int GetKeyId(const TKey &Key) const
void AttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of attr names for edge EId.
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.
void Ins(const TSizeTy &ValN, const TVal &Val)
Inserts new element Val before the element at position ValN.
int GetEdges() const
Returns the number of edges in the graph.
TModeNet & GetModeNetById(const TInt &ModeId) 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.
bool IsStrAttrDeletedE(const int &EId, const TStr &attr) const
static TStr Fmt(const char *FmtStr,...)
TInt Mode2
The first mode. In the case of directed crossnets, this is implicitly understood to be the source mod...
TCrossEdgeI GetEdgeI(const int &EId) const
Edge iterators.
int GetCrossId(const TStr &CrossName) const
Gets the crossnet id from the crossnet name.
void Clr()
Deletes all nodes and edges from the graph.
TVec< THash< TInt, TIntV > > VecOfIntHashVecsN
int GetMode1() const
Gets the id of the src mode.
Hash-Table with multiprocessing support.
void Clr(const bool &DoDel=true, const int &NoDelLim=-1, const bool &ResetDat=true)
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...
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
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.
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
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Gets Flt node attribute val. If not a proper attr, return default.
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)
TInt GetIntAttrDefaultN(const TStr &attribute) const
Gets Int node attribute val. If not a proper attr, return default.
TStr GetEdgeAttrValue(const int &EId, const TStrIntPrH::TIter &CrossHI) const
bool IsKey(const TKey &Key) const
TCrossNet & GetCrossNetByName(const TStr &CrossName) const
Gets a reference to the crossnet.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
int AddEdgeAttributes(PNEANet &NewNet, TCrossNet &Net, TVec< TPair< TStr, TStr > > &Attrs, int CrossId, int oldId, int EId)
TDat & AddDat(const TKey &Key)
static PNEANet New()
Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New().
TInt MxCrossNetId
Keeps track of the max mode id.
THash< TInt, TCrossEdge > CrossH
TDat & AddDat(const TKey &Key)
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.
const TDat & GetDat(const TKey &Key) const
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)
TModeNet & GetModeNetByName(const TStr &ModeName) const
Gets a reference to the modenet.
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.
THash< TInt, TStr > CrossIdToNameH
TSizeTy AddV(const TVec< TVal, TSizeTy > &ValV)
Adds the elements of the vector ValV to the to end of the vector.
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)