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);
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.
TStr GetStrAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of str attr from the node attr value vector.
Node iterator. Only forward iteration (operator++) is supported.
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
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.
TCrossEdgeI EndEdgeI() const
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Gets Flt edge attribute val. If not a proper attr, return default.
TNodeI EndMMNI() const
Returns an iterator referring to the past-the-end node in the graph.
int GetMode2() const
Gets the id of the dst mode.
TFlt GetFltAttrDatN(const TNodeI &NodeI, const TStr &attr)
Gets the value of flt attr from the node attr value vector.
TNodeI BegMMNI() const
Returns an iterator referring to the first node in the graph.
int AddKey(const TKey &Key)
TStr GetStrAttrDefaultN(const TStr &attribute) const
Gets Str node attribute val. If not a proper attr, return default.
The nodes of one particular mode in a TMMNet, and their neighbor vectors as TIntV attributes...
TModeNet & GetModeNetById(const TInt &ModeId) const
TFlt GetFltAttrDatE(const TCrossEdgeI &EdgeI, const TStr &attr)
Gets the value of flt attr from the edge attr value vector.
int GetMode1() const
Gets the id of the src mode.
TFlt GetFltAttrDefaultN(const TStr &attribute) const
Gets Flt node attribute val. If not a proper attr, return default.
TInt GetIntAttrDefaultN(const TStr &attribute) const
Gets Int node attribute val. If not a proper attr, return default.
bool IsKey(const TKey &Key) const
static PNEANet New()
Static cons returns pointer to graph. Ex: PNEANet Graph=TNEANet::New().
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.
int GetAttrTypeN(const TStr &attr) const
int GetAttrTypeE(const TStr &attr) const
TStr GetStrAttrDefaultE(const TStr &attribute) const
Gets Str edge attribute val. If not a proper attr, return default.
Implements a single CrossNet consisting of edges between two TModeNets (could be the same TModeNet) ...