SNAP Library 3.0, User Reference  2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mmnet.h
Go to the documentation of this file.
1 #ifndef MMNET_H
2 #define MMNET_H
3 
4 
5 class TMMNet;
6 
7 
8 typedef TPt<TMMNet> PMMNet;
9 
11 class TModeNet;
12 
14 class TCrossNet;
15 
16 
17 //#//////////////////////////////////////////////
19 
23 class TModeNet : public TNEANet {
24 public:
25  typedef TModeNet TNetMM;
26 public:
28  class TNodeI : public TNEANet::TNodeI {
29  public:
30  TNodeI() : TNEANet::TNodeI() { }
31  TNodeI(const THashIter& NodeHIter, const TModeNet* GraphPt) : TNEANet::TNodeI(NodeHIter, GraphPt) { }
32  TNodeI(const TNodeI& NodeI) : TNEANet::TNodeI(NodeI) { }
33  TNodeI& operator = (const TNodeI& NodeI) { NodeHI = NodeI.NodeHI; Graph=NodeI.Graph; return *this; }
35  TNodeI& operator++ (int) { NodeHI++; return *this; }
36  bool operator < (const TNodeI& NodeI) const { return NodeHI < NodeI.NodeHI; }
37  bool operator == (const TNodeI& NodeI) const { return NodeHI == NodeI.NodeHI; }
39  void GetNeighborsByCrossNet(TStr& Name, TIntV& Neighbors, const bool isOutEId=false) {
40  const TModeNet *TMGraph = static_cast<const TModeNet *>(Graph); TMGraph->GetNeighborsByCrossNet(GetId(), Name, Neighbors, isOutEId); }
42  void GetCrossNetNames(TStrV& Names) { const TModeNet *TMGraph = static_cast<const TModeNet *>(Graph); TMGraph->GetCrossNetNames(Names); }
43  friend class TModeNet;
44  };
45 private:
47  TMMNet *MMNet; // A pointer to the parent MMNet
48  THash<TStr, TBool> NeighborTypes; // Mapping of the Neighbor/CrossNets for this mode to whether it requires a one (or two) vectors to store neighbors
49 
50 public:
51  TModeNet() : TNEANet(), ModeId(-1), MMNet(), NeighborTypes() { }
52  TModeNet(const int& TypeId) : TNEANet(), ModeId(TypeId), MMNet(), NeighborTypes() { }
54  explicit TModeNet(const int& Nodes, const int& Edges) : TNEANet(Nodes, Edges),
55  ModeId(-1), MMNet(), NeighborTypes(){ }
56  explicit TModeNet(const int& Nodes, const int& Edges, const int& TypeId) : TNEANet(Nodes, Edges),
57  ModeId(TypeId), MMNet(), NeighborTypes() { }
58  TModeNet(const TModeNet& Graph) : TNEANet(true, Graph), ModeId(Graph.ModeId), MMNet(Graph.MMNet), NeighborTypes(Graph.NeighborTypes) { }
60  TModeNet(TSIn& SIn) : TNEANet(SIn), ModeId(SIn), MMNet(), NeighborTypes(SIn) { }
61 private:
62  TModeNet(const TModeNet& Graph, bool isSubModeGraph) : TNEANet(Graph, isSubModeGraph), ModeId(Graph.ModeId), MMNet(), NeighborTypes() {}
63 public:
65  void Save(TSOut& SOut) const {
66  TNEANet::Save(SOut); ModeId.Save(SOut); NeighborTypes.Save(SOut); }
67 
69  void DelNode(const int& NId);
71  void GetCrossNetNames(TStrV& Names) const { NeighborTypes.GetKeyV(Names); }
73  void GetNeighborsByCrossNet(const int& NId, TStr& Name, TIntV& Neighbors, const bool isOutEId=false) const;
74 
76  TNodeI BegMMNI() const { return TNodeI(NodeH.BegI(), this); }
78  TNodeI EndMMNI() const { return TNodeI(NodeH.EndI(), this); }
80  TNodeI GetMMNI(const int& NId) const { return TNodeI(NodeH.GetI(NId), this); }
82  void Clr();
83 
84 
85  TModeNet& operator = (const TModeNet& Graph) {
86  if (this!=&Graph) {
87  MxNId=Graph.MxNId; MxEId=Graph.MxEId; NodeH=Graph.NodeH; EdgeH=Graph.EdgeH;
93  ModeId=Graph.ModeId; MMNet=Graph.MMNet; NeighborTypes=Graph.NeighborTypes;
94  }
95  return *this;
96  }
97 
98 private:
99  //method to add neighbors; will be called by TMMNet AddEdge function; outEdge == true iff NId(which is of the type of the TModeNet; i.e. it should refer to a node in this graph) is the source node.
100  int AddNeighbor(const int& NId, const int& EId, const bool outEdge, const int linkId, const bool sameMode, bool isDir);
101  int AddNeighbor(const int& NId, const int& EId, const bool outEdge, const TStr& linkName, const bool sameMode, bool isDir);
102  int DelNeighbor(const int& NId, const int& EId, bool outEdge, const TStr& CrossName, const bool sameMode, bool isDir);
103  int DelNeighbor(const int& NId, const int& EId, bool outEdge, const TInt& linkId, const bool sameMode, bool isDir);
104  TStr GetNeighborCrossName(const TStr& CrossName, bool isOutEdge, const bool sameMode, bool isDir) const;
105  void SetParentPointer(TMMNet* parent);
106  int AddNbrType(const TStr& CrossName, const bool sameMode, bool isDir);
108  int AddIntVAttrByVecN(const TStr& attr, TVec<TIntV>& Attrs);
109  void RemoveCrossNets(TModeNet& Result, TStrV& CrossNets);
110  int DelNbrType(const TStr& CrossName);
111  int GetAttrTypeN(const TStr& attr) const;
112  void ClrNbr(const TStr& CrossNetName, const bool& outEdge, const bool& sameMode, bool& isDir);
113 public:
114  friend class TMMNet;
115  friend class TCrossNet;
116 };
117 
118 
119 //#///////////////////////////////////////////////
121 
124 class TCrossNet {
125 
126 public:
127  //#///////////////////////////////////////////////
129  class TCrossEdge {
130  private:
133  public:
134  TCrossEdge() : EId(-1), SrcNId(-1), DstNId(-1) { }
135  TCrossEdge(const int& Id, const int& SourceNId, const int& DestNId) :
136  EId(Id), SrcNId(SourceNId), DstNId(DestNId) { }
137  TCrossEdge(const TCrossEdge& MultiEdge) : EId(MultiEdge.EId), SrcNId(MultiEdge.SrcNId),
138  DstNId(MultiEdge.DstNId) { }
139  TCrossEdge(TSIn& SIn) : EId(SIn), SrcNId(SIn), DstNId(SIn) { }
140  void Save(TSOut& SOut) const { EId.Save(SOut); SrcNId.Save(SOut); DstNId.Save(SOut); }
141  int GetId() const { return EId; }
142  int GetSrcNId() const { return SrcNId; }
143  int GetDstNId() const { return DstNId; }
144  size_t GetMemUsed() const { return EId.GetMemUsed() + SrcNId.GetMemUsed() + DstNId.GetMemUsed(); }
145  friend class TCrossNet;
146  };
148  class TCrossEdgeI {
149  private:
152  const TCrossNet *Graph;
153  public:
154  TCrossEdgeI() : CrossHI(), Graph(NULL) { }
155  TCrossEdgeI(const THashIter& CrossHIter, const TCrossNet *GraphPt) : CrossHI(CrossHIter), Graph(GraphPt) { }
156  TCrossEdgeI(const TCrossEdgeI& EdgeI) : CrossHI(EdgeI.CrossHI), Graph(EdgeI.Graph) { }
157  TCrossEdgeI& operator = (const TCrossEdgeI& EdgeI) { if (this!=&EdgeI) { CrossHI=EdgeI.CrossHI; Graph=EdgeI.Graph; } return *this; }
159  TCrossEdgeI& operator++ (int) { CrossHI++; return *this; }
160  bool operator < (const TCrossEdgeI& EdgeI) const { return CrossHI < EdgeI.CrossHI; }
161  bool operator == (const TCrossEdgeI& EdgeI) const { return CrossHI == EdgeI.CrossHI; }
163  int GetId() const { return CrossHI.GetDat().GetId(); }
165  int GetSrcNId() const { return CrossHI.GetDat().GetSrcNId(); }
167  int GetDstNId() const { return CrossHI.GetDat().GetDstNId(); }
168 
170  int GetSrcModeId() const { return Graph->GetMode1(); }
172  int GetDstModeId() const { return Graph->GetMode2(); }
174  bool IsDirected() const { return Graph->IsDirected(); }
175 
176 
177  friend class TCrossNet;
178  };
179 
181  class TAIntI {
182  private:
186  const TCrossNet *Graph;
187  public:
188  TAIntI() : HI(), attr(), Graph(NULL) { }
189  TAIntI(const TIntVecIter& HIter, TStr attribute, const TCrossNet* GraphPt) : HI(HIter), attr(), Graph(GraphPt) { attr = attribute; }
190  TAIntI(const TAIntI& I) : HI(I.HI), attr(I.attr), Graph(I.Graph) { }
191  TAIntI& operator = (const TAIntI& I) { HI = I.HI; Graph=I.Graph; attr = I.attr; return *this; }
192  bool operator < (const TAIntI& I) const { return HI < I.HI; }
193  bool operator == (const TAIntI& I) const { return HI == I.HI; }
195  TInt GetDat() const { return HI[0]; }
197  bool IsDeleted() const { return GetDat() == Graph->GetIntAttrDefaultE(attr); };
198  TAIntI& operator++(int) { HI++; return *this; }
199  friend class TCrossNet;
200  };
201 
203  class TAStrI {
204  private:
208  const TCrossNet *Graph;
209  public:
210  TAStrI() : HI(), attr(), Graph(NULL) { }
211  TAStrI(const TStrVecIter& HIter, TStr attribute, const TCrossNet* GraphPt) : HI(HIter), attr(), Graph(GraphPt) { attr = attribute; }
212  TAStrI(const TAStrI& I) : HI(I.HI), attr(I.attr), Graph(I.Graph) { }
213  TAStrI& operator = (const TAStrI& I) { HI = I.HI; Graph=I.Graph; attr = I.attr; return *this; }
214  bool operator < (const TAStrI& I) const { return HI < I.HI; }
215  bool operator == (const TAStrI& I) const { return HI == I.HI; }
217  TStr GetDat() const { return HI[0]; }
219  bool IsDeleted() const { return GetDat() == Graph->GetStrAttrDefaultE(attr); };
220  TAStrI& operator++(int) { HI++; return *this; }
221  friend class TCrossNet;
222  };
223 
225  class TAFltI {
226  private:
230  const TCrossNet *Graph;
231  public:
232  TAFltI() : HI(), attr(), Graph(NULL) { }
233  TAFltI(const TFltVecIter& HIter, TStr attribute, const TCrossNet* GraphPt) : HI(HIter), attr(), Graph(GraphPt) { attr = attribute; }
234  TAFltI(const TAFltI& I) : HI(I.HI), attr(I.attr), Graph(I.Graph) { }
235  TAFltI& operator = (const TAFltI& I) { HI = I.HI; Graph=I.Graph; attr = I.attr; return *this; }
236  bool operator < (const TAFltI& I) const { return HI < I.HI; }
237  bool operator == (const TAFltI& I) const { return HI == I.HI; }
239  TFlt GetDat() const { return HI[0]; }
241  bool IsDeleted() const { return GetDat() == Graph->GetFltAttrDefaultE(attr); };
242  TAFltI& operator++(int) { HI++; return *this; }
243  friend class TCrossNet;
244  };
245 private:
260  enum { IntType, StrType, FltType };
261 public:
264  TCrossNet(TInt MId1, TInt MId2, TInt LId) : CrossH(), MxEId(0), Mode1(MId1), Mode2(MId2), IsDirect(true),CrossNetId(LId), Net(),
266  TCrossNet(TInt MId1, TInt MId2, TBool IsDir, TInt LId) : CrossH(), MxEId(0), Mode1(MId1), Mode2(MId2), IsDirect(IsDir),CrossNetId(LId), Net(),
268  TCrossNet(TSIn& SIn) : CrossH(SIn), MxEId(SIn), Mode1(SIn), Mode2(SIn), IsDirect(SIn), CrossNetId(SIn), Net(),
270  TCrossNet(const TCrossNet& OtherTCrossNet) : CrossH(OtherTCrossNet.CrossH), MxEId(OtherTCrossNet.MxEId), Mode1(OtherTCrossNet.Mode1),
271  Mode2(OtherTCrossNet.Mode2), IsDirect(OtherTCrossNet.IsDirect), CrossNetId(OtherTCrossNet.CrossNetId),Net(OtherTCrossNet.Net), KeyToIndexTypeE(OtherTCrossNet.KeyToIndexTypeE),
272  IntDefaultsE(OtherTCrossNet.IntDefaultsE), StrDefaultsE(OtherTCrossNet.StrDefaultsE), FltDefaultsE(OtherTCrossNet.FltDefaultsE), VecOfIntVecsE(OtherTCrossNet.VecOfIntVecsE),
273  VecOfStrVecsE(OtherTCrossNet.VecOfStrVecsE), VecOfFltVecsE(OtherTCrossNet.VecOfFltVecsE) {}
274 
275  TCrossNet& operator=(const TCrossNet& OtherTCrossNet) {
276  CrossH = OtherTCrossNet.CrossH;
277  MxEId = OtherTCrossNet.MxEId;
278  Mode1 = OtherTCrossNet.Mode1;
279  Mode2 = OtherTCrossNet.Mode2;
280  CrossNetId = OtherTCrossNet.CrossNetId;
281  IsDirect = OtherTCrossNet.IsDirect;
282  Net = OtherTCrossNet.Net;
283  KeyToIndexTypeE = OtherTCrossNet.KeyToIndexTypeE;
284  IntDefaultsE = OtherTCrossNet.IntDefaultsE;
285  StrDefaultsE = OtherTCrossNet.StrDefaultsE;
286  FltDefaultsE = OtherTCrossNet.FltDefaultsE;
287  VecOfIntVecsE = OtherTCrossNet.VecOfIntVecsE;
288  VecOfStrVecsE = OtherTCrossNet.VecOfStrVecsE;
289  VecOfFltVecsE = OtherTCrossNet.VecOfFltVecsE;
290  return *this;
291  }
292 
293 private:
294  void SetParentPointer(TMMNet* parent);
296  TInt GetIntAttrDefaultE(const TStr& attribute) const { return IntDefaultsE.IsKey(attribute) ? IntDefaultsE.GetDat(attribute) : (TInt) TInt::Mn; }
298  TStr GetStrAttrDefaultE(const TStr& attribute) const { return StrDefaultsE.IsKey(attribute) ? StrDefaultsE.GetDat(attribute) : (TStr) TStr::GetNullStr(); }
300  TFlt GetFltAttrDefaultE(const TStr& attribute) const { return FltDefaultsE.IsKey(attribute) ? FltDefaultsE.GetDat(attribute) : (TFlt) TFlt::Mn; }
301  int GetAttrTypeE(const TStr& attr) const;
302  TCrossEdge& GetEdge(int eid) { return CrossH[eid]; }
303 public:
305  bool IsEdge(const int& EId) const { return CrossH.IsKey(EId); }
306 
307  int GetMxEId() const { return MxEId; }
309  int GetEdges() const { return CrossH.Len(); }
311  void Clr();
312 
314  int AddEdge(const int& sourceNId, const int& destNId, int EId=-1);
316  TCrossEdgeI GetEdgeI(const int& EId) const { return TCrossEdgeI(CrossH.GetI(EId), this); }
317  TCrossEdgeI BegEdgeI() const { return TCrossEdgeI(CrossH.BegI(), this); }
318  TCrossEdgeI EndEdgeI() const { return TCrossEdgeI(CrossH.EndI(), this); }
320  int DelEdge(const int& EId);
322  int GetMode1() const { return Mode1; }
324  int GetMode2() const {return Mode2; }
326  void Save(TSOut& SOut) const { CrossH.Save(SOut); MxEId.Save(SOut); Mode1.Save(SOut); Mode2.Save(SOut); IsDirect.Save(SOut); CrossNetId.Save(SOut);
328  VecOfStrVecsE.Save(SOut); VecOfFltVecsE.Save(SOut); }
329 
331  bool IsDirected() const { return IsDirect;}
333  void AttrNameEI(const TInt& EId, TStrV& Names) const {
334  AttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
335  void AttrNameEI(const TInt& EId, TStrIntPrH::TIter CrossHI, TStrV& Names) const;
337  void AttrValueEI(const TInt& EId, TStrV& Values) const {
338  AttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
339  void AttrValueEI(const TInt& EId, TStrIntPrH::TIter CrossHI, TStrV& Values) const;
341  void IntAttrNameEI(const TInt& EId, TStrV& Names) const {
342  IntAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
343  void IntAttrNameEI(const TInt& EId, TStrIntPrH::TIter CrossHI, TStrV& Names) const;
345  void IntAttrValueEI(const TInt& EId, TIntV& Values) const {
346  IntAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
347  void IntAttrValueEI(const TInt& EId, TStrIntPrH::TIter CrossHI, TIntV& Values) const;
348 
349 
351  void StrAttrNameEI(const TInt& EId, TStrV& Names) const {
352  StrAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
353  void StrAttrNameEI(const TInt& EId, TStrIntPrH::TIter CrossHI, TStrV& Names) const;
355  void StrAttrValueEI(const TInt& EId, TStrV& Values) const {
356  StrAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
357  void StrAttrValueEI(const TInt& EId, TStrIntPrH::TIter CrossHI, TStrV& Values) const;
359  void FltAttrNameEI(const TInt& EId, TStrV& Names) const {
360  FltAttrNameEI(EId, KeyToIndexTypeE.BegI(), Names);}
361  void FltAttrNameEI(const TInt& EId, TStrIntPrH::TIter CrossHI, TStrV& Names) const;
363  void FltAttrValueEI(const TInt& EId, TFltV& Values) const {
364  FltAttrValueEI(EId, KeyToIndexTypeE.BegI(), Values);}
365  void FltAttrValueEI(const TInt& EId, TStrIntPrH::TIter CrossHI, TFltV& Values) const;
366 
368  int AddIntAttrDatE(const TCrossEdgeI& EdgeI, const TInt& value, const TStr& attr) { return AddIntAttrDatE(EdgeI.GetId(), value, attr); }
369  int AddIntAttrDatE(const int& EId, const TInt& value, const TStr& attr);
371  int AddStrAttrDatE(const TCrossEdgeI& EdgeI, const TStr& value, const TStr& attr) { return AddStrAttrDatE(EdgeI.GetId(), value, attr); }
372  int AddStrAttrDatE(const int& EId, const TStr& value, const TStr& attr);
374  int AddFltAttrDatE(const TCrossEdgeI& EdgeI, const TFlt& value, const TStr& attr) { return AddFltAttrDatE(EdgeI.GetId(), value, attr); }
375  int AddFltAttrDatE(const int& EId, const TFlt& value, const TStr& attr);
376 
378  TInt GetIntAttrDatE(const TCrossEdgeI& EdgeI, const TStr& attr) { return GetIntAttrDatE(EdgeI.GetId(), attr); }
379  TInt GetIntAttrDatE(const int& EId, const TStr& attr);
381  TStr GetStrAttrDatE(const TCrossEdgeI& EdgeI, const TStr& attr) { return GetStrAttrDatE(EdgeI.GetId(), attr); }
382  TStr GetStrAttrDatE(const int& EId, const TStr& attr);
384  TFlt GetFltAttrDatE(const TCrossEdgeI& EdgeI, const TStr& attr) { return GetFltAttrDatE(EdgeI.GetId(), attr); }
385  TFlt GetFltAttrDatE(const int& EId, const TStr& attr);
386 
388  TAIntI BegEAIntI(const TStr& attr) const {
389  return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, this);
390  }
392  TAIntI EndEAIntI(const TStr& attr) const {
393  return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr, this);
394  }
396  TAIntI GetEAIntI(const TStr& attr, const int& EId) const {
397  return TAIntI(VecOfIntVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(CrossH.GetKeyId(EId)), attr, this);
398  }
399 
401  TAStrI BegEAStrI(const TStr& attr) const {
402  return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, this); }
404  TAStrI EndEAStrI(const TStr& attr) const {
405  return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr, this);
406  }
408  TAStrI GetEAStrI(const TStr& attr, const int& EId) const {
409  return TAStrI(VecOfStrVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(CrossH.GetKeyId(EId)), attr, this);
410  }
412  TAFltI BegEAFltI(const TStr& attr) const {
413  return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].BegI(), attr, this);
414  }
416  TAFltI EndEAFltI(const TStr& attr) const {
417  return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].EndI(), attr, this);
418  }
420  TAFltI GetEAFltI(const TStr& attr, const int& EId) const {
421  return TAFltI(VecOfFltVecsE[KeyToIndexTypeE.GetDat(attr).Val2].GetI(CrossH.GetKeyId(EId)), attr, this);
422  }
423 
425  int DelAttrDatE(const TCrossEdgeI& EdgeI, const TStr& attr) { return DelAttrDatE(EdgeI.GetId(), attr); }
426  int DelAttrDatE(const int& EId, const TStr& attr);
427 
429  int AddIntAttrE(const TStr& attr, TInt defaultValue=TInt::Mn);
431  int AddStrAttrE(const TStr& attr, TStr defaultValue=TStr::GetNullStr());
433  int AddFltAttrE(const TStr& attr, TFlt defaultValue=TFlt::Mn);
434 
436  int DelAttrE(const TStr& attr);
437 
438  // Returns true if \c attr exists for edge \c EId and has default value.
439  bool IsAttrDeletedE(const int& EId, const TStr& attr) const;
440  // Returns true if Int \c attr exists for edge \c EId and has default value.
441  bool IsIntAttrDeletedE(const int& EId, const TStr& attr) const;
442  // Returns true if Str \c attr exists for edge \c NId and has default value.
443  bool IsStrAttrDeletedE(const int& EId, const TStr& attr) const;
444  // Returns true if Flt \c attr exists for edge \c NId and has default value.
445  bool IsFltAttrDeletedE(const int& EId, const TStr& attr) const;
446 
447  // Returns true if EId attr deleted for current edge attr iterator.
448  bool EdgeAttrIsDeleted(const int& EId, const TStrIntPrH::TIter& CrossHI) const;
449  // Returns true if EId attr deleted for current edge int attr iterator.
450  bool EdgeAttrIsIntDeleted(const int& EId, const TStrIntPrH::TIter& CrossHI) const;
451  // Returns true if EId attr deleted for current edge str attr iterator.
452  bool EdgeAttrIsStrDeleted(const int& EId, const TStrIntPrH::TIter& CrossHI) const;
453  // Returns true if EId attr deleted for current edge flt attr iterator.
454  bool EdgeAttrIsFltDeleted(const int& EId, const TStrIntPrH::TIter& CrossHI) const;
455 
456  // Returns edge attribute value, converted to Str type.
457  TStr GetEdgeAttrValue(const int& EId, const TStrIntPrH::TIter& CrossHI) const;
458 
459  friend class TMMNet;
460  friend class TModeNet;
461 };
462 
463 //#///////////////////////////////////////////////
465 
468 class TMMNet {
469 
470 public:
472  class TModeNetI {
473  protected:
476  const TMMNet *Graph;
477  public:
478  TModeNetI() : ModeNetHI(), Graph(NULL) { }
479  TModeNetI(const THashIter& ModeNetHIter, const TMMNet* GraphPt) : ModeNetHI(ModeNetHIter), Graph(GraphPt) { }
480  TModeNetI(const TModeNetI& ModeNetI) : ModeNetHI(ModeNetI.ModeNetHI), Graph(ModeNetI.Graph) { }
481  TModeNetI& operator = (const TModeNetI& ModeNetI) { ModeNetHI = ModeNetI.ModeNetHI; Graph=ModeNetI.Graph; return *this; }
483  TModeNetI& operator++ (int) { ModeNetHI++; return *this; }
484  bool operator < (const TModeNetI& ModeNetI) const { return ModeNetHI < ModeNetI.ModeNetHI; }
485  bool operator == (const TModeNetI& ModeNetI) const { return ModeNetHI == ModeNetI.ModeNetHI; }
487  int GetModeId() { return ModeNetHI.GetKey(); }
489  TStr GetModeName() { return Graph->GetModeName(ModeNetHI.GetKey()); }
492  friend class TMMNet;
493  };
494 
496  class TCrossNetI {
497  protected:
500  const TMMNet *Graph;
501  public:
502  TCrossNetI() : CrossNetHI(), Graph(NULL) { }
503  TCrossNetI(const THashIter& CrossNetHIter, const TMMNet* GraphPt) : CrossNetHI(CrossNetHIter), Graph(GraphPt) { }
504  TCrossNetI(const TCrossNetI& CrossNetI) : CrossNetHI(CrossNetI.CrossNetHI), Graph(CrossNetI.Graph) { }
505  TCrossNetI& operator = (const TCrossNetI& CrossNetI) { CrossNetHI = CrossNetI.CrossNetHI; Graph=CrossNetI.Graph; return *this; }
507  TCrossNetI& operator++ (int) { CrossNetHI++; return *this; }
508  bool operator < (const TCrossNetI& CrossNetI) const { return CrossNetHI < CrossNetI.CrossNetHI; }
509  bool operator == (const TCrossNetI& CrossNetI) const { return CrossNetHI == CrossNetI.CrossNetHI; }
511  int GetCrossId() { return CrossNetHI.GetKey(); }
513  TStr GetCrossName() { return Graph->GetCrossName(CrossNetHI.GetKey()); }
516  friend class TMMNet;
517  };
518 
519 public:
520  TCRef CRef; //Reference counter. Necessary for pointers.
521 
522 private:
523 
528 
531 
534 
535 public:
536  friend class TCrossNet;
537  friend class TModeNet;
538 
539 public:
541  TMMNet(const TMMNet& OtherTMMNet) : MxModeId(OtherTMMNet.MxModeId), MxCrossNetId(OtherTMMNet.MxCrossNetId), TModeNetH(OtherTMMNet.TModeNetH),
542  TCrossNetH(OtherTMMNet.TCrossNetH), ModeIdToNameH(OtherTMMNet.ModeIdToNameH), ModeNameToIdH(OtherTMMNet.ModeNameToIdH), CrossIdToNameH(OtherTMMNet.CrossIdToNameH), CrossNameToIdH(OtherTMMNet.CrossNameToIdH) {}
544  for (THash<TInt, TModeNet>::TIter it = TModeNetH.BegI(); it < TModeNetH.EndI(); it++) {
545  it.GetDat().SetParentPointer(this);
546  }
547  for (THash<TInt, TCrossNet>::TIter it = TCrossNetH.BegI(); it < TCrossNetH.EndI(); it++) {
548  it.GetDat().SetParentPointer(this);
549  }
550  }
552  int AddModeNet(const TStr& ModeName);
554  int DelModeNet(const TInt& ModeId);
555  int DelModeNet(const TStr& ModeName);
557  int AddCrossNet(const TStr& ModeName1, const TStr& ModeName2, const TStr& CrossNetName, bool isDir=true);
558  int AddCrossNet(const TInt& ModeId1, const TInt& ModeId2, const TStr& CrossNetName, bool isDir=true);
560  int DelCrossNet(const TInt& CrossNetId);
561  int DelCrossNet(const TStr& CrossNet);
562 
564  void Save(TSOut& SOut) const {MxModeId.Save(SOut); MxCrossNetId.Save(SOut); TModeNetH.Save(SOut);
566  CrossNameToIdH.Save(SOut); }
568  static PMMNet Load(TSIn& SIn) { return PMMNet(new TMMNet(SIn)); }
569  static PMMNet New() { return PMMNet(new TMMNet()); }
570 
572  int GetModeId(const TStr& ModeName) const { if (ModeNameToIdH.IsKey(ModeName)) { return ModeNameToIdH.GetDat(ModeName); } else { return -1; } }
574  TStr GetModeName(const TInt& ModeId) const { if (ModeIdToNameH.IsKey(ModeId)) { return ModeIdToNameH.GetDat(ModeId); } else {return TStr::GetNullStr();} }
576  int GetCrossId(const TStr& CrossName) const { if (CrossNameToIdH.IsKey(CrossName)) { return CrossNameToIdH.GetDat(CrossName); } else { return -1; } }
578  TStr GetCrossName(const TInt& CrossId) const { if (CrossIdToNameH.IsKey(CrossId)) { return CrossIdToNameH.GetDat(CrossId); } else { return TStr::GetNullStr(); } }
579 
581  TModeNet& GetModeNetByName(const TStr& ModeName) const;
582  TModeNet& GetModeNetById(const TInt& ModeId) const;
583 
585  TCrossNet& GetCrossNetByName(const TStr& CrossName) const;
586  TCrossNet& GetCrossNetById(const TInt& CrossId) const;
587 
589  TCrossNetI GetCrossNetI(const int& Id) const { return TCrossNetI(TCrossNetH.GetI(Id), this); }
590  TCrossNetI BegCrossNetI() const { return TCrossNetI(TCrossNetH.BegI(), this); }
591  TCrossNetI EndCrossNetI() const { return TCrossNetI(TCrossNetH.EndI(), this); }
592 
594  TModeNetI GetModeNetI(const int& Id) const { return TModeNetI(TModeNetH.GetI(Id), this); }
595  TModeNetI BegModeNetI() const { return TModeNetI(TModeNetH.BegI(), this); }
596  TModeNetI EndModeNetI() const { return TModeNetI(TModeNetH.EndI(), this); }
597 
599  int GetModeNets() { return TModeNetH.Len(); }
601  int GetCrossNets() { return TCrossNetH.Len(); }
602 
604  PMMNet GetSubgraphByCrossNet(TStrV& CrossNetTypes);
606  PMMNet GetSubgraphByModeNet(TStrV& ModeNetTypes);
607 
609  PNEANet ToNetwork(TIntV& CrossNetTypes, TIntStrStrTrV& NodeAttrMap, TVec<TTriple<TInt, TStr, TStr> >& EdgeAttrMap);
611  PNEANet ToNetwork2(TIntV& CrossNetTypes, TIntStrPrVH& NodeAttrMap, THash<TInt, TVec<TPair<TStr, TStr> > >& EdgeAttrMap);
612 
613  #ifdef GCC_ATOMIC
614  PNEANetMP ToNetworkMP(TStrV& CrossNetNames);
615  #endif // GCC_ATOMIC
616 
617 private:
618  void ClrNbr(const TInt& ModeId, const TInt& CrossNetId, const bool& outEdge, const bool& sameMode, bool& isDir);
619  int AddMode(const TStr& ModeName, const TInt& ModeId, const TModeNet& ModeNet);
620  int AddCrossNet(const TStr& CrossNetName, const TInt& CrossNetId, const TCrossNet& CrossNet);
621  int AddNodeAttributes(PNEANet& NewNet, TModeNet& Net, TVec<TPair<TStr, TStr> >& Attrs, int ModeId, int oldId, int NId);
622  int AddEdgeAttributes(PNEANet& NewNet, TCrossNet& Net, TVec<TPair<TStr, TStr> >& Attrs, int CrossId, int oldId, int EId);
623  void GetPartitionRanges(TIntPrV& Partitions, const TInt& NumPartitions, const TInt& MxVal) const;
624 };
625 
626 // set flags
627 namespace TSnap {
628 template <> struct IsMultiGraph<TModeNet> { enum { Val = 1 }; };
629 template <> struct IsDirected<TModeNet> { enum { Val = 1 }; };
630 }
631 #endif // MMNET_H
TCrossNet & GetCrossNet()
Gets a reference to the crossnet.
Definition: mmnet.h:515
Definition: bd.h:440
TVec< TIntV > VecOfIntVecsN
Definition: network.h:1870
TStr GetStrAttrDatE(const TCrossEdgeI &EdgeI, const TStr &attr)
Gets the value of str attr from the edge attr value vector.
Definition: mmnet.h:381
TModeNetI GetModeNetI(const int &Id) const
Iterator over all modenets.
Definition: mmnet.h:594
bool operator<(const TNodeI &NodeI) const
Definition: mmnet.h:36
int GetId() const
Returns edge ID.
Definition: mmnet.h:163
TIter EndI() const
Returns an iterator referring to the past-the-end element in the vector.
Definition: ds.h:567
int AddFltAttrDatE(const TCrossEdgeI &EdgeI, const TFlt &value, const TStr &attr)
Attribute based add function for attr to Flt value.
Definition: mmnet.h:374
TMMNet(TSIn &SIn)
Definition: mmnet.h:543
TCrossEdgeI(const TCrossEdgeI &EdgeI)
Definition: mmnet.h:156
TCrossNet(TSIn &SIn)
Definition: mmnet.h:268
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...
Definition: mmnet.cpp:965
THash< TStr, TFlt > FltDefaultsE
Definition: network.h:1869
bool IsFltAttrDeletedE(const int &EId, const TStr &attr) const
Definition: mmnet.cpp:382
void FltAttrValueEI(const TInt &EId, TFltV &Values) const
Returns a vector of attr values for node NId.
Definition: mmnet.h:363
bool operator<(const TCrossNetI &CrossNetI) const
Definition: mmnet.h:508
int GetModeId(const TStr &ModeName) const
Gets the mode id from the mode name.
Definition: mmnet.h:572
TStrIntPrH KeyToIndexTypeE
Definition: mmnet.h:253
bool IsDeleted() const
Returns true if the attribute has been deleted.
Definition: mmnet.h:241
int AddStrAttrDatE(const TCrossEdgeI &EdgeI, const TStr &value, const TStr &attr)
Attribute based add function for attr to Str value.
Definition: mmnet.h:371
TAIntI GetEAIntI(const TStr &attr, const int &EId) const
Returns an iterator referring to the edge of ID EId in the graph.
Definition: mmnet.h:396
TVec< TStrV > VecOfStrVecsE
Definition: network.h:1871
THash< TStr, TFlt > FltDefaultsE
Definition: mmnet.h:256
THash< TStr, TInt > IntDefaultsE
Definition: network.h:1867
int DelCrossNet(const TInt &CrossNetId)
Deletes a crossnet from the multimodal network.
Definition: mmnet.cpp:645
TModeNet iterator. Only forward iteration (operator++) is supported.
Definition: mmnet.h:472
TCrossNetI EndCrossNetI() const
Definition: mmnet.h:591
TFltV::TIter TFltVecIter
Definition: mmnet.h:227
TModeNet TNetMM
Definition: mmnet.h:25
void FltAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for node NId.
Definition: mmnet.h:359
TInt MxModeId
Definition: mmnet.h:524
const TCrossNet * Graph
Definition: mmnet.h:230
TModeNetI(const THashIter &ModeNetHIter, const TMMNet *GraphPt)
Definition: mmnet.h:479
Node iterator. Only forward iteration (operator++) is supported.
Definition: mmnet.h:28
TVec< TIntV > VecOfIntVecsE
Definition: mmnet.h:257
Definition: ds.h:129
void GetNeighborsByCrossNet(TStr &Name, TIntV &Neighbors, const bool isOutEId=false)
Gets the neighbors (NIds) for the given node for the given CrossNet type.
Definition: mmnet.h:39
TCrossNet(const TCrossNet &OtherTCrossNet)
Definition: mmnet.h:270
TModeNet & GetModeNet()
Gets a reference to the modenet.
Definition: mmnet.h:491
bool EdgeAttrIsStrDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
Definition: mmnet.cpp:399
void GetPartitionRanges(TIntPrV &Partitions, const TInt &NumPartitions, const TInt &MxVal) const
Definition: mmnet.cpp:1052
void AttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for edge EId.
Definition: mmnet.h:337
void Save(TSOut &SOut) const
Definition: dt.h:1060
TStr GetCrossName()
Gets the name of the crossnet.
Definition: mmnet.h:513
PMMNet GetSubgraphByCrossNet(TStrV &CrossNetTypes)
Gets the induced subgraph given a vector of crossnet type names.
Definition: mmnet.cpp:728
THash< TInt, TModeNet >::TIter THashIter
Definition: mmnet.h:474
int GetSrcModeId() const
Returns the source mode of the crossnet.
Definition: mmnet.h:170
THashIter CrossHI
Definition: mmnet.h:151
int GetSrcNId() const
Returns the source of the edge.
Definition: mmnet.h:165
THash< TInt, TNode >::TIter THashIter
Definition: network.h:1634
TNodeI GetMMNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
Definition: mmnet.h:80
void DelNode(const int &NId)
Deletes the given node from this mode.
Definition: mmnet.cpp:57
Tests (at compile time) if the graph is directed.
Definition: gbase.h:28
bool IsDeleted() const
Returns true if the attribute has been deleted.
Definition: mmnet.h:197
TMMNet * MMNet
Definition: mmnet.h:47
TIter BegI() const
Definition: hash.h:171
TAIntI BegEAIntI(const TStr &attr) const
Returns an iterator referring to the first edge's int attribute.
Definition: mmnet.h:388
bool operator==(const TCrossEdgeI &EdgeI) const
Definition: mmnet.h:161
TCrossNet()
Definition: mmnet.h:262
TAStrI(const TStrVecIter &HIter, TStr attribute, const TCrossNet *GraphPt)
Definition: mmnet.h:211
TCrossNet iterator. Only forward iteration (operator++) is supported.
Definition: mmnet.h:496
const TCrossNet * Graph
Definition: mmnet.h:152
TInt GetIntAttrDefaultE(const TStr &attribute) const
Gets Int edge attribute val. If not a proper attr, return default.
Definition: mmnet.h:296
THashIter CrossNetHI
Definition: mmnet.h:499
const TNEANet * Graph
Definition: network.h:1636
void Save(TSOut &SOut) const
Definition: hash.h:141
TStrVecIter HI
Definition: mmnet.h:206
TModeNet(const int &TypeId)
Definition: mmnet.h:52
TStrIntPrH KeyToIndexTypeE
Definition: network.h:1865
TCrossEdgeI BegEdgeI() const
Definition: mmnet.h:317
A single edge in the cross net. Has an Edge Id, and the source and destination node ids...
Definition: mmnet.h:129
bool operator==(const TAIntI &I) const
Definition: mmnet.h:193
TAttr SAttrN
Definition: network.h:1876
TMMNet * Net
Definition: mmnet.h:252
TFlt GetDat() const
Returns an attribute of the node.
Definition: mmnet.h:239
TAFltI BegEAFltI(const TStr &attr) const
Returns an iterator referring to the first edge's flt attribute.
Definition: mmnet.h:412
THash< TStr, TFlt > FltDefaultsN
Definition: network.h:1869
bool operator==(const TAStrI &I) const
Definition: mmnet.h:215
TAIntI & operator++(int)
Definition: mmnet.h:198
void Save(TSOut &SOut) const
Definition: dt.h:902
int DelNeighbor(const int &NId, const int &EId, bool outEdge, const TStr &CrossName, const bool sameMode, bool isDir)
Definition: mmnet.cpp:44
int GetModeId()
Gets the mode id.
Definition: mmnet.h:487
TInt MxNId
Definition: network.h:1861
TModeNet(const int &Nodes, const int &Edges, const int &TypeId)
Definition: mmnet.h:56
static PMMNet Load(TSIn &SIn)
Loads the TMMNet from binary stream.
Definition: mmnet.h:568
TAStrI GetEAStrI(const TStr &attr, const int &EId) const
Returns an iterator referring to the edge of ID EId in the graph.
Definition: mmnet.h:408
bool operator<(const TAStrI &I) const
Definition: mmnet.h:214
Edge iterator. Only forward iteration (operator++) is supported.
Definition: mmnet.h:148
const TDat & GetDat(const TKey &Key) const
Definition: hash.h:220
Node iterator. Only forward iteration (operator++) is supported.
Definition: network.h:1632
TVec< TIntV > VecOfIntVecsE
Definition: network.h:1870
TIter EndI() const
Definition: hash.h:176
TCrossEdge & GetEdge(int eid)
Definition: mmnet.h:302
THash< TInt, TStr > ModeIdToNameH
Definition: mmnet.h:529
int DelEdge(const int &EId)
Deletes an edge by its id.
Definition: mmnet.cpp:256
TAStrI EndEAStrI(const TStr &attr) const
Returns an iterator referring to the past-the-end edge's attribute.
Definition: mmnet.h:404
int DelAttrDatE(const TCrossEdgeI &EdgeI, const TStr &attr)
Deletes the edge attribute for NodeI.
Definition: mmnet.h:425
THash< TInt, TCrossNet > TCrossNetH
Definition: mmnet.h:527
TCRef CRef
Definition: mmnet.h:520
int DelModeNet(const TInt &ModeId)
Deletes a mode from the multimodal network.
Definition: mmnet.cpp:664
bool operator==(const TModeNetI &ModeNetI) const
Definition: mmnet.h:485
TAIntI EndEAIntI(const TStr &attr) const
Returns an iterator referring to the past-the-end edge's attribute.
Definition: mmnet.h:392
bool EdgeAttrIsDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
Definition: mmnet.cpp:386
TCrossEdgeI EndEdgeI() const
Definition: mmnet.h:318
const TCrossNet * Graph
Definition: mmnet.h:186
int GetDstNId() const
Definition: mmnet.h:143
TFlt GetFltAttrDefaultE(const TStr &attribute) const
Gets Flt edge attribute val. If not a proper attr, return default.
Definition: mmnet.h:300
TCrossNetI BegCrossNetI() const
Definition: mmnet.h:590
bool operator<(const TAIntI &I) const
Definition: mmnet.h:192
TCrossEdgeI & operator=(const TCrossEdgeI &EdgeI)
Definition: mmnet.h:157
TModeNet(const TModeNet &Graph)
Definition: mmnet.h:58
Definition: dt.h:1293
TVec< TStrV > VecOfStrVecsN
Definition: network.h:1871
TNodeI & operator=(const TNodeI &NodeI)
Definition: mmnet.h:33
TCrossNet(TInt MId1, TInt MId2, TBool IsDir, TInt LId)
Definition: mmnet.h:266
Definition: fl.h:58
TAStrI BegEAStrI(const TStr &attr) const
Returns an iterator referring to the first edge's str attribute.
Definition: mmnet.h:401
void Save(TSOut &SOut) const
Definition: ds.h:903
TCrossEdge(const int &Id, const int &SourceNId, const int &DestNId)
Definition: mmnet.h:135
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 ...
Definition: mmnet.cpp:803
bool operator==(const TAFltI &I) const
Definition: mmnet.h:237
THash< TInt, TEdge > EdgeH
Definition: network.h:1863
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...
Definition: mmnet.cpp:106
void IntAttrValueEI(const TInt &EId, TIntV &Values) const
Returns a vector of attr values for edge EId.
Definition: mmnet.h:345
TCrossNetI(const TCrossNetI &CrossNetI)
Definition: mmnet.h:504
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.
Definition: mmnet.cpp:620
Node/edge float attribute iterator. Iterates through all nodes/edges for one float attribute...
Definition: mmnet.h:225
int AddModeNet(const TStr &ModeName)
Adds a mode to the multimodal network.
Definition: mmnet.cpp:605
TModeNet(const int &Nodes, const int &Edges)
Constructor that reserves enough memory for a graph of nodes and edges.
Definition: mmnet.h:54
int GetCrossNets()
Returns the number of crossnets in the multimodal network.
Definition: mmnet.h:601
THash< TStr, TStr > StrDefaultsE
Definition: mmnet.h:255
TModeNet & operator=(const TModeNet &Graph)
Definition: mmnet.h:85
int GetId() const
Definition: mmnet.h:141
TAttr SAttrE
Definition: network.h:1877
const TMMNet * Graph
Definition: mmnet.h:500
int GetId() const
Returns ID of the current node.
Definition: network.h:1647
static const int Mn
Definition: dt.h:1048
bool IsDeleted() const
Returns true if the attribute has been deleted.
Definition: mmnet.h:219
TVec< TStrV > VecOfStrVecsE
Definition: mmnet.h:258
TNodeI EndMMNI() const
Returns an iterator referring to the past-the-end node in the graph.
Definition: mmnet.h:78
int AddIntAttrDatE(const TCrossEdgeI &EdgeI, const TInt &value, const TStr &attr)
Attribute based add function for attr to Int value.
Definition: mmnet.h:368
THash< TStr, TInt > ModeNameToIdH
Definition: mmnet.h:530
TCrossNetI GetCrossNetI(const int &Id) const
Iterator over all crossnets.
Definition: mmnet.h:589
void StrAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of str attr names for node NId.
Definition: mmnet.h:351
TVec< TFltV > VecOfFltVecsE
Definition: network.h:1872
TInt ModeId
Definition: mmnet.h:46
TStrIntPrH KeyToIndexTypeN
KeyToIndexType[N|E]: Key->(Type,Index).
Definition: network.h:1865
void GetCrossNetNames(TStrV &Names)
Gets all the CrossNets that include the given node.
Definition: mmnet.h:42
void GetCrossNetNames(TStrV &Names) const
Gets a list of CrossNets that have this Mode as either a source or destination type.
Definition: mmnet.h:71
TAFltI GetEAFltI(const TStr &attr, const int &EId) const
Returns an iterator referring to the edge of ID EId in the graph.
Definition: mmnet.h:420
TAFltI & operator=(const TAFltI &I)
Definition: mmnet.h:235
int GetMode2() const
Gets the id of the dst mode.
Definition: mmnet.h:324
TAFltI & operator++(int)
Definition: mmnet.h:242
TFltVecIter HI
Definition: mmnet.h:228
TAFltI(const TFltVecIter &HIter, TStr attribute, const TCrossNet *GraphPt)
Definition: mmnet.h:233
void RemoveCrossNets(TModeNet &Result, TStrV &CrossNets)
Definition: mmnet.cpp:126
TCrossNet(TInt MId1, TInt MId2, TInt LId)
Definition: mmnet.h:264
int GetSrcNId() const
Definition: mmnet.h:142
TCrossEdge(const TCrossEdge &MultiEdge)
Definition: mmnet.h:137
bool operator==(const TNodeI &NodeI) const
Definition: mmnet.h:37
THash< TInt, TCrossNet >::TIter THashIter
Definition: mmnet.h:498
TCrossEdgeI & operator++(int)
Increment iterator.
Definition: mmnet.h:159
THash< TStr, TInt > CrossNameToIdH
Definition: mmnet.h:533
Node/edge integer attribute iterator. Iterates through all nodes/edges for one integer attribute...
Definition: mmnet.h:181
THashIter ModeNetHI
Definition: mmnet.h:475
int AddNbrType(const TStr &CrossName, const bool sameMode, bool isDir)
Definition: mmnet.cpp:82
int AddStrAttrE(const TStr &attr, TStr defaultValue=TStr::GetNullStr())
Adds a new Str edge attribute to the hashmap.
Definition: mmnet.cpp:542
int GetModeNets()
Returns the number of modes in the multimodal network.
Definition: mmnet.h:599
TInt GetDat() const
Returns an attribute of the node.
Definition: mmnet.h:195
TAFltI EndEAFltI(const TStr &attr) const
Returns an iterator referring to the past-the-end edge's attribute.
Definition: mmnet.h:416
TMMNet()
Definition: mmnet.h:540
bool operator<(const TCrossEdgeI &EdgeI) const
Definition: mmnet.h:160
THash< TStr, TStr > StrDefaultsN
Definition: network.h:1868
int AddFltAttrE(const TStr &attr, TFlt defaultValue=TFlt::Mn)
Adds a new Flt edge attribute to the hashmap.
Definition: mmnet.cpp:561
Tests (at compile time) if the graph is a multigraph with multiple edges between the same nodes...
Definition: gbase.h:30
Node/edge string attribute iterator. Iterates through all nodes/edges for one string attribute...
Definition: mmnet.h:203
TInt CrossNetId
Definition: mmnet.h:251
int DelNbrType(const TStr &CrossName)
Definition: mmnet.cpp:90
TStr GetModeName(const TInt &ModeId) const
Gets the mode name from the mode id.
Definition: mmnet.h:574
TNodeI BegMMNI() const
Returns an iterator referring to the first node in the graph.
Definition: mmnet.h:76
bool operator<(const TAFltI &I) const
Definition: mmnet.h:236
bool EdgeAttrIsIntDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
Definition: mmnet.cpp:393
bool EdgeAttrIsFltDeleted(const int &EId, const TStrIntPrH::TIter &CrossHI) const
Definition: mmnet.cpp:405
TCrossNetI & operator=(const TCrossNetI &CrossNetI)
Definition: mmnet.h:505
TModeNetI EndModeNetI() const
Definition: mmnet.h:596
void Clr()
Deletes all nodes and edges from the graph.
Definition: mmnet.cpp:174
TStr GetCrossName(const TInt &CrossId) const
Gets the crossnet name from the crossnet id.
Definition: mmnet.h:578
const TCrossNet * Graph
Definition: mmnet.h:208
int GetDstNId() const
Returns the destination of the edge.
Definition: mmnet.h:167
PNEANetMP ToNetworkMP(TStrV &CrossNetNames)
Definition: mmnet.cpp:1070
TVec< TVec< TIntV > > VecOfIntVecVecsE
Definition: network.h:1873
static TStr GetNullStr()
Definition: dt.cpp:1626
TStr GetDat() const
Returns an attribute of the node.
Definition: mmnet.h:217
THash< TStr, TInt > IntDefaultsE
Definition: mmnet.h:254
bool IsIntAttrDeletedE(const int &EId, const TStr &attr) const
Definition: mmnet.cpp:374
TStrV::TIter TStrVecIter
Definition: mmnet.h:205
int AddNodeAttributes(PNEANet &NewNet, TModeNet &Net, TVec< TPair< TStr, TStr > > &Attrs, int ModeId, int oldId, int NId)
Definition: mmnet.cpp:1249
int GetCrossId()
Gets the crossnet id.
Definition: mmnet.h:511
Directed multigraph with node edge attributes.
Definition: network.h:1591
Definition: fl.h:128
The nodes of one particular mode in a TMMNet, and their neighbor vectors as TIntV attributes...
Definition: mmnet.h:23
void Save(TSOut &SOut) const
Saves the TMMNet to binary stream.
Definition: mmnet.h:564
TInt MxEId
Definition: network.h:1861
TMMNet(const TMMNet &OtherTMMNet)
Definition: mmnet.h:541
THash< TInt, TCrossEdge >::TIter THashIter
Definition: mmnet.h:150
TModeNetI & operator=(const TModeNetI &ModeNetI)
Definition: mmnet.h:481
void ClrNbr(const TStr &CrossNetName, const bool &outEdge, const bool &sameMode, bool &isDir)
Definition: mmnet.cpp:15
TAFltI(const TAFltI &I)
Definition: mmnet.h:234
TModeNet()
Definition: mmnet.h:51
const TMMNet * Graph
Definition: mmnet.h:476
Definition: dt.h:1044
TVal * TIter
Random access iterator to TVal.
Definition: ds.h:431
THash< TInt, TModeNet > TModeNetH
Keeps track of the max crossnet id.
Definition: mmnet.h:526
TNodeI & operator++(int)
Increments the iterator.
Definition: mmnet.h:35
bool operator==(const TCrossNetI &CrossNetI) const
Definition: mmnet.h:509
int GetKeyId(const TKey &Key) const
Definition: hash.h:424
static PMMNet New()
Definition: mmnet.h:569
void AttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of attr names for edge EId.
Definition: mmnet.h:333
TPt< TMMNet > PMMNet
Definition: mmnet.h:5
void Save(TSOut &SOut) const
Saves the TCrossNet to the binary stream.
Definition: mmnet.h:326
TModeNet(const TModeNet &Graph, bool isSubModeGraph)
Definition: mmnet.h:62
void SetParentPointer(TMMNet *parent)
Definition: mmnet.cpp:280
THash< TStr, TBool > NeighborTypes
Definition: mmnet.h:48
void IntAttrNameEI(const TInt &EId, TStrV &Names) const
Returns a vector of int attr names for edge EId.
Definition: mmnet.h:341
TCrossNetI & operator++(int)
Increments iterator.
Definition: mmnet.h:507
TModeNetI BegModeNetI() const
Definition: mmnet.h:595
void Save(TSOut &SOut) const
Definition: mmnet.h:140
Definition: ds.h:32
int GetEdges() const
Returns the number of edges in the graph.
Definition: mmnet.h:309
int AddIntVAttrByVecN(const TStr &attr, TVec< TIntV > &Attrs)
Adds a new TIntV node attribute to the hashmap.
Definition: mmnet.cpp:117
TModeNet & GetModeNetById(const TInt &ModeId) const
Definition: mmnet.cpp:690
TCrossEdge(TSIn &SIn)
Definition: mmnet.h:139
bool IsDirected() const
Returns whether the edge is directed.
Definition: mmnet.h:174
TModeNetI & operator++(int)
Increment iterator.
Definition: mmnet.h:483
int GetMxEId() const
Definition: mmnet.h:307
THash< TStr, TStr > StrDefaultsE
Definition: network.h:1868
size_t GetMemUsed() const
Definition: mmnet.h:144
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...
Definition: mmnet.cpp:188
void GetKeyV(TVec< TKey > &KeyV) const
Definition: hash.h:442
TFlt GetFltAttrDatE(const TCrossEdgeI &EdgeI, const TStr &attr)
Gets the value of flt attr from the edge attr value vector.
Definition: mmnet.h:384
TAStrI(const TAStrI &I)
Definition: mmnet.h:212
TModeNet(TSIn &SIn)
Constructor for loading the graph from a (binary) stream SIn.
Definition: mmnet.h:60
void Save(TSOut &SOut) const
Saves the graph to a (binary) stream SOut. Expects data structures for sparse attributes.
Definition: network.h:1918
TAStrI & operator=(const TAStrI &I)
Definition: mmnet.h:213
Definition: dt.h:412
int GetMemUsed() const
Definition: dt.h:1076
bool IsStrAttrDeletedE(const int &EId, const TStr &attr) const
Definition: mmnet.cpp:378
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
Definition: ds.h:565
TInt Mode1
Definition: mmnet.h:248
TInt Mode2
The first mode. In the case of directed crossnets, this is implicitly understood to be the source mod...
Definition: mmnet.h:249
TVec< TFltV > VecOfFltVecsN
Definition: network.h:1872
TNodeI(const THashIter &NodeHIter, const TModeNet *GraphPt)
Definition: mmnet.h:31
TCrossEdgeI GetEdgeI(const int &EId) const
Edge iterators.
Definition: mmnet.h:316
int GetCrossId(const TStr &CrossName) const
Gets the crossnet id from the crossnet name.
Definition: mmnet.h:576
bool operator<(const TModeNetI &ModeNetI) const
Definition: mmnet.h:484
int GetMode1() const
Gets the id of the src mode.
Definition: mmnet.h:322
TVal2 Val2
Definition: ds.h:35
TStr GetNeighborCrossName(const TStr &CrossName, bool isOutEdge, const bool sameMode, bool isDir) const
Definition: mmnet.cpp:4
TBool IsDirect
The second mode. In the case of directed crossnets, this is implicitly understood to be the destinati...
Definition: mmnet.h:250
Definition: bd.h:196
THash< TStr, TInt > IntDefaultsN
Definition: network.h:1867
TAIntI(const TIntVecIter &HIter, TStr attribute, const TCrossNet *GraphPt)
Definition: mmnet.h:189
TAIntI & operator=(const TAIntI &I)
Definition: mmnet.h:191
bool IsAttrDeletedE(const int &EId, const TStr &attr) const
Definition: mmnet.cpp:367
THash< TInt, TNode > NodeH
Definition: network.h:1862
int DelAttrE(const TStr &attr)
Removes all the values for edge attr.
Definition: mmnet.cpp:580
TModeNetI(const TModeNetI &ModeNetI)
Definition: mmnet.h:480
bool IsEdge(const int &EId) const
Tests whether an edge with edge ID EId exists in the graph.
Definition: mmnet.h:305
TVec< TVec< TIntV > > VecOfIntVecVecsN
Definition: network.h:1873
int AddMode(const TStr &ModeName, const TInt &ModeId, const TModeNet &ModeNet)
Definition: mmnet.cpp:705
int AddIntAttrE(const TStr &attr, TInt defaultValue=TInt::Mn)
Adds a new Int edge attribute to the hashmap.
Definition: mmnet.cpp:522
TVec< TFltV > VecOfFltVecsE
Definition: mmnet.h:259
TInt MxEId
The HashTable from Edge id to the corresponding Edge.
Definition: mmnet.h:247
void ClrNbr(const TInt &ModeId, const TInt &CrossNetId, const bool &outEdge, const bool &sameMode, bool &isDir)
Definition: mmnet.cpp:723
THashIter NodeHI
Definition: network.h:1635
TIntV::TIter TIntVecIter
Definition: mmnet.h:183
TStr GetEdgeAttrValue(const int &EId, const TStrIntPrH::TIter &CrossHI) const
Definition: mmnet.cpp:411
TCrossNet & GetCrossNetByName(const TStr &CrossName) const
Gets a reference to the crossnet.
Definition: mmnet.cpp:695
bool IsKey(const TKey &Key) const
Definition: hash.h:216
int AddEdgeAttributes(PNEANet &NewNet, TCrossNet &Net, TVec< TPair< TStr, TStr > > &Attrs, int CrossId, int oldId, int EId)
Definition: mmnet.cpp:1276
void Save(TSOut &SOut) const
Saves the graph to a (binary) stream SOut.
Definition: mmnet.h:65
Definition: dt.h:881
TStr GetModeName()
Gets the name of the mode.
Definition: mmnet.h:489
TInt MxCrossNetId
Keeps track of the max mode id.
Definition: mmnet.h:525
TNodeI(const TNodeI &NodeI)
Definition: mmnet.h:32
THash< TInt, TCrossEdge > CrossH
Definition: mmnet.h:246
int Len() const
Definition: hash.h:186
TIter GetI(const TSizeTy &ValN) const
Returns an iterator an element at position ValN.
Definition: ds.h:569
TCrossNet & GetCrossNetById(const TInt &CrossId) const
Definition: mmnet.cpp:699
TInt GetIntAttrDatE(const TCrossEdgeI &EdgeI, const TStr &attr)
Gets the value of int attr from the edge attr value vector.
Definition: mmnet.h:378
bool IsDirected() const
Whether edges in the crossnet are directed.
Definition: mmnet.h:331
TIntVecIter HI
Definition: mmnet.h:184
TCrossNetI(const THashIter &CrossNetHIter, const TMMNet *GraphPt)
Definition: mmnet.h:503
PMMNet GetSubgraphByModeNet(TStrV &ModeNetTypes)
Gets the induced subgraph given a vector of mode type names.
Definition: mmnet.cpp:771
TAIntI(const TAIntI &I)
Definition: mmnet.h:190
TCrossEdgeI(const THashIter &CrossHIter, const TCrossNet *GraphPt)
Definition: mmnet.h:155
TModeNet & GetModeNetByName(const TStr &ModeName) const
Gets a reference to the modenet.
Definition: mmnet.cpp:685
TCrossNet & operator=(const TCrossNet &OtherTCrossNet)
Definition: mmnet.h:275
void Clr()
Deletes all nodes from this mode and edges from associated crossnets.
Definition: mmnet.cpp:22
int GetAttrTypeN(const TStr &attr) const
Definition: mmnet.cpp:159
void SetParentPointer(TMMNet *parent)
Definition: mmnet.cpp:78
void StrAttrValueEI(const TInt &EId, TStrV &Values) const
Returns a vector of attr values for node NId.
Definition: mmnet.h:355
int GetAttrTypeE(const TStr &attr) const
Definition: mmnet.cpp:167
TStr GetStrAttrDefaultE(const TStr &attribute) const
Gets Str edge attribute val. If not a proper attr, return default.
Definition: mmnet.h:298
int GetDstModeId() const
Returns the destination mode of the crossnet.
Definition: mmnet.h:172
static const double Mn
Definition: dt.h:1297
Multimodal networks.
Definition: mmnet.h:468
THash< TInt, TStr > CrossIdToNameH
Definition: mmnet.h:532
TIter GetI(const TKey &Key) const
Definition: hash.h:178
Implements a single CrossNet consisting of edges between two TModeNets (could be the same TModeNet) ...
Definition: mmnet.h:124
int AddNeighbor(const int &NId, const int &EId, const bool outEdge, const int linkId, const bool sameMode, bool isDir)
Definition: mmnet.cpp:31
TAStrI & operator++(int)
Definition: mmnet.h:220