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);
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) ...