SNAP Library 4.0, User Reference  2017-07-27 13:18:06
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
graphmp.h
Go to the documentation of this file.
1 #ifndef GRAPHMP_H
2 #define GRAPHMP_H
3 
4 #ifdef GCC_ATOMIC
5 //#//////////////////////////////////////////////
7 class TNGraphMP;
8 
10 
11 //#//////////////////////////////////////////////
13 
27 class TNGraphMP {
28 public:
29  typedef TNGraphMP TNet;
31 public:
32  class TNode {
33  private:
36  public:
37  TNode() : Id(-1), InNIdV(), OutNIdV() { }
38  TNode(const int& NId) : Id(NId), InNIdV(), OutNIdV() { }
39  TNode(const TNode& Node) : Id(Node.Id), InNIdV(Node.InNIdV), OutNIdV(Node.OutNIdV) { }
40  TNode(TSIn& SIn) : Id(SIn), InNIdV(SIn), OutNIdV(SIn) { }
41  void Save(TSOut& SOut) const { Id.Save(SOut); InNIdV.Save(SOut); OutNIdV.Save(SOut); }
42  int GetId() const { return Id; }
43  int GetDeg() const { return GetInDeg() + GetOutDeg(); }
44  int GetInDeg() const { return InNIdV.Len(); }
45  int GetOutDeg() const { return OutNIdV.Len(); }
46  int GetInNId(const int& NodeN) const { return InNIdV[NodeN]; }
47  int GetOutNId(const int& NodeN) const { return OutNIdV[NodeN]; }
48  int GetNbrNId(const int& NodeN) const { return NodeN<GetOutDeg()?GetOutNId(NodeN):GetInNId(NodeN-GetOutDeg()); }
49  bool IsInNId(const int& NId) const { return InNIdV.SearchBin(NId) != -1; }
50  bool IsOutNId(const int& NId) const { return OutNIdV.SearchBin(NId) != -1; }
51  bool IsNbrNId(const int& NId) const { return IsOutNId(NId) || IsInNId(NId); }
52  void PackOutNIdV() { OutNIdV.Pack(); }
53  void PackNIdV() { InNIdV.Pack(); }
54  void SortNIdV() { InNIdV.Sort(); OutNIdV.Sort();}
55  friend class TNGraphMP;
56  };
58  class TNodeI {
59  private:
62  public:
63  TNodeI() : NodeHI() { }
64  TNodeI(const THashIter& NodeHIter) : NodeHI(NodeHIter) { }
65  TNodeI(const TNodeI& NodeI) : NodeHI(NodeI.NodeHI) { }
66  TNodeI& operator = (const TNodeI& NodeI) { NodeHI = NodeI.NodeHI; return *this; }
68  TNodeI& operator++ (int) { NodeHI++; return *this; }
69  bool operator < (const TNodeI& NodeI) const { return NodeHI < NodeI.NodeHI; }
70  bool operator == (const TNodeI& NodeI) const { return NodeHI == NodeI.NodeHI; }
72  int GetId() const { return NodeHI.GetDat().GetId(); }
74  int GetDeg() const { return NodeHI.GetDat().GetDeg(); }
76  int GetInDeg() const { return NodeHI.GetDat().GetInDeg(); }
78  int GetOutDeg() const { return NodeHI.GetDat().GetOutDeg(); }
80  void SortNIdV() { NodeHI.GetDat().SortNIdV(); }
82 
84  int GetInNId(const int& NodeN) const { return NodeHI.GetDat().GetInNId(NodeN); }
86 
88  int GetOutNId(const int& NodeN) const { return NodeHI.GetDat().GetOutNId(NodeN); }
90 
92  int GetNbrNId(const int& NodeN) const { return NodeHI.GetDat().GetNbrNId(NodeN); }
94  bool IsInNId(const int& NId) const { return NodeHI.GetDat().IsInNId(NId); }
96  bool IsOutNId(const int& NId) const { return NodeHI.GetDat().IsOutNId(NId); }
98  bool IsNbrNId(const int& NId) const { return IsOutNId(NId) || IsInNId(NId); }
99  friend class TNGraphMP;
100  };
102  class TEdgeI {
103  private:
105  int CurEdge;
106  public:
107  TEdgeI() : CurNode(), EndNode(), CurEdge(0) { }
108  TEdgeI(const TNodeI& NodeI, const TNodeI& EndNodeI, const int& EdgeN=0) : CurNode(NodeI), EndNode(EndNodeI), CurEdge(EdgeN) { }
109  TEdgeI(const TEdgeI& EdgeI) : CurNode(EdgeI.CurNode), EndNode(EdgeI.EndNode), CurEdge(EdgeI.CurEdge) { }
110  TEdgeI& operator = (const TEdgeI& EdgeI) { if (this!=&EdgeI) { CurNode=EdgeI.CurNode; EndNode=EdgeI.EndNode; CurEdge=EdgeI.CurEdge; } return *this; }
113  while (CurNode < EndNode && CurNode.GetOutDeg()==0) { CurNode++; } } return *this; }
114  bool operator < (const TEdgeI& EdgeI) const { return CurNode<EdgeI.CurNode || (CurNode==EdgeI.CurNode && CurEdge<EdgeI.CurEdge); }
115  bool operator == (const TEdgeI& EdgeI) const { return CurNode == EdgeI.CurNode && CurEdge == EdgeI.CurEdge; }
117  int GetId() const { return -1; }
119  int GetSrcNId() const { return CurNode.GetId(); }
121  int GetDstNId() const { return CurNode.GetOutNId(CurEdge); }
122  friend class TNGraphMP;
123  };
124 private:
128 private:
129  TNode& GetNode(const int& NId) { return NodeH.GetDat(NId); }
130  const TNode& GetNode(const int& NId) const { return NodeH.GetDat(NId); }
131 public:
132  TNGraphMP() : CRef(), MxNId(0), NodeH() { }
134  explicit TNGraphMP(const int& Nodes, const int& Edges) : MxNId(0) { Reserve(Nodes, Edges); }
135  TNGraphMP(const TNGraphMP& Graph) : MxNId(Graph.MxNId), NodeH(Graph.NodeH) { }
137  TNGraphMP(TSIn& SIn) : MxNId(SIn), NodeH(SIn) { }
139  void Save(TSOut& SOut) const { MxNId.Save(SOut); NodeH.Save(SOut); }
141  static PNGraphMP New() { return new TNGraphMP(); }
143 
145  static PNGraphMP New(const int& Nodes, const int& Edges) { return new TNGraphMP(Nodes, Edges); }
147  static PNGraphMP Load(TSIn& SIn) { return PNGraphMP(new TNGraphMP(SIn)); }
149  bool HasFlag(const TGraphFlag& Flag) const;
150  TNGraphMP& operator = (const TNGraphMP& Graph) {
151  if (this!=&Graph) { MxNId=Graph.MxNId; NodeH=Graph.NodeH; } return *this; }
152 
154  int GetNodes() const { return NodeH.Len(); }
156  void SetNodes(const int& Length) { NodeH.SetLen(Length); }
158 
162  int AddNode(int NId = -1);
164  int AddNodeUnchecked(int NId = -1);
166  int AddNode(const TNodeI& NodeId) { return AddNode(NodeId.GetId()); }
168 
177  int AddNode(const int& NId, const TIntV& InNIdV, const TIntV& OutNIdV);
179 
187  int AddNode(const int& NId, const TVecPool<TInt>& Pool, const int& SrcVId, const int& DstVId);
189 
191  void DelNode(const int& NId);
193  void DelNode(const TNode& NodeI) { DelNode(NodeI.GetId()); }
195  bool IsNode(const int& NId) const { return NodeH.IsKey(NId); }
197  TNodeI BegNI() const { return TNodeI(NodeH.BegI()); }
199  TNodeI EndNI() const { return TNodeI(NodeH.EndI()); }
201  TNodeI GetNI(const int& NId) const { return TNodeI(NodeH.GetI(NId)); }
202  // GetNodeC() has been commented out. It was a quick shortcut, do not use.
203  //const TNode& GetNodeC(const int& NId) const { return NodeH.GetDat(NId); }
205  int GetMxNId() const { return MxNId; }
206  int Reserved() const {return NodeH.GetReservedKeyIds();}
207 
209  int GetEdges() const;
211 
217  int AddEdge(const int& SrcNId, const int& DstNId);
219  int AddEdgeUnchecked(const int& SrcNId, const int& DstNId);
221  int AddEdge(const TEdgeI& EdgeI) { return AddEdge(EdgeI.GetSrcNId(), EdgeI.GetDstNId()); }
222  int AddOutEdge1(int& SrcIdx, const int& SrcNId, const int& DstNId);
223  int AddInEdge1(int& DstIdx, const int& SrcNId, const int& DstNId);
224  void AddOutEdge2(const int& SrcNId, const int& DstNId);
225  void AddInEdge2(const int& SrcNId, const int& DstNId);
226 
228  void AddNodeWithEdges(const TInt& NId, TIntV& InNIdV, TIntV& OutNIdV);
229 
231 
235  void DelEdge(const int& SrcNId, const int& DstNId, const bool& IsDir = true);
237  bool IsEdge(const int& SrcNId, const int& DstNId, const bool& IsDir = true) const;
239  TEdgeI BegEI() const { TNodeI NI=BegNI(); while(NI<EndNI() && NI.GetOutDeg()==0){NI++;} return TEdgeI(NI, EndNI()); }
241  TEdgeI EndEI() const { return TEdgeI(EndNI(), EndNI()); }
242  // /// Not supported/implemented!
243  // TEdgeI GetEI(const int& EId) const; // not supported
245  TEdgeI GetEI(const int& SrcNId, const int& DstNId) const;
246 
248  int GetRndNId(TRnd& Rnd=TInt::Rnd) { return NodeH.GetKey(NodeH.GetRndKeyId(Rnd, 0.8)); }
250  TNodeI GetRndNI(TRnd& Rnd=TInt::Rnd) { return GetNI(GetRndNId(Rnd)); }
252  void GetNIdV(TIntV& NIdV) const;
253 
255  bool Empty() const { return GetNodes()==0; }
257  void Clr() { MxNId=0; NodeH.Clr(); }
259  void Reserve(const int& Nodes, const int& Edges) { if (Nodes>0) { NodeH.Gen(Nodes); } }
261  void ReserveNodeDegs(const int& Idx, const int& InDeg, const int& OutDeg) { if (InDeg > 0) NodeH[Idx].InNIdV.Reserve(InDeg); if (OutDeg > 0) NodeH[Idx].OutNIdV.Reserve(OutDeg); }
263  void ReserveNIdInDeg(const int& NId, const int& InDeg) { GetNode(NId).InNIdV.Reserve(InDeg); }
265  void ReserveNIdOutDeg(const int& NId, const int& OutDeg) { GetNode(NId).OutNIdV.Reserve(OutDeg); }
267  void SortEdges(const int& Idx, const int& InDeg, const int& OutDeg) { if (InDeg > 0) NodeH[Idx].InNIdV.Sort(); if (OutDeg > 0) NodeH[Idx].OutNIdV.Sort(); }
269  void SortNodeAdjV() { for (TNodeI NI = BegNI(); NI < EndNI(); NI++) { NI.SortNIdV();} }
271 
276  void Defrag(const bool& OnlyNodeLinks=false);
278 
281  bool IsOk(const bool& ThrowExcept=true) const;
283  void Dump(FILE *OutF=stdout) const;
285 
289  static PNGraphMP GetSmallGraph();
290  friend class TPt<TNGraphMP>;
291  friend class TNGraphMPMtx;
292 };
293 
294 // set flags
295 namespace TSnap {
296 template <> struct IsDirected<TNGraphMP> { enum { Val = 1 }; };
297 }
298 
299 #else
300 
301 // substitute TNGraph for TNGraphMP on non-gcc platforms
302 //typedef TNGraph TNGraphMP;
303 //typedef TPt<TNGraphMP> PNGraphMP;
304 
305 #endif // GCC_ATOMIC
306 
307 #endif // GRAPHMP_H
308 
Definition: bd.h:440
TIter GetI(const TKey &Key) const
Definition: hashmp.h:158
TNGraphMP TNet
Definition: graphmp.h:29
void AddOutEdge2(const int &SrcNId, const int &DstNId)
Definition: graphmp.cpp:272
int GetInDeg() const
Definition: graphmp.h:44
int GetDeg() const
Definition: graphmp.h:43
bool Empty() const
Tests whether the graph is empty (has zero nodes).
Definition: graphmp.h:255
TNGraphMP()
Definition: graphmp.h:132
bool operator<(const TEdgeI &EdgeI) const
Definition: graphmp.h:114
int GetOutNId(const int &NodeN) const
Definition: graphmp.h:47
int AddOutEdge1(int &SrcIdx, const int &SrcNId, const int &DstNId)
Definition: graphmp.cpp:234
void Save(TSOut &SOut) const
Definition: hashmp.h:129
bool IsNbrNId(const int &NId) const
Definition: graphmp.h:51
void ReserveNIdInDeg(const int &NId, const int &InDeg)
Reserves memory for node ID NId having InDeg in-edges.
Definition: graphmp.h:263
Definition: dt.h:11
int GetMxNId() const
Returns the maximum id of a any node in the graph.
Definition: graphmp.h:205
void Save(TSOut &SOut) const
Definition: dt.h:1150
TNGraphMP(const TNGraphMP &Graph)
Definition: graphmp.h:135
void SortEdges(const int &Idx, const int &InDeg, const int &OutDeg)
Sorts in-edges and out-edges.
Definition: graphmp.h:267
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
Definition: graphmp.h:201
TIntV OutNIdV
Definition: graphmp.h:35
Tests (at compile time) if the graph is directed.
Definition: gbase.h:28
void ReserveNIdOutDeg(const int &NId, const int &OutDeg)
Reserves memory for node ID NId having OutDeg out-edges.
Definition: graphmp.h:265
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:575
TEdgeI & operator++(int)
Increment iterator.
Definition: graphmp.h:112
static PNGraphMP New()
Static constructor that returns a pointer to the graph. Call: PNGraphMP Graph = TNGraphMP::New().
Definition: graphmp.h:141
TNode(const TNode &Node)
Definition: graphmp.h:39
void DelNode(const int &NId)
Deletes node of ID NId from the graph.
Definition: graphmp.cpp:68
TEdgeI(const TNodeI &NodeI, const TNodeI &EndNodeI, const int &EdgeN=0)
Definition: graphmp.h:108
TPt< TNGraphMP > PNet
Definition: graphmp.h:30
void SetLen(const int &Length)
Definition: hashmp.h:166
int GetOutNId(const int &NodeN) const
Returns ID of NodeN-th out-node (the node the current node points to).
Definition: graphmp.h:88
int AddEdge(const TEdgeI &EdgeI)
Adds an edge from EdgeI.GetSrcNId() to EdgeI.GetDstNId() to the graph.
Definition: graphmp.h:221
bool operator<(const TNodeI &NodeI) const
Definition: graphmp.h:69
const TNode & GetNode(const int &NId) const
Definition: graphmp.h:130
static TRnd Rnd
Definition: dt.h:1143
int GetNbrNId(const int &NodeN) const
Definition: graphmp.h:48
void Save(TSOut &SOut) const
Definition: graphmp.h:41
void DelEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true)
Deletes an edge from node IDs SrcNId to DstNId from the graph.
Definition: graphmp.cpp:112
TNodeI(const THashIter &NodeHIter)
Definition: graphmp.h:64
void Dump(FILE *OutF=stdout) const
Print the graph in a human readable form to an output stream OutF.
Definition: graphmp.cpp:206
int GetEdges() const
Returns the number of edges in the graph.
Definition: graphmp.cpp:89
void ReserveNodeDegs(const int &Idx, const int &InDeg, const int &OutDeg)
Reserves memory for node Idx having InDeg in-edges and OutDeg out-edges.
Definition: graphmp.h:261
Definition: fl.h:58
void Save(TSOut &SOut) const
Definition: ds.h:954
void SortNIdV()
Sorts the adjacency lists of the current node.
Definition: graphmp.h:80
TNode(const int &NId)
Definition: graphmp.h:38
int GetInNId(const int &NodeN) const
Definition: graphmp.h:46
TNodeI GetRndNI(TRnd &Rnd=TInt::Rnd)
Returns an interator referring to a random node in the graph.
Definition: graphmp.h:250
static PNGraphMP New(const int &Nodes, const int &Edges)
Static constructor that returns a pointer to the graph and reserves enough memory for Nodes nodes and...
Definition: graphmp.h:145
int GetOutDeg() const
Definition: graphmp.h:45
TIter EndI() const
Definition: hashmp.h:156
void Reserve(const int &Nodes, const int &Edges)
Reserves memory for a graph of Nodes nodes and Edges edges.
Definition: graphmp.h:259
TEdgeI BegEI() const
Returns an iterator referring to the first edge in the graph.
Definition: graphmp.h:239
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
Definition: graphmp.h:197
int AddEdgeUnchecked(const int &SrcNId, const int &DstNId)
Adds an edge from node IDs SrcNId to node DstNId to the graph without performing checks.
Definition: graphmp.cpp:106
TCRef CRef
Definition: graphmp.h:125
void Defrag(const bool &OnlyNodeLinks=false)
Defragments the graph.
Definition: graphmp.cpp:149
bool operator==(const TEdgeI &EdgeI) const
Definition: graphmp.h:115
int AddNode(const TNodeI &NodeId)
Adds a node of ID NodeI.GetId() to the graph.
Definition: graphmp.h:166
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1318
void AddInEdge2(const int &SrcNId, const int &DstNId)
Definition: graphmp.cpp:276
TIntV InNIdV
Definition: graphmp.h:35
int GetRndNId(TRnd &Rnd=TInt::Rnd)
Returns an ID of a random node in the graph.
Definition: graphmp.h:248
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
Definition: graphmp.h:199
void SortNIdV()
Definition: graphmp.h:54
TNGraphMP & operator=(const TNGraphMP &Graph)
Definition: graphmp.h:150
int GetSrcNId() const
Gets the source node of an edge.
Definition: graphmp.h:119
void DelNode(const TNode &NodeI)
Deletes node of ID NodeI.GetId() from the graph.
Definition: graphmp.h:193
void PackOutNIdV()
Definition: graphmp.h:52
void Save(TSOut &SOut) const
Saves the graph to a (binary) stream SOut.
Definition: graphmp.h:139
bool IsNode(const int &NId) const
Tests whether ID NId is a node.
Definition: graphmp.h:195
void SetNodes(const int &Length)
Sets the number of nodes in the graph.
Definition: graphmp.h:156
Directed graph for multi-threaded operations.
Definition: graphmp.h:27
int GetDeg() const
Returns degree of the current node, the sum of in-degree and out-degree.
Definition: graphmp.h:74
int GetDstNId() const
Gets destination node of an edge.
Definition: graphmp.h:121
TEdgeI GetEI(const int &SrcNId, const int &DstNId) const
Returns an iterator referring to edge (SrcNId, DstNId) in the graph.
Definition: graphmp.cpp:136
bool IsKey(const TKey &Key) const
Definition: hashmp.h:191
bool IsOutNId(const int &NId) const
Tests whether the current node points to node with ID NId.
Definition: graphmp.h:96
int GetId() const
Returns ID of the current node.
Definition: graphmp.h:72
TNGraphMP(const int &Nodes, const int &Edges)
Constructor that reserves enough memory for a graph of Nodes nodes and Edges edges.
Definition: graphmp.h:134
int AddInEdge1(int &DstIdx, const int &SrcNId, const int &DstNId)
Definition: graphmp.cpp:253
Edge iterator. Only forward iteration (operator++) is supported.
Definition: graphmp.h:102
Definition: fl.h:128
Node iterator. Only forward iteration (operator++) is supported.
Definition: graphmp.h:58
bool IsInNId(const int &NId) const
Definition: graphmp.h:49
void Clr()
Deletes all nodes and edges from the graph.
Definition: graphmp.h:257
TSizeTy SearchBin(const TVal &Val) const
Returns the position of an element with value Val.
Definition: ds.h:1519
void AddNodeWithEdges(const TInt &NId, TIntV &InNIdV, TIntV &OutNIdV)
Adds a node of ID NId to the graph, creates edges to the node from all nodes in vector InNIdV...
Definition: graphmp.cpp:282
Definition: dt.h:1134
friend class TNGraphMPMtx
Definition: graphmp.h:291
bool HasFlag(const TGraphFlag &Flag) const
Allows for run-time checking the type of the graph (see the TGraphFlag for flags).
Definition: graphmp.cpp:6
int GetReservedKeyIds() const
Definition: hashmp.h:169
THashIter NodeHI
Definition: graphmp.h:61
bool IsInNId(const int &NId) const
Tests whether node with ID NId points to the current node.
Definition: graphmp.h:94
int GetRndKeyId(TRnd &Rnd) const
Get an index of a random element. If the hash table has many deleted keys, this may take a long time...
Definition: hashmp.h:558
int GetId() const
Definition: graphmp.h:42
void Gen(const int &ExpectVals)
Definition: hashmp.h:160
THashMP< TInt, TNode > NodeH
Definition: graphmp.h:127
TNGraphMP(TSIn &SIn)
Constructor that loads the graph from a (binary) stream SIn.
Definition: graphmp.h:137
bool IsOutNId(const int &NId) const
Definition: graphmp.h:50
bool IsOk(const bool &ThrowExcept=true) const
Checks the graph data structure for internal consistency.
Definition: graphmp.cpp:160
TIter BegI() const
Definition: hashmp.h:153
int GetOutDeg() const
Returns out-degree of the current node.
Definition: graphmp.h:78
void GetNIdV(TIntV &NIdV) const
Gets a vector IDs of all nodes in the graph.
Definition: graphmp.cpp:143
int GetId() const
Gets edge ID. Always returns -1 since only edges in multigraphs have explicit IDs.
Definition: graphmp.h:117
void SortNodeAdjV()
Sorts the adjacency lists of each node.
Definition: graphmp.h:269
int GetNbrNId(const int &NodeN) const
Returns ID of NodeN-th neighboring node.
Definition: graphmp.h:92
void Pack()
Reduces vector capacity (frees memory) to match its size.
Definition: ds.h:1057
enum TGraphFlag_ TGraphFlag
Graph Flags, used for quick testing of graph types.
int GetInDeg() const
Returns in-degree of the current node.
Definition: graphmp.h:76
TEdgeI & operator=(const TEdgeI &EdgeI)
Definition: graphmp.h:110
TInt MxNId
Definition: graphmp.h:126
Hash-Table with multiprocessing support.
Definition: hashmp.h:81
TNode(TSIn &SIn)
Definition: graphmp.h:40
TEdgeI EndEI() const
Returns an iterator referring to the past-the-end edge in the graph.
Definition: graphmp.h:241
bool IsNbrNId(const int &NId) const
Tests whether node with ID NId is a neighbor of the current node.
Definition: graphmp.h:98
Definition: bd.h:196
int GetNodes() const
Returns the number of nodes in the graph.
Definition: graphmp.h:154
void Clr(const bool &DoDel=true)
Definition: hashmp.h:474
void PackNIdV()
Definition: graphmp.h:53
static PNGraphMP GetSmallGraph()
Returns a small graph on 5 nodes and 6 edges.
Definition: graphmp.cpp:223
void Reserve(const TSizeTy &_MxVals)
Reserves enough memory for the vector to store _MxVals elements.
Definition: ds.h:543
int AddNode(int NId=-1)
Adds a node of ID NId to the graph.
Definition: graphmp.cpp:10
bool operator==(const TNodeI &NodeI) const
Definition: graphmp.h:70
int Reserved() const
Definition: graphmp.h:206
TNodeI & operator++(int)
Increment iterator.
Definition: graphmp.h:68
TNodeI CurNode
Definition: graphmp.h:104
int AddNodeUnchecked(int NId=-1)
Adds a node of ID NId to the graph without performing checks.
Definition: graphmp.cpp:21
static PNGraphMP Load(TSIn &SIn)
Static constructor that loads the graph from a stream SIn and returns a pointer to it...
Definition: graphmp.h:147
TPt< TNGraphMP > PNGraphMP
Definition: graphmp.h:7
TNodeI & operator=(const TNodeI &NodeI)
Definition: graphmp.h:66
TEdgeI(const TEdgeI &EdgeI)
Definition: graphmp.h:109
const TDat & GetDat(const TKey &Key) const
Definition: hashmp.h:195
int GetInNId(const int &NodeN) const
Returns ID of NodeN-th in-node (the node pointing to the current node).
Definition: graphmp.h:84
bool IsEdge(const int &SrcNId, const int &DstNId, const bool &IsDir=true) const
Tests whether an edge from node IDs SrcNId to DstNId exists in the graph.
Definition: graphmp.cpp:130
TNodeI EndNode
Definition: graphmp.h:104
TNode & GetNode(const int &NId)
Definition: graphmp.h:129
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node IDs SrcNId to node DstNId to the graph.
Definition: graphmp.cpp:97
THashMP< TInt, TNode >::TIter THashIter
Definition: graphmp.h:60
TNodeI(const TNodeI &NodeI)
Definition: graphmp.h:65
int Len() const
Definition: hashmp.h:165
const TKey & GetKey(const int &KeyId) const
Definition: hashmp.h:185