Monitoring physical distancing for crowd management: Real-time trajectory and group analysis

Physical distancing, as a measure to contain the spreading of Covid-19, is defining a “new normal”. Unless belonging to a family, pedestrians in shared spaces are asked to observe a minimal (country-dependent) pairwise distance. Coherently, managers of public spaces may be tasked with the enforcement or monitoring of this constraint. As privacy-respectful real-time tracking of pedestrian dynamics in public spaces is a growing reality, it is natural to leverage on these tools to analyze the adherence to physical distancing and compare the effectiveness of crowd management measurements. Typical questions are: “in which conditions non-family members infringed social distancing?”, “Are there repeated offenders?”, and “How are new crowd management measures performing?”. Notably, dealing with large crowds, e.g. in train stations, gets rapidly computationally challenging. In this work we have a two-fold aim: first, we propose an efficient and scalable analysis framework to process, offline or in real-time, pedestrian tracking data via a sparse graph. The framework tackles efficiently all the questions mentioned above, representing pedestrian-pedestrian interactions via vector-weighted graph connections. On this basis, we can disentangle distance offenders and family members in a privacy-compliant way. Second, we present a thorough analysis of mutual distances and exposure-times in a Dutch train platform, comparing pre-Covid and current data via physics observables as Radial Distribution Functions. The versatility and simplicity of this approach, developed to analyze crowd management measures in public transport facilities, enable to tackle issues beyond physical distancing, for instance the privacy-respectful detection of groups and the analysis of their motion patterns.


Introduction
Crowd management is a challenging scientific topic directly impacting on the functioning of trafficked urban infrastructures such as, e.g., train or metro stations. Even more so, in time of Covid-19 pandemic, after an initial lock-down period, communities are still wondering how to resume a "new normal" life, while the virus is still circulating among the population. One of present our method and possible variations, that we employ to analyze mutual distancing data in Section 6. A final discussion in Section 7 closes the paper.

Related works: (Social) distance in pedestrian dynamics
The analysis of pairwise distances and the automated identification of family-groups triggered by the Covid-19 pandemics connect with outstanding technological and fundamental issues in the broader field of crowd dynamics. Crowd dynamics is a multidisciplinary research area aiming at understanding and modeling the motion of pedestrians in crowds (see, e.g., [7][8][9], for introductory references). Outstanding questions specifically connected to mutual distances and groups are, e.g.: "what is the impact of the group on the individual dynamics observables such as position and velocity?" "How do people in social groups interact?", "How does information propagates throughout groups?" (see e.g. [10][11][12][13][14] and e.g. [15] for a group-psychology review). Although these questions are longstanding, and have been investigated via models or in laboratory settings extensively, first quantitative studies in pedestrian dynamics driven by real-life big experimental datasets are relatively recent (see, e.g., [16][17][18][19]). Large-volumes of experimental data, in the order of hundred of thousands real-life trajectories, are indeed essential in order to analyze quantitatively and systematically the physics of pedestrian motion, disentangling the high variations in individual behaviors from average patterns, and characterizing typical fluctuations and universal features [19,20]. This relative delay in performing high-statistics based analyses of pedestrian motion (especially in comparison with other "active matter" physical systems [21]), is most likely due to the complex technical challenge of achieving accurate, privacy-preserving, individual tracking in real-life conditions (see, e.g., [20,22,23], or [24] for approaches targeting even higher resolution). Market solutions, as the one considered in this paper, are also becoming accessible, offering various trade-offs between accuracy and costs (see, e.g., [25]). On top of automated tracking, higher-level automated understanding of individual behaviors-a concept also known in computer science as trajectory pattern mining [26,27]remains also outstanding in many aspects. The automated identification of pedestrian groups, or pedestrian "group mining", is a notable example in this context. On one side, in current pedestrian dynamics research, the definition and classification of groups and social structures in experimental data has been manual, i.e. based on labor-intensive visual inspection (e.g. [28]). While this ensures high-quality validated measurements, it limits the possibility to establish vast statistical datasets towards data-driven characterizations of averages and fluctuations in the dynamics. On the other side, automatic strategies to identify groups have been proposed by the data mining community. These approaches primarily hinge on analyzing (instantaneous) spatial clusters of pedestrians and the consistency with which these adhere over time to some group semantics (flocking, convoying, aggregation/ desegregation, see [27,[29][30][31] and references within).
Here we pursue distance analyses and family-group identification via discretized mutual pairwise distance distributions-represented in physics terms via Radial Distribution Functions among relevant pedestrian pairs (the concept of RDF is further reviewed in Section 4). We accumulate information on a "social" interaction graph with vector edge weights. This data structure holds all the relevant contact times and distance statistics; besides, family-groups emerge as incremental features queryable by a space-time distance semantics. Graphs are classic tools in discrete mathematics to represent networks of interactions, or connections between entities (e.g. [32]). Formally speaking, a graph H is a set of nodes, H = {p i }, endowed with edges, say e = (p i , p j ), connecting node pairs. Providing a weight function, w(e), defined on the edges, makes the graph "weighted". In our case, nodes are in 1:1 correspondence with observed pedestrians, whereas edges underlie distance-based interactions, that are characterized by a weight function with values in a real vector space of pre-fixed dimension. Graphs have been often used for data-driven studies on social behavior both of humans, e.g. to analyze social networks [33], GPS-data [34], but also of social animals (e.g. [35,36]). In [19,37], graphs have also been used to address big-data analyses and representation of pedestrian dynamics aiming at efficient data searches.

Pedestrian tracking setup at Utrecht Central station
We benchmark our approach considering pedestrian tracking data acquired on platform 3 at Utrecht Central station, The Netherlands (cf. Fig 1). Utrecht Central, with roughly 57 million annual users, is the nation-wide busiest railway station. Since 2017, platform 3 has been equipped with 19 commercial pedestrian tracking sensors, each of which captures 3D stereo images at f = 10 frames per second and processes them to deliver individual tracking data in a privacy-friendly manner (cf. sketch in Fig 1). The sensor view-cones are in partial overlap, which enables the sensor network to stitch together trajectory pieces acquired by the single devices. The total area covered by the set of sensors consist of the full platform width (about 3m) for 120 linear meters next to track 5, plus the area underneath escalators and staircases connecting the platform to the central hall. This yields a covered area of approximately 450m 2 . Track 5 is among Utrecht's busiest tracks and is primarily utilized by trains heading to Amsterdam Central Station and Schiphol Airport. The complex and multi-directional crowd flows on the platform are recorded with high space-and time-resolution 24/7 since March 2017 (localization precision: O(5-10)cm, similar technology to what employed in [25]). In normal operation conditions, the system would capture about 100.000 trajectories per day while, on average, only 16.000 trajectories per day were observed in the two months after the Covid-19 outbreak (see pre-and during-Covid-19 crowd distribution example in Fig 1 and crowd density histograms in Fig 2). This unique measurement setup gives us not only the possibility of developing and testing our approach in meaningful real-life conditions, but also to compare relevant statistical observables of the pairwise distance (RDFs), before and during the Covid-19 measures.

Ethics statement
This study has been approved by the Ethical Review Board of Eindhoven University of Technology (ref. ERB2020AP1, 21 st , Feb. 2020). During this study we acquired passengers trajectory data (Utrecht station, Platform 3) via anonymous-by-design commercial sensors. The dataset considered includes thus individual trajectories and no additional personal feature has been available and/or stored.

Pedestrian radial distribution functions
In theoretical physics and molecular dynamics, the radial distribution function, g(r) (RDF), and the radial cumulative distribution function (RCDF), G(r), are established tools to characterize the distribution of pairwise distances between particles (see e.g. [38]), i.e., in our case, pedestrians.
By definition of RCDF, for a crowd with uniform spatial density ρ, on average, i.e. in the mean-field of many realizations, the number of people, N ρ (r), at a distance up to r from a generic individual satisfies therefore, g(r) = @ r G(r) holds. Thus, the functions g(r), G(r) (and derived quantities) do not carry any space/time specific information, rather they relate to average properties, depending only on mutual distances. For instance, in unconfined space, G(r) grows as the circle area, i.e.

N unconf
In our train platform, such a �r 2 growth ratio is possible only when r is sufficiently smaller  than the platform width. Else, we expect a �r 1 (linear) trend, as the area growth is bound to the platform length only. This holds until platform finite size effects come into play. In Fig 3 we compare the RDF and RCDF for the two density levels highlighted in Fig 2. We notice a depletion in the radial distribution functions at short distances when comparing with the situation pre-outbreak. As a partial anticipation of the results of this paper, in the figure we report also the RDF discounted of short-distance family-group interactions (such interactions are allowed by present regulations). As expected, this yields a further depletion of the RDF in the region r ≲ 1.5 m. In the figure, we additionally report the aforementioned analytic trends and the R(C)DF functions obtained through Monte Carlo numerical simulations in a rectangular domain with the same size as the platform. We specifically consider an ensemble of simulated crowds of N pedestrians; individuals have a random spatial distribution satisfying a minimal mutual distance of 0.2m. The figure reports ensemble-averaged RDFs and RCDFs which thus We compare the pre-Covid situation with the present, and with a Monte Carlo model of a random distribution of passengers across a region identical to the platform. We report the RDF and RCDF of the current situation including and excluding family-groups contributions, as made possible by the method introduced in Section 5.
Short mutual distances over extended time duration are known to increase the contagion probability: RDF and RCDF can be used to evaluate the average exposure time. A pedestrian that was on the platform for a time interval ΔT, was exposed, on average, for a time with r c being a critical distance threshold (e.g. r c can be the nation-wide physical distancing requirement). Similarly, the function quantifies the contribution to the total average exposure time given by peer pedestrians at distance r.

Distance-interaction network
In this section, we describe our scalable framework to characterize pedestrians pairwise distances, identify family-groups and distance offenders. Our approach is a substantial evolution of the graph approach presented by some of the authors in [19,37], which not only does enable to tackle, in real-time, relevant questions connected to Covid-19 safety measures, but unlocks the automation of relevant pedestrian dynamics aspects as the detection of groups. Relevant differences with the previous works [19,37] are postponed after the approach description. Our measurements come in the form of time-stamped trajectories. As no further information is available, such as body orientation or gaze direction [39] or body size/approximate age, our identification of family-groups relies only on mutual proximity and its time-consistency. Whenever two or more pedestrians maintain a mutual short distance consistently throughout a sufficient fraction of their trajectory, they should automatically emerge as belonging to the same family-group. Additionally, we deem implementation simplicity, while maintaining efficiency and sufficient accuracy in identifying family-groups relations, possibly in real-time, and without complex/costly data-searches. Hence, our approach is "additive" (or "incremental") and RDF-like information is increased, on the go, in a graph data structure (at minimal memory costs), and, without computationally-costly searches in stored records, family-groups and offenders remain identified immediately. In other words, by additivity, we stress that our data structure is built online and usable after only one time-forward pass of the trajectory data.

Graph data structure construction
In conceptual terms, we represent the pedestrian trajectories as individual nodes of a graph H. Each node includes information specific to the trajectories, such as overall observation time, τ, source and destination. These three quantities are incremental as, respectively, τ scales with the number of frames a pedestrian is observed, the source point is the initial point of a trajectory while the destination gets constantly updated with the current position until a pedestrian leaves the measurement area. Whenever two pedestrians, say p 1 and p 2 , are observed simultaneously (i.e. in the same frame) and their Euclidean distance, r = d(p 1 , p 2 ), is below a critical threshold D 0 > D, we memorize (properties of) this event within the weight,wðeÞ, of the edge e = (p 1 , p 2 ), that connects the two pedestrian-nodes p 1 , p 2 . Specifically, the weightwðeÞ aims at a discrete counterpart of the RDF (g(r), cf. Eq (1)) restricted to pedestrians p 1 , p 2 and with support 0 � r � D 0 . Similarly to the RDF, also the graph H does not hold detailed microscopic information in space/time, such as instantaneous positions. To focus on the identification of Corona events and disentanglement of family-groups, we set D 0 = 2.5 m, i.e. one meter more than the social distance required by Dutch regulations, D = 1.5 m< D 0 . This aims at exploring the distance dynamics in the neighborhood of the current regulations and leaves flexibility should the regulations become stricter and require additional mutual separation.
The vector weightwðeÞ keeps record of the number of occurrences of distance events, r, after a given radial quantization (binning). In the following, we consider five evenly-sized bins with sides at r ¼ fr 0 ; . . . ; r d ; . . .g ¼ f0; 0:5; 1:0; 1:5; 2:0; 2:5g m; ð5Þ for the sake of readability, we also indicate, the individual components ofwðeÞ,w d ðeÞ, as w 0 ðeÞ ¼wðeÞ½0:0 : 0:5�; w 1 ðeÞ ¼wðeÞ½0:5 : 1:0�; and so on. Hence, for each time instant in which d(p 1 , p 2 ) < 0.5, the counterwðeÞ½0 : 0:5� is incremented of one unit. Similarly, whenever 0.5 < d(p 1 , p 2 ) < 1.0, the weightwðeÞ½0:5 : 1:0� gets incremented, etc. Note that updating the data structure requires only all the pairwise distances (smaller than D 0 ) at each frame. The choice of bin size, which regulates the quality of the approximation of the RDF of p 1 and p 2 , is clearly arbitrary and needs to be a trade-off between the required resolution on the RDF and memory allowance. Consistently with Eq (4), scaling the countswðeÞ by the (inverse of the) sensors sampling frequency, f, yields the time duration, in seconds, pedestrians p 1 and p 2 maintain a given (quantized) distance (i.e. f À 1w ðeÞ½0:5 : 1:0� is the amount of seconds p 1 and p 2 had a distance between 0.5 and 1.0 meters). Hence, statistical moments of r, weighted by f À 1w ðeÞ enable to calculate the total contact time of p 1 and p 2 , their average distance and fluctuations. In all cases, the statistics are restricted to r � D 0 (insights on the relevant statistical properties of the graph are left to the next subsection). Operationally, we build the graph as reported in Algo-  (a) Conceptual sketch representing the accumulation of information on the graph H. Whenever two pedestrians, say p 1 , p 2 stand at a distance d smaller than D 0 , this gets recorded in the histogram weight of the edge between nodes p 1 and p 2 as an additive contribution to the bin approximating d.
In the sketch we report a section of the platform: edge appear between nodes according to the distance; the histogram weights are reported atop and beneath the sketch with the same color coding of the edges and scaled with the sampling time (thus they translate to the contact time conditioned by the distance). Nodes are reported in red if they have performed at least one Corona event (thus they have an edge with non-zero contributions at distances below D 0 ), else they are in green. (b) Examples of graphs acquired in windows of about ten minutes around each train arrival (determining the peaks in the counts at the bottom). We report a magnified version of one among these graphs. Nodes are colored by the node degree, i.e. by the number of first neighbors, ranging from yellow to red. Edge thickness scaled by the contact time, T d e , Eq (7). The higher the degree of a node, the larger the number of distance offenses performed by the associated pedestrian. https://doi.org/10.1371/journal.pone.0240963.g004

PLOS ONE
Algorithm 1: Graph construction algorithm in pseudo-code. The data structure is built streaming the trajectory data once. The function q = q(d) returns the distance bin to which d belongs. Hence, given the quantization in Eq (5), it holds q(0 < d < 0.5m) = 0, q(0.5m < d < 1.0m) = 1, etc. Extensions and variations. In settings as train platforms, not all the areas come with the same importance or criticality. The so-called "danger zone", the last 80cm-wide buffer region on the platform that is stepped on just before boarding a train, is an example. For our use case it is imperative to have the capability of discriminating between events happening inside and outside such an area. To achieve this, we consider two separate sets of weights on each edge: w dz ðeÞ andw c ðeÞ, which count, respectively, the time instants a given distance below D 0 occurs when the centroid between the two pedestrians lies in the danger zone, and otherwise. According to our previous definition,wðeÞ ¼w dz ðeÞ þw c ðeÞ holds. Fig 4a reflects this aspect by representingw dz ðeÞ andw c ðeÞ stacked (and with different color shade).

Approximation of the short-range RDF as edge average
The graph is a collection of RDFs functions restricted to pairs of pedestrians. As such, within the limits of the quantization, it is richer in information than the "global" RDF (Eq (1)). The latter, in fact, can be recovered by averaging the edge weights over the entire graph, i.e. by combining each pairwise contribution. Restricting to a graph describing conditions with equal density, the global RDF can be approximated as where c is a constant scaling depending on the normalization considered for g. In words, the integral of the RDF in the bin [r d , r d+1 ] can be approximated by the d-th (enseble-averaged) edge weight. Averaging over a graph including non-homogeneous density levels, yields the RDF averaged among such densities.

Interaction classification
In this subsection we leverage on the graph topology and edge data to deduce relevant information about pairwise distance, family-group relations, exposure times, and physical distance offenders. Pairwise exposure time and pairwise distance statistics. Pedestrians p 1 and p 2 , whose distance satisfied r = d(p 1 , p 2 ) � D 0 at least in one frame, have their interaction recorded on the graph edge e = (p 1 , p 2 ). The weightwðeÞ allows us to characterize their distance properties restricted to the instants in which r < D 0 . In particular, the contact time T e between p 1 and p 2 satisfies where the index d selects the farthest relevant distance bin. According to our quantization in Eq (5), d = 2 would restrict to interactions with r � 1.5 m and thus quantify the "exposure time" according to the Dutch regulations, whereas d = d max = 4 includes all stored interactions for the pair e, i.e. r � D 0 . Similarly, the average pairwise distance reads ½Avg: pairwise dist:� ð8Þ where r jþ 1 2 identifies the mid point between bin j and j + 1 in Eq (5). Higher order moments of r weighted bywðeÞ can be used to estimate the fluctuation (variance) of the distance in time.
In particular, if the variance s 2 ðrÞ ¼ hr 2 i d e À ðhri d e Þ 2 is small, then the pedestrians kept an almost fixed distance during their trajectories. Notably, small or possibly zero r variance, σ 2 (r), are necessary condition for non-positive (Finite Time) Lyapunov Exponent of the distance between p 1 and p 2 [40]. Total individual exposure time. The total time an individual p has been exposed to contacts can be computed by summing the pairwise contact times T d e (Eq (7)) for all pedestrians, p j , that entered into contact with p, i.e. for all the edges e = (p, p j ) that converge to p, in formulas where N(p) is the list of the first-neighbor of p (nodes connected to p through at least a single edge). Eq (9) provides a counterpart to Eq (3) in which we consider a specific pedestrian, p, rather than averaging over all pedestrians. Notice that the index d is the discrete analogue of the cutting threshold r c . Family-group relations. We determine whether two pedestrians, p 1 , p 2 , belong to the same family-group on the basis of their contact time T d ðp 1 ;p 2 Þ and their persistence time in the tracking area, t p 1 and t p 2 . In particular, if the symmetric relation henceforth indicated as p 1 � p 2 holds we consider p 1 and p 2 as belonging to the same family-group. We set λ (1) = 40%, λ (2) = 90% which, in words, translates to people who have a pairwise distance of less than 1.5m for 90% percent of the time and are within 1m for 40% percent of the time. The rationale being that pedestrians who followed the same trajectory, thereby being in mutual close proximity for the major part of their persistence time, and who are comfortable for extended periods in each other's private space (r � 1m) most likely belong to the same family-group. Family-groups with more than two individuals are expected to appear in the graph as completely connected sub-graphs, or cliques, in which all the nodes are in Relation (10) between each other.
We can now define a second total individual exposure time which is equal to T d p (Eq (11)) after discounting family-group contacts: Analogously, we can consider a RCDF discounted of family-group contributions, say G f (r) (cf. Eqs (1) and (3)), such that is the total exposure time with non-family individuals and up to a spatial threshold r c . By differentiation (as in Eq (1)), we can similarly define the RDF g f (r) discounted by family-groups. Family sub-graph transitive closure. The relation "�" can be non-transitive, i.e. p 1 � p 2 , p 2 � p 3 do not imply p 1 � p 3 . One may thus consider the transitive closure of "�", say "�" which is defined as p 1 and p 3 belong to the same family-group (p 1 �p 3 ) either if p 1 � p 3 or if they have common family-group members.
In the data we analyze in Section 6, we do not consider such transitive closure. In other words, family-group relations are exclusively defined by Relation (10). On one hand, we deem rare the event that a family remains not represented by a clique. Even in this case, we expect contributions to the overall RDF statistics be minimal. On the other hand, in real-life data collected with sensors similar to ours, short/broken trajectories may appear. We observed that these, in combination with Relation (10) would unrealistically increase the probability of observing large family-groups. Hence, to avoid excessive and unjustified complications in the heuristics we restrict to Relation (10).

Relevant interactions, family-discounted graph and offenders.
Combining the previous elements we can now identify distance offenders as those pedestrians that violate physical distancing while not being part of a family. We consider the sub-graph H 0 � H obtained after pruning H of family-group edges. The connections left in H 0 must indicate sporadic (i.e. not time-consistent) distance infringements.
As exposure time is deemed a critical parameter for contagion [41], we apply a further time requirement to discriminate actual offenders. Specifically, we introduce the set P 0 a defined as in words, elements of P 0 a are pedestrians who violated physical distancing with non-family members for an overall time longer than α. The number of first neighbors of a node in P 0 a identifies how many contacts such pedestrian had: we label as repeated offenders those with more than 10 first neighbors (i.e. pedestrians that violated physical distancing with more than 10 different people and for an overall time larger than α). We remark that this classification can be run in real-time as all the aforementioned requirements can be constructed in additive manner.

Differences with previous works by some of the authors
In [19,37] some of the authors leveraged on a similar interaction network to build a scalable representation and search tool for high-statistics real-life pedestrian tracking data. The aim there was to tackle fundamental issues about the physics of pedestrian dynamics (e.g., mechanics of pairwise avoidance, statistical observables of undisturbed pedestrian motion), which requires extracting pertinent data from databases with few million real-life trajectories. This was made possible and efficient by representing every target experimental scenario with a sub-graph topology. Matches of this topology within the experimental data correspond to the desired trajectory data. The graph structure hereby proposed focuses, instead, on processing streaming data for RDF and exposure time statistics. As a by-product, we automate detection of groups, in our case mostly families, and related properties.

Physical distancing at Utrecht Central station, platform 3
In this section we employ the graph H to analyze trajectory data collected in Utrecht station (see Section 3) and we compare statistics from before and during the Covid-19 pandemic.

Typical graphs and qualitative aspects
In Fig 4b, we report examples of the graphs acquired during a typical morning (time interval 4AM-8.30AM). Train arrivals are the most critical conditions when it comes to respecting physical distancing, thus we create a new graph two minutes after each train departure, when the platform is almost empty (this step is not strictly necessary, but increases computational efficiency). In the figure, nodes size and color follows the node degree, i.e. the number of first neighbors and, thus, the distance offenses committed by that node.
As a qualitative example of the capability of the method to extract relevant data, we showcase two antipodal conditions in Fig 5. In the first case (left panel), we report two pedestrians in a family-group relation that remain together throughout their entire trajectories: from the escalators to the boarding. In the second case, we have a repeated offender: the associated node exhibits 28 first-neighbor connections. Interestingly, a significant part of the offenses happens while the pedestrian waits in proximity of the escalator. This, therefore, rather marks a waiting area to be disallowed, than a willing offender.

Family-group discounted RDFs
In Figs 3 and 6 we report RDFs prior and after excluding family-group interactions. The RDFs for r < D are non-vanishing, even after discounting the contributions of family-groups, most significant in the weekends (when the presence of workers and commuters is lower; cf. shortdistance "bump" in Fig 6). We expect these remaining contributions at r < D to be to Corona events by distance offenders. Notably, once removed of family-groups contributions, the RDFs at small r values recover a linear growth rate, as expected by a random spatial distribution of passengers (scaling as the derivative of Eq (2)).

Exposure time, node degree and evolution through the pandemics
In Fig 7a we report, week-by-week, the average edge weight as introduced in Eq (6), pruned of family-group contributions and scaled by the sampling frequency. This provides an approximation of how the (family-discounted) average individual exposure time has been changing over time (weeks 17 to 26 in 2020). As the usage of the platform grew after a drop at the beginning of the outbreak, so did the exposure time for distances between 0.5m and 2.5m, especially until week 22. On the opposite, the amount of time, per person, spent with a peer within 0.5m has remained constant and within fractions of a second. A new operation schedule at week 23,  . This ratio, which we further scale to its value at week 18, displays a �100% growth between week 18 and 26, to confirm that the increment of passengers contributes only for 150% of the overall exposure time growth. with increased train frequency throughout the day, allowed a temporary reduction of the load on the platform, making easier to respect physical distancing. From week 24 onward, individual exposure times showed again a growing trend. To render the data comparable, we consider also exposure times compensated for the new train schedule (Fig 7a, This shows a more stable growth pattern and an increase of factor 3.5 between weeks 17 and 26 (the factor γ is an estimate, considering the presence of trains of different kind and lengths). Scaling the corrected exposure times with the number of passengers, which is itself growing, we additionally notice, that the former is growing faster (i.e. exposure time grow super-linearly with respect to the passengers). This suggests a possible relaxation or an increased difficulty in following physical distancing regulations. We report in Fig 8a an in-depth breakdown of the distribution of node degrees, i.e. the number of first neighbors of each node and thus the number of contacts with different individuals the node had (including both offenses and families). Consistently with our previous observations, the fraction of high degree nodes (5+ or 10+), i.e. repeated offenders, has also been growing steadily, but a temporary drop following the train schedule change. In Fig 8b we display the distribution of individual exposure times pruned of family contributions, and up to the distance thresholds r d (Eq (5)), i.e. the pdfs of T d p;f (cf. Eq (11)). Similarly to what discussed in [42], and consistently with the model in [43], we observe a power-law distribution in the exposure times (exponent p < −2), which emerges as a robust feature of random encounter dynamics. Additionally, we notice that the distance threshold plays a strong multiplicative effect and, possibly, it also weakly influences the exponent. It is worth remarking that our largest observation times are bound by the fact that we limit our graphs to time intervals of about 10-15 minutes around each train arrival. This reduces our resolution at large time scales and thus yields the exponential-like drop in the distribution tails. Fig 8. (a) Distribution of node-pedestrian degree per day as a percentage of the total number of passengers. The degree of a node counts the number of people encountered with a mutual distance smaller than 1.5m (hence, degree 0 means that a person did not have any Corona event). We observe that high-degree nodes, i.e. repeated distance offenders, increased steadily until the train schedule change (e.g. nodes with 10+ contacts grew from �1% to �10%). The schedule change yielded a temporary drop in the offender percentage after which it started increasing again. This can be a sign of warning towards the relaxation in the compliance of physical distancing rules. (b) Probability density function of the individual exposure time discounted of families, T d p;f considering different maximum distances (Eq (9)). Exposure times show a power-law behavior. The PDF depletion after T = 5minutes is most likely due to the time windowing that we operate around each train arrival (cf. Fig 4b). This yields a data cut-off for large times. https://doi.org/10.1371/journal.pone.0240963.g008

Crowd density: Incidence of family-groups and effective offenders
The passenger density on the platform has an influence on the offenses: the higher the density the easier it gets to violate physical distancing. In Fig 9a we report for a sample day (12 th of June 2020), how the percentage of "family" nodes and offenders scales with the density within the global density interval [0, 0.5]ped/m 2 . As in Eq (13), we also include minimum contact time thresholds, α, for tagging offenders. We observe that the percentage of nodes belonging to family-groups remains stationary (value �11%, a detailed breakdown of the clique size is in Fig 9b). Up to 80% of the pedestrians at the maximum density level committed offenses assuming no minimum time threshold (α = 0). This percentage slightly diminishes to 60% restricting to a minimum contact time α = 5s. Interestingly, the percentage shows a non-linear dependency on the density when α = 30s. In particular, such percentage remains stationary (value � 11%) until 0.2ped/m 2 and then suddenly increases. This can suggest an increase in difficulty in following distancing rules around this density level. We report the coefficients of the linear fitting of such data in Table 1. Fig 9. (a) Percentage of pedestrian nodes exposed to contacts as a function of the global density on the platform (density calculated as number of people in a frame divided by the total sensor area, 450m 2 , discounted of the danger zone, 96m 2 ). Exposed nodes that have at least one contact, of any duration, with another pedestrian (within or outside their family-group or not) are in blue. This percentage if further broken down into nodes part of a family group (red) and actual distance offenders (green). The purple and orange lines restrict, respectively, to nodes with a minimum exposure time of 10s and 30s. Linear fitting parameters are reported in Table 1. (b) Distribution of individuals and cliques day-by-day as a percentage of the total number of nodes. Between 80% and 85% of the nodes do not belong to cliques, i.e. they travel alone and their contacts are all distance infringements. Familygroups of two people cover about 12%-15% of the remaining nodes; family-groups of three and more provide a minimal �3% contribution.

δ � 0 Slope
Ped.-nodes with any contact 28.5% 13.4%/δ Ped.-nodes exposed 17.1% 12.9%/δ Ped.-nodes with exposure α > 10s 9.56% 12.4%/δ Ped.-nodes part of a family-group 11.5% 0.48%/δ As a measurement unit for the pedestrian density we employ tenths of pedestrians per square meter: δ = 10 −1 ped/m 2 . Thus the fitting intercept is at δ = 0 while the increments (slopes) are reported as percent variations per δ unit. As an example, pedestrians that do not belong to a family-group and are in contact with someone else grow about 13% when the density increases between 0.2 and 0.3ped/m 2 and similarly between 0.3 and 0.4 and so on. We do not report linear fitting parameters for the case α = 30s as the growth is non-linear. https://doi.org/10.1371/journal.pone.0240963.t001

Discussion
We have presented an highly efficient and accurate approach to the problem of studying, in real-time, the distance-time encounter patterns in a crowd of individuals. Our approach allows us to identify social groups, such as families, by imposing thresholds on the distance-time contact patterns. In the context of the currently ongoing Covid-19 pandemic, we demonstrate this as an effective and promising tool to monitor, in a full privacy respectful way, the observation of physical distancing. The outcome of the analysis can provide early warnings in respect to an average relaxation towards the compliance of physical distance rules, can allow to identify spots where physical distancing most frequently is violated and it may, as well, allow to identify in real-time the presence of distance offenders. We observed, besides, a super-linear dependence between contact times and passenger number. This can be caused both by a reduction of attention towards social distancing rules but also to an intrinsic increase in difficulty in complying to regulations. The investigation of this aspect is left to future research. The proposed algorithm is simple and can be easily implemented using existent graph code libraries. In our case, we could process a day of data in few minutes using the python Net-workX library [44]. Libraries sporting higher performance and/or scalability exist in case of even more demanding situations.
It is worth mentioning that the approach here proposed can be applied to any type of tracing trajectories and possibly to study the collective dynamics of large groups of active or passive particles making it a tool capable of going well beyond the application to crowd dynamics and physical distancing discussed here.