11// //////////////////////////////////////////////
22//  Mutimodal Network
3- 
43TStr TModeNet::GetNeighborCrossName (const  TStr& CrossName, bool  isOutEdge, const  bool  sameMode, bool  isDir) const  {
54  TStr Cpy (CrossName);
65  if  (!isDir || !sameMode) { return  Cpy; }
@@ -1086,12 +1085,14 @@ void TMMNet::GetPartitionRanges(TIntPrV& Partitions, const TInt& NumPartitions,
10861085#ifdef  GCC_ATOMIC
10871086
10881087PNEANetMP TMMNet::ToNetworkMP (TStrV& CrossNetNames) {
1089-   
1088+ 
10901089  TStrIntH CrossNetStart;
10911090  THashSet<TInt> ModeSet;
10921091  int  offset = 0 ;
10931092  int  NumEdges = 0 ;
1093+   TVec<TCrossNet> CrossNets;
10941094  for  (int  i=0 ; i < CrossNetNames.Len (); i++) {
1095+     CrossNets.Add (GetCrossNetByName (CrossNetNames[i]));
10951096    CrossNetStart.AddDat (CrossNetNames[i], offset);
10961097    TCrossNet& CrossNet = GetCrossNetByName (CrossNetNames[i]);
10971098    int  factor = CrossNet.IsDirected () ? 1  : 2 ;
@@ -1101,13 +1102,11 @@ PNEANetMP TMMNet::ToNetworkMP(TStrV& CrossNetNames) {
11011102    ModeSet.AddKey (CrossNet.GetMode2 ());
11021103  }
11031104  int  MxEId = offset;
1104- 
11051105  int  NumNodes = 0 ;
11061106  for  (THashSet<TInt>::TIter MI = ModeSet.BegI (); MI < ModeSet.EndI (); MI++) {
11071107    TModeNet& ModeNet = GetModeNetById (MI.GetKey ());
11081108    NumNodes += ModeNet.GetNodes ();
11091109  }
1110- 
11111110  THashMP<TIntPr, TInt> NodeMap (NumNodes);
11121111  THashMP<TIntPr, TIntPr> EdgeMap (NumEdges);
11131112  PNEANetMP NewNet = TNEANetMP::New (NumNodes, NumEdges);
@@ -1122,7 +1121,6 @@ PNEANetMP TMMNet::ToNetworkMP(TStrV& CrossNetNames) {
11221121
11231122    TIntPrV NodePartitions;
11241123    GetPartitionRanges (NodePartitions, num_threads, KeyIds.Len ());
1125- 
11261124    int  curr_nid;
11271125    #pragma  omp parallel for schedule(static) private(curr_nid)
11281126    for  (int  i = 0 ; i < NodePartitions.Len (); i++) {
@@ -1142,14 +1140,15 @@ PNEANetMP TMMNet::ToNetworkMP(TStrV& CrossNetNames) {
11421140                TIntV Neighbors;
11431141                ModeNet.GetNeighborsByCrossNet (n_i, CrossNetNames[j], Neighbors);
11441142                int  edge_offset = CrossNetStart.GetDat (CrossNetNames[j]);
1145-                 TCrossNet CrossNet = GetCrossNetByName (CrossNetNames[j]);
1146-                 bool  isDir = CrossNet.IsDirected ();
1147-                 bool  isOutNbr = CrossNet.GetMode1 () == ModeId;
1143+                 // TCrossNet CrossNet = GetCrossNetByName(CrossNetNames[j]);
1144+                 TCrossNet* CrossNet = &CrossNets[j];
1145+                 bool  isDir = CrossNet->IsDirected ();
1146+                 bool  isOutNbr = CrossNet->GetMode1 () == ModeId;
11481147                int  factor = isDir ? 1  : 2 ;
11491148
11501149                int  id_offset = isDir || isOutNbr ? 0  : 1 ;
1151-                 if  (!isDir && CrossNet. GetMode1 () == CrossNet. GetMode2 ()) {
1152-                   id_offset = n_i == CrossNet. GetEdge (n_i).GetSrcNId () ? 0  : 1 ;
1150+                 if  (!isDir && CrossNet-> GetMode1 () == CrossNet-> GetMode2 ()) {
1151+                   id_offset = n_i == CrossNet-> GetEdge (n_i).GetSrcNId () ? 0  : 1 ;
11531152                }
11541153
11551154                for  (int  k = 0 ; k < Neighbors.Len (); k++) {
@@ -1195,7 +1194,6 @@ PNEANetMP TMMNet::ToNetworkMP(TStrV& CrossNetNames) {
11951194    TInt CrossNetId = GetCrossId (CrossNetName);
11961195    TInt Mode1 = CrossNet.GetMode1 ();
11971196    TInt Mode2 = CrossNet.GetMode2 ();
1198- 
11991197    TIntPrV EdgePartitions;
12001198    GetPartitionRanges (EdgePartitions, num_threads, CrossNet.MxEId );
12011199    int  curr_eid;
@@ -1247,7 +1245,6 @@ PNEANetMP TMMNet::ToNetworkMP(TStrV& CrossNetNames) {
12471245    NewNet->AddIntAttrDatN (NodeMap.GetDat (NewNodeIds[i]), NewNodeIds[i].GetVal2 (), TStr (" Id"  ));
12481246  }
12491247
1250- 
12511248  TIntPrV NewEdgeIds;
12521249  EdgeMap.GetKeyV (NewEdgeIds);
12531250  #pragma  omp parallel for schedule(static)
0 commit comments