6 if (!isDir || !sameMode) {
return Cpy; }
25 for (
int i=0; i < CNets.
Len(); i++) {
31 int TModeNet::AddNeighbor(
const int& NId,
const int& EId,
bool outEdge,
const int linkId,
const bool sameMode,
bool isDir){
33 return AddNeighbor(NId, EId, outEdge, CrossName, sameMode, isDir);
54 return DelNeighbor(NId, EId, outEdge, CrossName, sameMode, isDir);
60 for (
int i=0; i < Names.
Len(); i++) {
64 for (
int j=0; j < OutEIds.
Len(); j++) {
70 for (
int j=0; j < InEIds.
Len(); j++) {
85 bool hasSingleVector = (!isDir || !sameMode);
94 if (hasSingleVector) {
109 if (hasSingleVector) {
130 TStr AttrName = it.GetKey();
131 TInt AttrType = it.GetDat().GetVal1();
132 TInt AttrIndex = it.GetDat().GetVal2();
136 TStr WithoutSuffix = AttrName;
137 bool removeSuffix =
false;
139 WithoutSuffix = AttrName.
GetSubStr(0, AttrName.
Len()-5);
144 if (isSingleVNbrAttr || isMultiVNbrAttr) {
145 TStr NbrName = isSingleVNbrAttr ? AttrName : WithoutSuffix;
146 if (CrossNets.
IsIn(NbrName)) {
147 Result.
AddNbrType(NbrName, removeSuffix, removeSuffix);
194 if (!M1.
IsNode(sourceNId) || !M2.
IsNode(destNId)) {
return -1; }
206 if (IntVec.
Len() > KeyId) {
214 for (i = 0; i < DefIntVec.
Len(); i++) {
215 TStr attr = DefIntVec[i];
223 if (StrVec.
Len() > KeyId) {
231 for (i = 0; i < DefStrVec.
Len(); i++) {
232 TStr attr = DefStrVec[i];
240 if (FltVec.
Len() > KeyId) {
248 for (i = 0; i < DefFltVec.
Len(); i++) {
249 TStr attr = DefFltVec[i];
258 int srcNode = Edge.
SrcNId;
259 int dstNode = Edge.
DstNId;
286 while (!CrossHI.
IsEnd()) {
296 while (!CrossHI.
IsEnd()) {
306 while (!CrossHI.
IsEnd()) {
316 while (!CrossHI.
IsEnd()) {
327 while (!CrossHI.
IsEnd()) {
337 while (!CrossHI.
IsEnd()) {
348 while (!CrossHI.
IsEnd()) {
358 while (!CrossHI.
IsEnd()) {
371 return IntDel || StrDel || FltDel;
390 return IntDel || StrDel || FltDel;
439 for (i = 0; i <
MxEId; i++) {
462 for (i = 0; i <
MxEId; i++) {
486 for (i = 0; i <
MxEId; i++) {
512 }
else if (vecType ==
StrType) {
514 }
else if (vecType ==
FltType) {
530 for (i = 0; i <
MxEId; i++) {
531 NewVec.
Ins(i, defaultValue);
549 for (i = 0; i <
MxEId; i++) {
550 NewVec.
Ins(i, defaultValue);
568 for (i = 0; i <
MxEId; i++) {
569 NewVec.
Ins(i, defaultValue);
587 }
else if (vecType ==
StrType) {
592 }
else if (vecType ==
FltType) {
623 return AddCrossNet(ModeId1, ModeId2, CrossNetName, isDir);
667 for (
int i = 0; i < CrossNets.
Len(); i++) {
692 TModeNet &Net = (
const_cast<TMMNet *
>(
this))->TModeNetH.GetDat(ModeId);
701 TCrossNet& CrossNet = (
const_cast<TMMNet *
>(
this))->TCrossNetH.GetDat(CrossId);
710 TModeNetH[ModeId].SetParentPointer(
this);
719 TCrossNetH[CrossNetId].SetParentPointer(
this);
723 void TMMNet::ClrNbr(
const TInt& ModeId,
const TInt& CrossNetId,
const bool& outEdge,
const bool& sameMode,
bool& isDir) {
725 TModeNetH[ModeId].ClrNbr(CrossNetName, outEdge, sameMode, isDir);
733 for(
int i = 0; i < CrossNetTypes.
Len(); i++) {
734 TStr CrossName = CrossNetTypes[i];
736 TInt NewId = MxCross++;
738 TInt OldModeId1 = NewCrossNet.Mode1;
739 TInt OldModeId2 = NewCrossNet.Mode2;
740 TInt NewModeId1, NewModeId2;
741 if (ModeH.
IsKey(OldModeId1)) {
742 NewModeId1 = ModeH.
GetDat(OldModeId1);
744 NewModeId1 = MxMode++;
745 ModeH.
AddDat(OldModeId1, NewModeId1);
747 if (ModeH.
IsKey(OldModeId2)) {
748 NewModeId2 = ModeH.
GetDat(OldModeId2);
750 NewModeId2 = MxMode++;
751 ModeH.
AddDat(OldModeId2, NewModeId2);
753 NewCrossNet.Mode1 = NewModeId1;
754 NewCrossNet.Mode2 = NewModeId2;
755 NewCrossNet.CrossNetId = NewId;
756 Result->AddCrossNet(CrossName, NewId, NewCrossNet);
760 TInt NewModeId = it.GetDat();
762 TModeNetH.
GetDat(it.GetKey()).RemoveCrossNets(NewModeNet, CrossNetTypes);
763 NewModeNet.
ModeId = NewModeId;
764 Result->AddMode(ModeName, NewModeId, NewModeNet);
766 Result->MxModeId = MxMode;
767 Result->MxCrossNetId = MxCross;
773 for (
int i = 0; i < ModeNetTypes.
Len(); i++) {
781 ModeTypeIds[CrossNet.
Mode1] =
false;
782 ModeTypeIds[CrossNet.
Mode2] =
false;
787 TInt MxMode = Result->MxModeId;
788 TStrV EmptyCrossNetTypes;
790 if (it.GetDat().Val) {
792 TInt NewModeId = MxMode++;
794 TModeNetH.
GetDat(it.GetKey()).RemoveCrossNets(NewModeNet, EmptyCrossNetTypes);
795 NewModeNet.
ModeId = NewModeId;
796 Result->AddMode(ModeName, NewModeId, NewModeNet);
799 Result->MxModeId = MxMode;
809 for (
int i = 0; i < CrossNetTypes.
Len(); i++) {
817 int srcNode = EdgeI.GetSrcNId();
818 int dstNode = EdgeI.GetDstNId();
819 TIntPr SrcNodeMapping(Mode1, srcNode);
821 if (NodeMap.
IsKey(SrcNodeMapping)) {
822 srcId = NodeMap.
GetDat(SrcNodeMapping);
824 srcId = NewNet->AddNode();
825 NodeMap.
AddDat(SrcNodeMapping, srcId);
827 TIntPr DstNodeMapping(Mode2, dstNode);
829 if (NodeMap.
IsKey(DstNodeMapping)) {
830 dstId = NodeMap.
GetDat(DstNodeMapping);
832 dstId = NewNet->AddNode();
833 NodeMap.
AddDat(DstNodeMapping, dstId);
835 int edgeId = EdgeI.GetId();
836 TIntPr EdgeMapping(CrossNetTypes[i], edgeId);
837 int newEId = NewNet->AddEdge(srcId, dstId);
840 otherEId = NewNet->AddEdge(dstId, srcId);
848 TInt ModeId = it.GetKey();
850 TIntPr NodeKey(ModeId, NodeIt.GetId());
851 if (!NodeMap.
IsKey(NodeKey)) {
852 int newId = NewNet->AddNode();
853 NodeMap.
AddDat(NodeKey, newId);
859 NewNet->AddIntAttrN(
TStr(
"Mode"));
860 NewNet->AddIntAttrN(
TStr(
"Id"));
861 NewNet->AddIntAttrE(
TStr(
"CrossNet"));
862 NewNet->AddIntAttrE(
TStr(
"Id"));
864 NewNet->AddIntAttrDatN(it.GetDat(), it.GetKey().GetVal1(),
TStr(
"Mode"));
865 NewNet->AddIntAttrDatN(it.GetDat(), it.GetKey().GetVal2(),
TStr(
"Id"));
868 NewNet->AddIntAttrDatE(it.GetDat().GetVal1(), it.GetKey().GetVal1(),
TStr(
"CrossNet"));
869 NewNet->AddIntAttrDatE(it.GetDat().GetVal1(), it.GetKey().GetVal2(),
TStr(
"Id"));
870 if (it.GetDat().GetVal2() != -1) {
871 NewNet->AddIntAttrDatE(it.GetDat().GetVal2(), it.GetKey().GetVal1(),
TStr(
"CrossNet"));
872 NewNet->AddIntAttrDatE(it.GetDat().GetVal2(), it.GetKey().GetVal2(),
TStr(
"Id"));
876 for (
int i = 0; i < NodeAttrMap.
Len(); i++) {
878 TInt ModeId = NodeAttrMap[i].Val1;
879 TStr OrigAttr = NodeAttrMap[i].Val2;
880 TStr NewAttr = NodeAttrMap[i].Val3;
886 TIntPr OldNId(ModeId, it.GetId());
887 int NewId = NodeMap.
GetDat(OldNId);
889 NewNet->AddIntAttrDatN(NewId, Val, NewAttr);
894 TIntPr OldNId(ModeId, it.GetId());
895 int NewId = NodeMap.
GetDat(OldNId);
897 NewNet->AddFltAttrDatN(NewId, Val, NewAttr);
903 TIntPr OldNId(ModeId, it.GetId());
904 int NewId = NodeMap.
GetDat(OldNId);
906 NewNet->AddStrAttrDatN(NewId, Val, NewAttr);
909 NewNet->AddIntVAttrN(NewAttr);
911 TIntPr OldNId(ModeId, it.GetId());
912 int NewId = NodeMap.
GetDat(OldNId);
914 NewNet->AddIntVAttrDatN(NewId, Val, NewAttr);
919 for (
int i = 0; i < EdgeAttrMap.Len(); i++) {
921 TInt CrossId = EdgeAttrMap[i].Val1;
922 TStr OrigAttr = EdgeAttrMap[i].Val2;
923 TStr NewAttr = EdgeAttrMap[i].Val3;
929 TIntPr OldNId(CrossId, it.GetId());
932 NewNet->AddIntAttrDatE(NewId.Val1, Val, NewAttr);
933 if (NewId.Val2 != -1) {
934 NewNet->AddIntAttrDatE(NewId.Val2, Val, NewAttr);
940 TIntPr OldNId(CrossId, it.GetId());
943 NewNet->AddFltAttrDatE(NewId.Val1, Val, NewAttr);
944 if (NewId.Val2 != -1) {
945 NewNet->AddFltAttrDatE(NewId.Val2, Val, NewAttr);
952 TIntPr OldNId(CrossId, it.GetId());
955 NewNet->AddStrAttrDatE(NewId.Val1, Val, NewAttr);
956 if (NewId.Val2 != -1) {
957 NewNet->AddStrAttrDatE(NewId.Val2, Val, NewAttr);
969 NewNet->AddIntAttrN(
TStr(
"Mode"));
970 NewNet->AddIntAttrN(
TStr(
"Id"));
971 NewNet->AddIntAttrE(
TStr(
"CrossNet"));
972 NewNet->AddIntAttrE(
TStr(
"Id"));
975 for (
int i = 0; i < CrossNetTypes.
Len(); i++) {
978 if (EdgeAttrMap.IsKey(CrossNetTypes[i])) {
979 CNetAttrs = EdgeAttrMap.
GetDat(CrossNetTypes[i]);
986 if (NodeAttrMap.
IsKey(Mode1)) {
987 Mode1Attrs = NodeAttrMap.
GetDat(Mode1);
990 if (NodeAttrMap.
IsKey(Mode2)) {
991 Mode2Attrs = NodeAttrMap.
GetDat(Mode2);
997 int srcNode = EdgeI.GetSrcNId();
998 int dstNode = EdgeI.GetDstNId();
999 TIntPr SrcNodeMapping(Mode1, srcNode);
1001 if (NodeMap.
IsKey(SrcNodeMapping)) {
1002 srcId = NodeMap.
GetDat(SrcNodeMapping);
1004 srcId = NewNet->AddNode();
1005 NodeMap.
AddDat(SrcNodeMapping, srcId);
1006 NewNet->AddIntAttrDatN(srcId, srcNode,
TStr(
"Id"));
1007 NewNet->AddIntAttrDatN(srcId, Mode1,
TStr(
"Mode"));
1010 TIntPr DstNodeMapping(Mode2, dstNode);
1012 if (NodeMap.
IsKey(DstNodeMapping)) {
1013 dstId = NodeMap.
GetDat(DstNodeMapping);
1015 dstId = NewNet->AddNode();
1016 NodeMap.
AddDat(DstNodeMapping, dstId);
1017 NewNet->AddIntAttrDatN(dstId, dstNode,
TStr(
"Id"));
1018 NewNet->AddIntAttrDatN(dstId, Mode2,
TStr(
"Mode"));
1021 int edgeId = EdgeI.GetId();
1022 int newEId = NewNet->AddEdge(srcId, dstId);
1023 NewNet->AddIntAttrDatE(newEId, edgeId,
TStr(
"Id"));
1024 NewNet->AddIntAttrDatE(newEId, CrossNetTypes[i],
TStr(
"CrossNet"));
1025 AddEdgeAttributes(NewNet, CrossNet, CNetAttrs, CrossNetTypes[i], edgeId, newEId);
1027 int otherEId = NewNet->AddEdge(dstId, srcId);
1028 NewNet->AddIntAttrDatE(otherEId, edgeId,
TStr(
"Id"));
1029 NewNet->AddIntAttrDatE(otherEId, CrossNetTypes[i],
TStr(
"CrossNet"));
1030 AddEdgeAttributes(NewNet, CrossNet, CNetAttrs, CrossNetTypes[i], edgeId, otherEId);
1036 TInt ModeId = it.GetKey();
1040 TIntPr NodeKey(ModeId, NodeIt.GetId());
1041 if (!NodeMap.
IsKey(NodeKey)) {
1042 int newId = NewNet->AddNode();
1043 NodeMap.
AddDat(NodeKey, newId);
1054 TInt PartitionSize = MxLen/NumPartitions;
1058 TInt CurrEnd = CurrStart + PartitionSize;
1059 if (MxLen - CurrEnd < PartitionSize) {
1063 Partitions.
Add(
TIntPr(CurrStart, CurrEnd));
1064 CurrStart = CurrEnd;
1076 for (
int i=0; i < CrossNetNames.
Len(); i++) {
1077 CrossNetStart.
AddDat(CrossNetNames[i], offset);
1080 offset += (CrossNet.
GetMxEId() * factor);
1081 NumEdges += (CrossNet.
GetEdges() * factor);
1097 int num_threads = omp_get_max_threads();
1100 TInt ModeId = MI.GetKey();
1109 #pragma omp parallel for schedule(static) private(curr_nid)
1110 for (
int i = 0; i < NodePartitions.
Len(); i++) {
1111 TInt CurrStart = NodePartitions[i].GetVal1();
1112 TInt CurrEnd = NodePartitions[i].GetVal2();
1113 curr_nid = offset + CurrStart;
1114 for (
int idx = CurrStart; idx < CurrEnd ; idx++) {
1115 int n_i = KeyIds[idx];
1116 if (ModeNet.
IsNode(n_i)) {
1120 for (
int j=0; j < CrossNetNames.
Len(); j++) {
1126 int edge_offset = CrossNetStart.
GetDat(CrossNetNames[j]);
1129 bool isOutNbr = CrossNet.
GetMode1() == ModeId;
1130 int factor = isDir ? 1 : 2;
1132 int id_offset = isDir || isOutNbr ? 0 : 1;
1137 for (
int k = 0; k < Neighbors.
Len(); k++) {
1138 if (isOutNbr && id_offset == 0) {
1139 OutNbrs.
Add(edge_offset + Neighbors[k]*factor + id_offset);
1141 InNbrs.
Add(edge_offset + Neighbors[k]*factor + id_offset);
1144 int opp_offset = id_offset == 1 ? 0 : 1;
1145 if (isOutNbr && id_offset == 0) {
1146 InNbrs.
Add(edge_offset + Neighbors[k]*factor + opp_offset);
1148 OutNbrs.
Add(edge_offset + Neighbors[k]*factor + opp_offset);
1155 OutNbrs.
AddV(TempOut);
1158 InNbrs.
AddV(TempIn);
1163 NewNet->AddNodeWithEdges(curr_nid, InNbrs, OutNbrs);
1164 TIntPr NodeKey(MI.GetKey(), n_i);
1165 NodeMap.
AddDat(NodeKey, curr_nid);
1170 offset += KeyIds.
Len();
1172 NewNet->SetNodes(offset);
1174 for (
int j=0; j < CrossNetNames.
Len(); j++) {
1175 TStr CrossNetName = CrossNetNames[j];
1184 offset = CrossNetStart.
GetDat(CrossNetNames[j]);
1186 #pragma omp parallel for schedule(static) private(curr_eid)
1187 for (
int i = 0; i < EdgePartitions.
Len(); i++) {
1188 TInt CurrStart = EdgePartitions[i].GetVal1();
1189 TInt CurrEnd = EdgePartitions[i].GetVal2();
1190 for (
int e_i = CurrStart; e_i < CurrEnd ; e_i++) {
1191 curr_eid = offset + factor*e_i;
1192 if (CrossNet.
IsEdge(e_i)) {
1193 int new_eid = curr_eid;
1194 TIntPr EdgeKey(CrossNetId, e_i);
1198 TIntPr NodeKeySrc(Mode1, srcNode);
1199 TIntPr NodeKeyDst(Mode2, dstNode);
1200 int newSrc = NodeMap.
GetDat(NodeKeySrc);
1201 int newDst = NodeMap.
GetDat(NodeKeyDst);
1202 NewNet->AddEdgeUnchecked(curr_eid, newSrc, newDst);
1206 otherEId = curr_eid;
1207 NewNet->AddEdgeUnchecked(otherEId, newDst, newSrc);
1214 NewNet->SetEdges(MxEId);
1215 NewNet->ReserveAttr(2, 0, 0, 2, 0, 0);
1218 NewNet->AddIntAttrN(
TStr(
"Mode"));
1219 NewNet->AddIntAttrN(
TStr(
"Id"));
1220 NewNet->AddIntAttrE(
TStr(
"CrossNet"));
1221 NewNet->AddIntAttrE(
TStr(
"Id"));
1226 #pragma omp parallel for schedule(static)
1227 for(
int i = 0; i < NewNodeIds.
Len(); i++) {
1228 NewNet->AddIntAttrDatN(NodeMap.
GetDat(NewNodeIds[i]), NewNodeIds[i].GetVal1(),
TStr(
"Mode"));
1229 NewNet->AddIntAttrDatN(NodeMap.
GetDat(NewNodeIds[i]), NewNodeIds[i].GetVal2(),
TStr(
"Id"));
1235 #pragma omp parallel for schedule(static)
1236 for(
int i = 0; i < NewEdgeIds.
Len(); i++) {
1237 NewNet->AddIntAttrDatE(EdgeMap.
GetDat(NewEdgeIds[i]).
GetVal1(), NewEdgeIds[i].GetVal2(),
TStr(
"Id"));
1238 NewNet->AddIntAttrDatE(EdgeMap.
GetDat(NewEdgeIds[i]).
GetVal1(), NewEdgeIds[i].GetVal1(),
TStr(
"CrossNet"));
1240 NewNet->AddIntAttrDatE(EdgeMap.
GetDat(NewEdgeIds[i]).
GetVal2(), NewEdgeIds[i].GetVal1(),
TStr(
"CrossNet"));
1241 NewNet->AddIntAttrDatE(EdgeMap.
GetDat(NewEdgeIds[i]).
GetVal2(), NewEdgeIds[i].GetVal2(),
TStr(
"Id"));
1247 #endif // GCC_ATOMIC
1250 for (
int i = 0; i < Attrs.Len(); i++) {
1252 TStr OrigAttr = Attrs[i].Val1;
1253 TStr NewAttr = Attrs[i].Val2;
1256 TIntPr OldNId(ModeId, oldId);
1258 NewNet->AddIntAttrDatN(NId, Val, NewAttr);
1260 TIntPr OldNId(ModeId, oldId);
1262 NewNet->AddFltAttrDatN(NId, Val, NewAttr);
1264 TIntPr OldNId(ModeId, oldId);
1266 NewNet->AddStrAttrDatN(NId, Val, NewAttr);
1268 TIntPr OldNId(ModeId, oldId);
1270 NewNet->AddIntVAttrDatN(NId, Val, NewAttr);
1277 for (
int i = 0; i < Attrs.Len(); i++) {
1279 TStr OrigAttr = Attrs[i].Val1;
1280 TStr NewAttr = Attrs[i].Val2;
1283 TIntPr OldNId(CrossId, oldId);
1285 NewNet->AddIntAttrDatE(EId, Val, NewAttr);
1287 TIntPr OldNId(CrossId, oldId);
1289 NewNet->AddFltAttrDatE(EId, Val, NewAttr);
1291 TIntPr OldNId(CrossId, oldId);
1293 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 graph.
#define IAssertR(Cond, Reason)
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
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.
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
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.
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.
int AddIntVAttrByVecN(const TStr &attr, TVec< TIntV > &Attrs)
Adds a new TIntV node attribute to the hashmap.
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.
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.
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)