Research Article
MA-STS-Based Social Intimacy Analysis Algorithm Using Real Campus Network Data
Algorithm 1
Calculate the coincident time period algorithm of the trajectory.
| Enter trajectory tra1, trajectory tra2 | | Output the ratio of the total time spent on Mac online during the overlapping time period of tra1 and tra2 | (1) | m = len (Time (tra1)), n = len (Time (tra2)), l = k = 0 | (2) | if m and n: | (3) | while True: | (4) | if l >= m && k >= n then | (5) | break | (6) | if tra2 [k].time [1] <= tra1 [l].time [0] then | (7) | k ++ | (8) | continue | (9) | elif tra2 [k].time [0] >= tra1 [l].time [1] || tra2 [k].time [1] >= tra1 [l].time [1] then | (10) | l ++ | (11) | if tra1.pos = = tra2.pos then | (12) | time_stamp←max (tra2 [k].time [0], tra1 [l].time [0])−min (tra2 [k].time [1], tra1 [l].time [1]).total_seconds () | (13) | associated_time + = time_stamp | (14) | end if | (15) | end while | (16) | return (associated_time/(m + n/2)) |
|