Algorithm 2: A basic DFS algorithm FPM for finding all
(r, k)-flock patterns in an input trajectory database S given
maximum width r and minimum length k.
1: procedure FPM(ID, S, r, k)
2: for ℓ ← k, ... ,T do ⊲ Every length
3: for b
0
← 1,.. . ,T do ⊲ Each start time in T
4: ℓ
0
← b
0
+ ℓ − 1;
5: ID
1
← ID;
6: while ID
1
6=
/
0 do ⊲ Each id in ID
7: i
0
= deletemin(ID
1
);
8: P
0
← ({i
0
}, [b
0
,ℓ
0
]); ⊲ Initial pattern
9: RecFPM(P
0
,ID
1
,S, r, k);
10: procedure RECFPM(P = (X, [b, e]),ID,S, r, k)
11: if ||P||
∞
S
> r then
12: return ; ⊲ P is too wide
13: output P;
14: ID
1
← ID;
15: while ID
1
6=
/
0 do
16: i = deletemin(ID
1
);
17: RecFPM(Q = (X ∪ {i},[b,e]), ID
1
,S, r, k);
18: end while
Similarly, we can consider the flock pattern min-
ing problem with parameters (r, k, m).
We evaluate the performance of a flock pattern
mining algorithm A in terms of enumeration algo-
rithms (Avis and Fukuda, 1993). Let N and M be the
input size and the number of patterns as solutions. A
pattern mining algorithm A is said to have polynomial
delay (poly-delay) if the delay, which is the maximum
computation time between two consecutiveoutputs, is
bounded by a polynomial p(N) in N. A is of polyno-
mial space (poly-space) if the maximum size of its
working space, in addition to that of output stream O,
is bounded by a polynomial p(N).
3 ALGORITHMS
In this section, we present our pattern mining algo-
rithms for FPs and RFPs. We also give a speed-up
technique using geometric indexes to prune redundant
candidates.
3.1 A Basic DFS Algorithm for FPs
We first present a basic mining algorithm FPM (ba-
sic flock pattern miner) for FPs. In Algorithm 2
we present the algorithm FPM with its subprocedure
RecFPM for mining (r, k)-FPs.
In the overall design of our algorithm FPM, we
employ DFS (depth-first search) procedure according
to pattern growth approach (e.g., (Pei et al., 2004)) ap-
proach, as in PrefixSpan (Pei et al., 2004), Eclat (Zaki,
2000) and LCM (Uno et al., 2004).
In DFS (or pattern growth) approach, a recursive
mining procedure searches for all descendant of the
current pattern from smaller to larger in depth-first
manner using backtracking. The advantage of DFS
approach is that DFS miners are proven fast in main
memory environment and can be easily implemented
as a simple recursive procedure.
At the top-level of FPM, for each possible length
ℓ ∈ [k,T] no less than k, it invokes the recursive sub-
procedure RecFPM given as arguments an initial pat-
tern P
0
= (X
0
,[b
0
,e
0
]) consisting of a singleton ID set
X
0
= {i
0
} and an interval [b
0
,e
0
] for every possible
combination of i
0
∈ ID and b
0
∈ [0, T]. The end time
e
0
is calculated by b
0
and ℓ.
The recursive subprocedure RecFPM is a DFS al-
gorithm (or a backtracking algorithm) that searches
the hypothesisspace of all r-flock patterns with length
exactly ℓ as follow.
Starting from the initial pattern P
0
= (X
0
,[b
0
,e
0
])
consisting of a singleton ID set X
0
= {i
0
}, the
procedure enumerates all subsets X of ID using a
backtracking algorithm similar to depth-first search
algorithms for frequent itemset mining, such as
Eclat (Zaki, 2000) and LCM (Uno et al., 2004).
For each generated subset X, the procedure forms
a candidate (r, k)-flock pattern P = (X, [b, e]) with a
specified interval [b, e]. Then, the algorithm computes
the width ||P||
∞
of the pattern P by accessing the tra-
jectories in S, and checks if P satisfies the width con-
straint || P||
∞
≤ r. If the condition is violated, then it
prunes the search for P and all of its descendants.
This width-based pruning rule is justified by the
following lemma, which says the class of (r, k)-
patterns has the anti-monotonicity w.r.t. set inclusion
of their ID sets.
Lemma 2 (anti-monotonicity). Let P
i
= (X
i
,I
i
) be two
flock patterns, where i = 1, 2. If P
2
is an (r, k)-flock
pattern in S and if X
1
⊆ X
2
and I
1
⊆ I
2
hold, then P
1
is also an (r, k)-flock pattern in S.
From this lemma, once a candidate pattern P =
(X, I) does not satisfy the width and length con-
straints, any descendant of P obtained by adding new
trajectory (ids) to X no longer satisfies the constraints.
Therefore, we can prune the whole search sub-space
for descendants of P for (r, k)-flock patterns.
On the running time and space of the algorithm
FPM, The following proposition is easily derived
from our manuscript (Arimura et al., 2013).
Proposition 1. (Arimura et al., 2013) Let S be an in-
put trajectory database S of n trajectories with length
T. Then, the algorithm FPM in Algorithm 2 solves the
KDIR2013-InternationalConferenceonKnowledgeDiscoveryandInformationRetrieval
146