5 TInt SIdx = P->GetColIdx(C1);
6 TInt DIdx = P->GetColIdx(C2);
7 TInt StIdx = P->GetColIdx(C3);
8 TInt DuIdx = P->GetColIdx(C4);
14 P->ReadIntCol(C1,Source);
17 for (
TRowIterator RI = P->BegRI(); RI < P-> EndRI(); RI++) {
18 Graph->
AddNode(RI.GetRowIdx().Val);
19 MapV.
Add(RI.GetRowIdx());
22 for (
TRowIterator OI = P->BegRI(); OI < P->EndRI(); OI++) {
23 int OIdx = OI.GetRowIdx().Val;
24 int ODest = P->GetIntValAtRowIdx(DIdx,OIdx).Val;
25 int OStart = P->GetIntValAtRowIdx(StIdx,OIdx).Val;
26 int ODur = P->GetIntValAtRowIdx(DuIdx,OIdx).Val;
30 int hi = Source.
Len() - 1;
33 int mid = lo + (hi - lo)/2;
34 if (Source.
GetVal(mid) > val) { hi = mid - 1;}
35 else if (Source.
GetVal(mid) < val) { lo = mid + 1;}
36 else { index = mid; hi = mid - 1;}
40 for(
int i = BIdx; i < Source.
Len(); i++) {
42 if (InIdx == OIdx) {
continue;}
43 int InSource = P->GetIntValAtRowIdx(SIdx,InIdx).Val;
44 int InStart = P->GetIntValAtRowIdx(StIdx,InIdx).Val;
45 if (InSource != ODest) {
break;}
46 if (InStart >= (ODur + OStart) && InStart - (ODur + OStart) <= W.
Val) {
47 if (!Graph->
IsEdge(OIdx,InIdx)) {
58 TInt SIdx = P->GetColIdx(C1);
59 TInt DIdx = P->GetColIdx(C2);
60 TInt StIdx = P->GetColIdx(C3);
61 TInt DuIdx = P->GetColIdx(C4);
67 P->ReadIntCol(C3,Start);
70 for (
TRowIterator RI = P->BegRI(); RI < P-> EndRI(); RI++) {
71 Graph->
AddNode(RI.GetRowIdx().Val);
72 MapV.
Add(RI.GetRowIdx());
75 for (
TRowIterator OI = P->BegRI(); OI < P->EndRI(); OI++) {
76 int OIdx = OI.GetRowIdx().Val;
77 int ODest = P->GetIntValAtRowIdx(DIdx,OIdx).Val;
78 int OStart = P->GetIntValAtRowIdx(StIdx,OIdx).Val;
79 int ODur = P->GetIntValAtRowIdx(DuIdx,OIdx).Val;
81 int val = OStart + ODur;
83 int hi = Start.
Len() - 1;
87 int mid = lo + (hi - lo)/2;
88 if (Start.
GetVal(mid) > val) {
89 if ((mid-1) >= lo && Start.
GetVal(mid - 1) < val) {
90 index = mid - 1;
break;
94 else if (Start.
GetVal(mid) < val) {
95 if (mid + 1 <= hi && Start.
GetVal(mid + 1) > val) {
100 else { index = mid; hi = mid - 1;}
104 for(
int i = BIdx; i < Start.
Len(); i++) {
106 if (InIdx == OIdx) {
continue;}
107 int InSource = P->GetIntValAtRowIdx(SIdx,InIdx).Val;
108 int InStart = P->GetIntValAtRowIdx(StIdx,InIdx).Val;
109 if (InStart - (ODur + OStart) > W.
Val) {
break;}
110 if (InSource == ODest && InStart >= (ODur + OStart)) {
111 if (!Graph->
IsEdge(OIdx,InIdx)) {
131 TInt SIdx = P->GetColIdx(C1);
132 TInt DIdx = P->GetColIdx(C2);
133 TInt StIdx = P->GetColIdx(C3);
134 TInt DuIdx = P->GetColIdx(C4);
140 for (
TRowIterator RI = P->BegRI(); RI < P-> EndRI(); RI++) {
141 MapV.
Add(RI.GetRowIdx());
145 P->StoreIntCol(
"Physical",PhyV);
146 TInt PIdx = P->GetColIdx(
"Physical");
149 if (NI.GetInDeg() != 0) {
continue;}
153 TInt NId = NI.GetId();
156 CurCasc.
Add(P->GetIntValAtRowIdx(PIdx,NId));
157 while (! EventQ.
Empty()) {
161 for (
int e = 0; e < CNI.
GetOutDeg(); e++) {
163 if ( !VisitedH.
IsKey(CId)) {
166 CurCasc.
Add(P->GetIntValAtRowIdx(PIdx,CId));
172 if (Print && VisitedH.
Len() > 1) {
173 printf(
"__casacade__\t%d\n",VisitedH.
Len());
177 if (Print && VisitedH.
Len() > 1) {
179 int PSource = P->GetIntValAtRowIdx(SIdx,PIdx).Val;
180 int PDest = P->GetIntValAtRowIdx(DIdx,PIdx).Val;
181 int PStart = P->GetIntValAtRowIdx(StIdx,PIdx).Val;
182 int PDur = P->GetIntValAtRowIdx(DuIdx,PIdx).Val;
183 printf(
"%d\t%d\t%d\t%d\t%d\n",PIdx,PSource,PDest,PStart,PDur);
186 if (ToAddV.
Len() > 1) {
187 TopCascVV.
Add(ToAddV);
196 TInt SIdx = P->GetColIdx(C1);
197 TInt DIdx = P->GetColIdx(C2);
198 TInt StIdx = P->GetColIdx(C3);
199 TInt DuIdx = P->GetColIdx(C4);
205 for (
TRowIterator RI = P->BegRI(); RI < P-> EndRI(); RI++) {
206 MapV.
Add(RI.GetRowIdx());
209 P->StoreIntCol(
"Physical",PhyV);
210 TInt PIdx = P->GetColIdx(
"Physical");
213 if (NI.GetInDeg() == 0) { GNodeV.
Add(NI.GetId()); }
216 #pragma omp parallel private(ThTopCascVV) num_threads(10)
218 #pragma omp for schedule(dynamic,1000)
219 for (
int i = 0; i < GNodeV.
Len(); i++) {
223 TInt NId = GNodeV[i];
226 CurCasc.
Add(P->GetIntValAtRowIdx(PIdx,NId));
227 while (! EventQ.
Empty()) {
231 for (
int e = 0; e < CNI.
GetOutDeg(); e++) {
233 if ( !VisitedH.
IsKey(CId)) {
236 CurCasc.
Add(P->GetIntValAtRowIdx(PIdx,CId));
245 if (ToAddV.
Len() > 1) { ThTopCascVV.
Add(ToAddV);}
249 for (
int j = 0; j < ThTopCascVV.
Len(); j++) {
250 TopCascVV.
Add(ThTopCascVV[j]);
TIter EndI() const
Returns an iterator referring to the past-the-end element in the vector.
TNodeI BegNI() const
Returns an iterator referring to the first node in the graph.
static PNGraph New()
Static constructor that returns a pointer to the graph. Call: PNGraph Graph = TNGraph::New().
TNodeI GetNI(const int &NId) const
Returns an iterator referring to the node of ID NId in the graph.
void CascFind(PNGraph Graph, PTable P, const TStr C1, const TStr C2, const TStr C3, const TStr C4, TVec< TIntV > &TopCascVV, bool Print)
Takes as input a directed graph and returns all the top cascades in TopCascVV.
TSizeTy Len() const
Returns the number of elements in the vector.
int AddNode(int NId=-1)
Adds a node of ID NId to the graph.
bool IsKey(const TKey &Key) const
void Pop()
Removes the first element from the queue.
bool Empty() const
Tests whether the queue is empty (contains no elements).
Iterator class for TTable rows.
PNGraph CascGraphSource(PTable P, const TStr C1, const TStr C2, const TStr C3, const TStr C4, const TInt W)
Takes as input the column names of the PTable P as C1, C2,C3 and C4 and returns a directed graph of W...
const TVal & GetVal(const TSizeTy &ValN) const
Returns a reference to the element at position ValN in the vector.
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
int AddEdge(const int &SrcNId, const int &DstNId)
Adds an edge from node IDs SrcNId to node DstNId to the graph.
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.
int AddKey(const TKey &Key)
PNGraph CascGraphTime(PTable P, const TStr C1, const TStr C2, const TStr C3, const TStr C4, const TInt W)
Takes as input the column names of the PTable P as C1, C2,C3 and C4 and returns a directed graph of W...
PNGraph CascGraph(PTable P, const TStr C1, const TStr C2, const TStr C3, const TStr C4, const TInt W, bool SortParam)
Takes as input the column names of the PTable P as C1, C2, C3 and C4 and returns a directed graph of ...
TNodeI EndNI() const
Returns an iterator referring to the past-the-end node in the graph.
int GetOutDeg() const
Returns out-degree of the current node.
void CascFindMP(PNGraph Graph, PTable P, const TStr C1, const TStr C2, const TStr C3, const TStr C4, TVec< TIntV > &TopCascVV)
Parallel implementaion of CascFind takes as input a directed graph and returns all the top cascades i...
TIter BegI() const
Returns an iterator pointing to the first element in the vector.
void Push(const TVal &Val)
Adds an element at the end of the queue.
Node iterator. Only forward iteration (operator++) is supported.
Fast Queue used by the TBreathFS (uses memcpy to move objects TVal around).
const TVal & Top() const
Returns the value of the first element in the queue, but does not remove the element.
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
int GetOutNId(const int &NodeN) const
Returns ID of NodeN-th out-node (the node the current node points to).