<?xml-model href='http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng' schematypens='http://relaxng.org/ns/structure/1.0'?><TEI xmlns="http://www.tei-c.org/ns/1.0">
	<teiHeader>
		<fileDesc>
			<titleStmt><title level='a'>Faster and Generalized Temporal Triangle Counting, via Degeneracy Ordering</title></titleStmt>
			<publicationStmt>
				<publisher></publisher>
				<date>2021</date>
			</publicationStmt>
			<sourceDesc>
				<bibl> 
					<idno type="par_id">10279400</idno>
					<idno type="doi"></idno>
					<title level='j'>KDD</title>
<idno>2154-817X</idno>
<biblScope unit="volume"></biblScope>
<biblScope unit="issue"></biblScope>					

					<author>Noujan Pashanasangi</author><author>C. Seshadhri</author>
				</bibl>
			</sourceDesc>
		</fileDesc>
		<profileDesc>
			<abstract><ab><![CDATA[Triangle counting is a fundamental technique in network analysis, that has received much attention in various input models. The vast majority of triangle counting algorithms are targeted to static graphs. Yet, many real-world graphs are directed and temporal, where edges come with timestamps. Temporal triangles yield much more information, since they account for both the graph topology and the timestamps.Temporal triangle counting has seen a few recent results, but there are varying definitions of temporal triangles. In all cases, temporal triangle patterns enforce constraints on the time interval between edges (in the triangle). We define a general notion (δ1,3,δ1,2,δ2,3)-temporal triangles that allows for separate time constraints for all pairs of edges.Our main result is a new algorithm, DOTTT (Degeneracy Oriented Temporal Triangle Totaler), that exactly counts all directed variants of (δ1,3,δ1,2,δ2,3)-temporal triangles. Using the classic idea of degeneracy ordering with careful combinatorial arguments, we can prove that DOTTT runs in O(mκlogm) time, where m is the number of (temporal) edges and κ is the graph degeneracy (max core number). Up to log factors, this matches the running time of the best static triangle counters. Moreover, this running time is better than existing.DOTTT has excellent practical behavior and runs twice as fast as existing state-of-the-art temporal triangle counters (and is also more general). For example, DOTTT computes all types of temporal queries in Bitcoin temporal network with half a billion edges in less than an hour on a commodity machine.]]></ab></abstract>
		</profileDesc>
	</teiHeader>
	<text><body xmlns="http://www.tei-c.org/ns/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink">
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1">INTRODUCTION</head><p>Triangle counting is a fundamental problem in network analysis. There has been a rich line of work on counting triangles in graphs <ref type="bibr">[2,</ref><ref type="bibr">3,</ref><ref type="bibr">15,</ref><ref type="bibr">22,</ref><ref type="bibr">43]</ref>. The triangle counts appear in form of different parameters such as clustering coefficient <ref type="bibr">[55]</ref> and transitivity ratios <ref type="bibr">[54]</ref>. Triangle counting has many applications such as social networks analysis <ref type="bibr">[36]</ref>, indexing graph databases <ref type="bibr">[18]</ref>, community discovery <ref type="bibr">[32]</ref>, and spam detection <ref type="bibr">[4]</ref>.</p><p>Much of the rich history of triangle counting has focused on static graphs. But many real-world networks, such as communication networks, message networks, and social interaction networks are fundamentally temporal. Every edge has an associated timestamp <ref type="bibr">[11,</ref><ref type="bibr">12,</ref><ref type="bibr">20]</ref>. We can model these attributed networks as temporal networks where edges have timestamp. For example, in cryptocurrency transaction networks and email networks, each link is between a sender and a receiver and has a timestamp that could be represented as a directed edge with a timestamp in a temporal network.</p><p>Temporal triangle counts provide a far richer set of counts than standard counts. These counts take into account the temporal ordering of edges in a triangle, and potentially impose constraints on the timestamp difference among edges. Temporal triangle and motif counting has applications in graph representation learning <ref type="bibr">[48]</ref>, expressivity of graph neural networks (GNNs) <ref type="bibr">[7]</ref>, network classification <ref type="bibr">[47]</ref>, temporal text network analysis <ref type="bibr">[52]</ref>, computer networks <ref type="bibr">[50]</ref>, and brain networks <ref type="bibr">[9]</ref>. Recently, there has been significant interest in temporal triangle and motif counting algorithms <ref type="bibr">[6,</ref><ref type="bibr">7,</ref><ref type="bibr">25,</ref><ref type="bibr">27,</ref><ref type="bibr">35,</ref><ref type="bibr">[46]</ref><ref type="bibr">[47]</ref><ref type="bibr">[48]</ref><ref type="bibr">53]</ref>.</p><p>Counting temporal triangles in (directed) temporal networks introduces new challenges to that of triangle counting in static graphs. The first challenge is actually defining types of temporal triangles (or motifs). In essence, all definitions specify constraints on the time difference between edges of a triangle. For example, Kovanen et al. <ref type="bibr">[20]</ref> restrict temporal triangles to cases where the gap between two consecutive edges in the temporal ordering is at most &#916; time unit, and the two edges incident to each node are consecutive event of that node. Paranjape-Benson-Leskovec (henceforth PBL) introduce &#120575;-temporal triangles, where all edges of the triangle/motif have to occur within &#120575; timesteps <ref type="bibr">[33]</ref>. These varying definitions necessitate different algorithms. Our first motivating question is whether one can design algorithms for a more general notion of temporal triangles.</p><p>Secondly, there is a significant gap between the best static triangle counting algorithms and temporal triangle counters. Specifically, the classic and immensely practical triangle counting algorithm of Chiba-Nishizeki runs in time &#119874; (&#119898;&#120581;), where &#119898; is the number of edges and &#120581; is the graph degeneracy (or max core number). The current state-of-the-art temporal triangle counting algorithm of PBL runs in &#119874; (&#119898; &#8730; &#120591;) time, where &#120591; is the total triangle count (of the underlying static graph). There is a large gap between &#120581; (which is typically in the hundreds and thought of as a constant) and &#120591; (which is superlinear in &#119898;).</p><p>These twin issues motivate our study. Can we define a more general notion of temporal triangles, and give an algorithm whose asymptotic running time is closer to that of static triangle counting?</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.1">Problem Description</head><p>The input is a directed temporal graph &#119879; = (&#119881; , &#119864;). Each edge is a tuple of the form (&#119906;, &#119907;, &#119905;) where &#119906; and &#119907; are vertices in the temporal graph, and &#119905; is a timestamp. For notational convenience, we assume all timestamps in a temporal network are unique integers.</p><p>We introduce our notion of (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles.</p><p>Definition 1.1. Let &#119890; 1 = (&#119906; 1 , &#119907; 1 , &#119905; 1 ), &#119890; 2 = (&#119906; 2 , &#119907; 2 , &#119905; 2 ), and &#119890; 3 = (&#119906; 3 , &#119907; 3 , &#119905; 3 ), be three directed temporal edges where the induced static graph on them is a triangle, and &#119905; 1 &lt; &#119905; 2 &lt; &#119905; 3 .</p><p>(&#119890; 1 , &#119890; 2 , &#119890; 3 ) is a (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangle if &#119905; 2 -&#119905; 1 &#8804; &#120575; 1,2 , &#119905; 3 -&#119905; 2 &#8804; &#120575; 2,3 , and &#119905; 3 -&#119905; 1 &#8804; &#120575; 1,3 . Thus, we specify timestamp differences between every pair of edges. When one also considers the direction of edges, there exist eight different types of temporal triangles as shown in Fig. <ref type="figure">2</ref>. These types are distinguished by temporal ordering of edges and their direction. Thus, for any choice of (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 ), there are eight different types of temporal triangles (one corresponding to each figure in Fig. <ref type="figure">2</ref>).</p><p>We observe that the notion in Definition 1.1 subsumes most existing temporal triangle definitions. Specifically, a (&#120575; 1,3 , &#120575; 1,3 , &#120575; 1,3 )temporal triangle becomes a &#120575; 1,3 -temporal triangles as defined in PBL <ref type="bibr">[33]</ref>. Temporal triangles with respect to the temporal motif definition by by <ref type="bibr">Kovanen et al. in [20]</ref> consider timestamp differences between consecutive edges in temporal ordering. By our definition, (2&#916;, &#916;, &#916;)-temporal triangles capture these types of temporal triangles. Although, the definition in <ref type="bibr">[20]</ref> is more restrictive and requires that all edges incident to a node are consecutive events of that node. Most existing temporal triangle counting literature uses these definitions <ref type="bibr">[25,</ref><ref type="bibr">27,</ref><ref type="bibr">46,</ref><ref type="bibr">53]</ref>. We describe a simple example to see how Definition 1.1 offers richer temporal information. Let us measure time in hours, so (2, 1, 1)-temporal triangle is one where the first and second edge (of the triangle) are at most 1 hour apart, and similarly for the second and third edge. Now consider (1.5, 1, 1)-temporal triangles. The time gap between the first and second edge (as well as the second and third) is again 1 hour, but the entire triangle must occur within 1.5 hours. There is a significant difference between these cases, but previous definitions of temporal triangles would not distinguish these.</p><p>We note that more general temporal motifs, beyond triangles, have been defined. Yet, to the best of our knowledge, most fast algorithms that scale to millions of edges have been designed for triangles. Paranjape et al. specialized algorithm for 3-edge triangle motifs (temporal triangles) is up to 56x faster than their general motif counting algorithm <ref type="bibr">[33]</ref>. Our focus was on scalable algorithms, and hence, on triangle counting. We believe that generalizing Definition 1.1 (and our DOTTT algorithm) for general motifs would be compelling future work.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.2">Main Contributions</head><p>Our main result is the Degeneracy Oriented Temporal Triangle Totaler algorithm, DOTTT that counts (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles as defined in Definition 1.1. The running time is only a logarithmic overhead over static triangle counting. We detail our contributions below.</p><p>Theoretically bridging gap between temporal and static triangle counting: Our main theorem is the following. Theorem 1.2. Given &#120575; 1,3 , &#120575; 1,2 and &#120575; 2,3 , the DOTTT algorithm exactly counts each of the eight types of (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles (Fig. <ref type="figure">2</ref>) in a temporal graph in &#119874; (&#119898;&#120581; log &#119898;) time. (Here, &#119898; is the total number of temporal edges, and &#120581; is the degeneracy of the underlying static graph.)</p><p>Observe that, up to a logarithmic factor, our theoretical running time for temporal triangle counting matches the &#119874; (&#119898;&#120581;) bound for static triangle counting. As mentioned earlier, the previous best bound was &#119874; (&#119898;&#120591; 1/2 ). We stress that there is no dependence on the time intervals (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 ).</p><p>The idea of degeneracy orientations is tailored to static graphs, and one of our contributions is to show it can help for temporal triangle counting. A key insight in DOTTT is to process (underlying) static edges in the exact order of the Chiba-Nishizeki algorithm, but carefully consider neighboring edges to capture all temporal triangles. By a non-trivial combinatorial analysis, we can prove that number of times that a temporal edge is processed is upper bounded by &#120581;. We need additional data structure tricks to get the counts efficiently, leading to an extra logarithmic factor.</p><p>Excellent practical behavior of DOTTT: DOTTT consistently determines temporal triangle counts in less than ten minutes for datasets with tens of millions of edges. We only use a single commodity machine with 64GB memory, without any parallelization. We directly compare DOTTT with the state-of-the-art PBL algorithm. Our algorithm is consistently faster, and as illustrated in Fig. <ref type="figure">1a</ref> we typically get a factor 1.5 speedup for larger graphs. (We note that DOTTT can count a more general class of temporal triangles.)</p><p>We note that for the largest dataset in our experiments, Bitcoin (515.5M edges), DOTTT only uses 64GB memory and runs in less than an hour, while existing methods ran out of memory (details in &#167;6).</p><p>Richer triadic information from (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles: We demonstrate how (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles can give a richer network analysis method. Consider Fig. <ref type="figure">1b</ref>. For a collection of temporal datasets, we generate the counts of (1 hr, 30 min, 30 min)-temporal triangle counts, as well as those for (1 hr, 10 min, 50 min)-temporal triangles. We plot these numbers as a ratio of (1 hr, 1 hr, 1 hr)-temporal triangles. Across the datasets, the ratios  We note here that for each dataset, DOTTT has the same running time for obtaining the counts for (1 hr, 30 min, 30 min)-temporal triangle and (1 hr, 10 min, 50 min)-temporal triangles, as it has no dependency on the time intervals (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 ).</p><p>An interesting study is presented in Fig. <ref type="figure">1c</ref>. The transitivity and clustering coefficients are fundamental quantities of study in network science. In temporal graphs, in addition to these measure, the time it takes for a wedge (2-path) to close could also be of importance. (Zingnani et al. proposed the triadic closure delay metric that capture the time delay between when a triadic closure is first possible, and when they occur <ref type="bibr">[58]</ref>.) In Fig. <ref type="figure">1c</ref>, we fix &#120575; 1,3 = 2 hrs and &#120575; 1,2 = 1 hr. We then vary &#120575; 2,3 from zero to 60 minutes, and plot the ratio of (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles to (2hrs, 1hr, 1hr)-temporal triangles. We can see the trends in triadic closure with respect to the time for the third edge. We observe that, by and large, half the triangles are formed within 20 minutes of the first two edges appearing. And by 30 minutes, almost 75% of these triangles are formed. These are examples of triadic analyses enabled by DOTTT.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="1.3">Main challenges</head><p>In a temporal graph, the number of temporal edges is typically two to three times the number of underlying static edges. Since most triangle counting algorithms are based on some form of wedge enumerations, this leads to a significant increase in the number of edges. One method used for temporal triangle counting is to simply prune the temporal edges based on the time period <ref type="bibr">[27,</ref><ref type="bibr">45]</ref>. But such algorithms have a dependency on the time period and are inefficient for large time periods.</p><p>Another significant challenge is the multiplicity of an individual edge can be extremely large. The same edge often occurs many hundreds to thousands of times in a temporal network (in the BitCoin network, there is an edge appearing 447K times Tab. 2). These edges create significant bottlenecks for enumeration methods. It is not clear how efficient methods on the underlying static graphs (which ignores multiplicities) can help with this problem. Triangle counting often works by finding a wedge (2-path) and checking for the third edge. With multiple temporal edges between the same pair of vertices, this method requires many edge lookups. Paranjape et al. used a clever idea to process edges on a pair of vertices &#119874; (&#120591; 1/2 ) times. The challenge is to bound it by the degeneracy of the graph.</p><p>The time constraints expressed by (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles create additional challenges. A clever wedge enumeration exploiting the degeneracy may produce wedges containing the first and second edges of the triangle, the first and third, or the second and third. This makes the lookup (or counting) of possible "matches" for the remaining edge challenging, since it appears we need to look at all multiple edges. On the other hand, if we enumerated wedges that only involved the first and second edge, we cannot benefit for the efficiencies of degeneracy-based methods. Some of these problems can be circumvented for (&#120575;, &#120575;, &#120575;)-temporal triangles, but the general case is challenging.</p><p>Overall, we can state the main challenge as follows. Fast triangle counting methods (such as degeneracy based methods) necessarily ignore time constraints while generating wedges, making it hard to look for the "closing" edge. On the other hand, a method that exploits the timestamps by (say) pruning cannot get the efficiency gains of degeneracy based methods. One of the insights of DOTTT is a resolution of this tension.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="2">RELATED WORK</head><p>There is rich history of work on triangle counting in static graphs. Various algorithm for triangle and motif counting in attributed graphs have also been proposed <ref type="bibr">[13,</ref><ref type="bibr">30,</ref><ref type="bibr">37,</ref><ref type="bibr">41,</ref><ref type="bibr">42,</ref><ref type="bibr">56]</ref>. Here we only focus on temporal networks and refer the reader to <ref type="bibr">[2]</ref> and the tutorial <ref type="bibr">[44]</ref> for a more detailed list of related work.</p><p>Graph orientation, in particular degeneracy ordering, is a classic idea in counting triangles and motifs in static graphs, pioneered by Chiba-Nizhizeki <ref type="bibr">[8]</ref>. Recently, there has been a number of triangle counting and motif counting algorithms inspired by these techniques <ref type="bibr">[10,</ref><ref type="bibr">16,</ref><ref type="bibr">17,</ref><ref type="bibr">31,</ref><ref type="bibr">34,</ref><ref type="bibr">38]</ref>. The main benefit of degeneracy ordering is that the out-degree of each vertex becomes small when we orient the static graph based on this ordering.</p><p>Kovanen et al. called two temporal edges &#916;&#119879; -adjacent if they share a vertex and the difference of their timestamps are at most &#916;&#119879; <ref type="bibr">[20]</ref>. In their definition of temporal motifs, temporal edges must represent consecutive events for a node. Redmond et al. gave an algorithm for counting &#120575;-temporal motifs but their algorithm does not take the temporal ordering of edges into account <ref type="bibr">[39]</ref>, and only counts motifs where incoming edges occur before outgoing edges. Gurukar et al. present a heuristic for counting temporal motifs <ref type="bibr">[14]</ref>.</p><p>More related to our work, Paranjape-Benson-Leskovec defined the &#120575;-temporal motifs where all edges occur inside a time period &#120575; and also the temporal ordering of edges are taken into account <ref type="bibr">[33]</ref>. They gave a general algorithm for counting &#119896;-node &#8467;-edge motifs in temporal networks. The main idea behind their algorithm is a moving time window of size &#120575; over the sequence of all temporal edges for each static motif matching the underlying static motif of the temporal motif of interest. For temporal triangles, their algorithm runs in &#119874; (&#120591;&#119898;) time where &#120591; is the number of triangles in the underlying static graph of the input temporal graph &#119879; , as it might enumerate temporal edges on static edges with high multiplicity &#119874; (&#120591;) time. They also presented a specialized, more efficient algorithm for counting 3-edge temporal triangles that runs in time &#119874; (&#120591; 1/2 &#119898;). We call their algorithm &#119875;&#119861;&#119871; and use it as our baseline.</p><p>Mackey et al. presented a backtracking algorithm for counting &#120575;-temporal motifs that maps edges of the motif to the edges of the host graph one by one in temporal (chronological) ordering. For each edge, it only searches through edges that occur in the correct temporal ordering and respect the time gap restriction. <ref type="bibr">[27]</ref>. Unlike the PBL algortihm and ours, this algorithm could be inefficient for large values of &#120575; as its runtime depends on the value of &#120575;.</p><p>Liu et al. <ref type="bibr">[26]</ref> introduced a comparative survey of temporal motif models. Boekhout et al. gave an algorithm for counting &#120575;-temporal multi-layer temporal motifs <ref type="bibr">[6]</ref>. Li et al., developed an algorithm for counting temporal motifs in heterogeneous information networks <ref type="bibr">[24]</ref>. Petrovic et al. gave an algorithm for counting causal paths in time series data on networks <ref type="bibr">[35]</ref>.</p><p>There has also been recent progress on approximating the counts of temporal motifs and triangles <ref type="bibr">[46,</ref><ref type="bibr">53]</ref>. Particularly , Liu et al. presented a sampling framework for approximating the counts of &#120575; 1,3 -temporal motifs <ref type="bibr">[25]</ref>.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="3">PRELIMINARIES</head><p>The input graph is a directed temporal graph that we denote by &#119879; (&#119881; , &#119864;). Let |&#119881; | = &#119899; and |&#119864;| = &#119898;. Temporal graph &#119879; is presented as a collection of &#119898; directed temporal edges &#119890; = (&#119906;, &#119907;, &#119905;) where &#119906;, &#119907; &#8712; &#119881; , and &#119905; is the timestamp for edge &#119890; where &#119905; &#8712; R. We use &#119905; (&#119890;) to denote the timestamp of a temporal edge &#119890;. Note that there could be multiple temporal edges on the same pair of nodes. We assume that all the timestamps in &#119879; are unique. This assumption leads to the clean definition of different types of temporal triangles ( Fig. <ref type="figure">2</ref>), but is not a necessity of our algorithm. To be more specific, our algorithm also works for temporal graph including temporal edges with equal timestamp.</p><p>We denote the underlying undirected static graph of &#119879; as &#119866; = (&#119881; , &#119864; &#119904; ) and put |&#119864; &#119904; | = &#119898; &#119904; . Two vertices in the static graph &#119866; are connected if there is at least one temporal edge between them. Formally,</p><p>As shown in Fig. <ref type="figure">2</ref>, there are eight different types of temporal triangles. The time restrictions &#120575; 1,3 , &#120575; 1,2 , and &#120575; 2,3 is not involved in definition of these types and could be applied to each of them. Note that these different types account for all possible ordering of temporal edges in the triangle in addition to their directions.</p><p>In a directed graph &#119866;, we use &#119873; + (&#119907;) : {(&#119907;, &#119906;) &#8712; &#119864; (&#119866;)} to denote the out-neighborhood and &#119873; -(&#119907;) : {(&#119906;, &#119907;) &#8712; &#119864; (&#119866;)}) to denote the in-neighborhood of a vertex &#119907;. For a vertex &#119907; &#8712; &#119881; (&#119866;), we define out-degree as</p><p>Vertex ordering is a central idea in triangle counting and motif analysis in general <ref type="bibr">[5,</ref><ref type="bibr">8,</ref><ref type="bibr">16,</ref><ref type="bibr">31,</ref><ref type="bibr">34,</ref><ref type="bibr">38,</ref><ref type="bibr">49]</ref>. Let &#119866; be an undirected static simple graph. Given any ordering &#8826; of &#119881; (&#119866;), we can construct a DAG &#119866; &#8826; by orienting each edge {&#119906;, &#119907; } &#8712; &#119864; (&#119866;) from &#119906; to &#119907; iff &#119906; &#8826; &#119907;. Next we define degeneracy and degeneracy ordering formally. Definition 3.1. The degeneracy of a graph &#119866;, denoted by &#120581;, is the smallest integer &#119896; such that there exists an ordering &#8826; of &#119881; (&#119866;) where &#119889; + &#119907; (&#119866; &#8826; ) &#8804; &#119896; for each &#119907; &#8712; &#119881; (&#119866;). Definition 3.2. Degeneracy ordering of an undirected simple static graph &#119866; is obtained by removing a vertex with minimum degree repeatedly. The order of the removal of vertices is the degeneracy ordering of &#119866;.</p><p>There is an algorithm for finding the degeneracy ordering of a graph &#119866; in &#119874; (|&#119864; (&#119866;)|) time <ref type="bibr">[28]</ref>. Let &#8826; denote the degeneracy ordering.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="4">MAIN IDEAS</head><p>Our algorithm first enumerates static triangles in &#119866;, the underlying static graph of the input temporal graph &#119879; . Let {&#119906;, &#119907;, &#119908; } be a static triangle. We consider all possible temporal orderings as shown in Fig. <ref type="figure">3</ref>, and all possible orientations as shown in Fig. <ref type="figure">4</ref>, for a temporal triangle corresponding to {&#119906;, &#119907;, &#119908; }. A temporal ordering and a temporal orientation together determine the type of the temporal triangle. For example &#120587; 1 and &#120588; 8 correspond to T 1 . Tab. 1 lists all possible pairs of temporal ordering and orientations and their corresponding type of temporal triangle as a function &#120595; .</p><p>We store the input temporal edges of the input temporal graph &#119879; in a data structure in the CSR format. Thus, we can assume that we have constant time access to temporal edges on each pair of vertices for each direction in the order of increasing timestamps. Let &#120587; denote the temporal ordering, and &#120588; denote the orientation for which we want to count the temporal triangles. In this section, from here we only consider temporal edges that follow the orientation &#120588;.</p><p>Assume that the timestamps of two of the edges of a temporal triangle corresponding to the static triangle {&#119906;, &#119907;, &#119908; } is given. WLOG, assume that these temporal edges correspond to {&#119906;, &#119907; } and {&#119906;, &#119908; }. We can use a binary search to find the number of temporal edges on the pair {&#119907;, &#119908; } that are compatible with the two given temporal edges. Note that compatibility of timestamps is determined by the timestamp of edges and the temporal ordering &#120587;. Thus, all we need is to enumerate all possible pairs of temporal edges on {&#119906;, &#119907; } and {&#119906;, &#119908; }. This could be an expensive enumeration if both these static edges have high multiplicity of temporal edges.</p><p>We show that we can obtain the counts of temporal triangles on {&#119906;, &#119907;, &#119908; } without enumeration of all possible pairs of temporal edges on {&#119906;, &#119907; } and {&#119906;, &#119908; }. Let &#119890; 1 , . . . , &#119890; &#120590; (&#120588; ( {&#119906;,&#119907; })) denote the sequence of temporal edges in the order of increasing timestamp on {&#119906;, &#119907; }, and &#119890; &#8242; 1 , . . . , &#119890; &#8242; &#120590; (&#120588; ( {&#119906;,&#119908; })) denote that of {&#119906;, &#119908; }. We enumerate each of these sequences of temporal edges separately, and for each edge we store cumulative counts of compatible temporal edge on {&#119907;, &#119908; }. In other words, for each edge &#119890; in these two sequence, we store the counts of edges &#119890; 3 on {&#119907;, &#119908; } that are compatible with &#119890; or any other temporal edge in the same sequence with a smaller timestamp.</p><p>Then we enumerate the temporal edges on {&#119906;, &#119907; }, and for each edge &#119890; &#119894; we use binary search to find the sequence of temporal edges &#119890; &#8242; &#119895; , . . . , &#119890; &#8242; &#119896; , in increasing order of timestamp, on {&#119907;, &#119908; } that are compatible with &#119890; &#119894; . We use the cumulative counts of compatible edges on {&#119907;, &#119908; } that we stored for &#119890; &#119894; , &#119890; &#8242; &#119896; , and &#119890; &#8242; &#119895; to compute the counts of all temporal triangles on {&#119906;, &#119907;, &#119908; } that include &#119890; &#119894; .</p><p>Although we avoid the enumeration of pairs of temporal edges on {&#119906;, &#119907; } and {&#119906;, &#119908; }, our algorithm could still be inefficient. The reason is that static edges {&#119906;, &#119907; } could have high multiplicity of temporal edges and also participate in a large number of static triangles. Here is where we use the power of vertex ordering and graph orientation techniques.</p><p>DOTTT enumerates static triangles in &#119866; &#8826; , and when processing a static triangle {&#119906;, &#119907;, &#119908; } where &#119906; comes first in the degeneracy ordering &#8826; of &#119866;, it only enumerates temporal edges on {&#119906;, &#119907; } and {&#119906;, &#119908; }. Thus, each temporal edge on a pair {&#119909;, &#119910;} where &#119909; &#8826; &#119910;, is processed only for static triangles where the third vertex is in the out-neighborhood of &#119909;. But we know that the out-degree of each vertex is bounded by &#120581; in &#119866; &#8826; . Therefore, each such temporal edge on {&#119909;, &#119910;} is processed &#119874; (&#120581;) times.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5">OUR MAIN ALGORITHM</head><p>In this section we describe our algorithm for getting (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )temporal triangles counts. Let &#119879; = (&#119881; , &#119864;) be the input directed temporal graph given as a list of temporal edges sorted by timestamps. Although not necessary for our algorithm, assuming that edges are given in increasing order of timestamp is common in temporal networks as the edges are recorded in their order of occurrence <ref type="bibr">[33]</ref>.</p><p>We first extract the static graph &#119866; (&#119881; , &#119864; &#119904; ) from &#119879; . Then, we obtain the degeneracy ordering of &#119866;, denoted by &#8826; using the algorithm by Matula and Beck <ref type="bibr">[28]</ref>, and orient the edges of &#119866; with respect to &#8826; Table <ref type="table">1</ref>: Conversion from temporal ordering and orientation to temporal triangle type.</p><p>to get the DAG &#119866; &#8826; . We start by enumerating static triangles in &#119866; &#8826; . This can be done in &#119874; (&#119898; &#119904; &#120581;) where &#120581; is the degeneracy of &#119866; <ref type="bibr">[8,</ref><ref type="bibr">38]</ref>. Note that all triangles in &#119866; &#8826; are acyclic as &#119866; &#8826; is a DAG, so each triangle in &#119866; correspond to an acyclic triangle in &#119866; &#8826; . In order to enumerate all triangles in &#119866;, we enumerate all directed edges in &#119866; &#8826; , and for each directed edge (&#119906;, &#119907;) we enumerate &#119873; + (&#119906;). For each vertex &#119908; &#8712; &#119873; + (&#119906;), we check whether {&#119906;, &#119907;, &#119908; } is a triangle by checking the existence of an edge between &#119907; and &#119908;.</p><p>We call vertex &#119906; in a static triangle {&#119906;, &#119907;, &#119908; } the source vertex if &#119906; &#8826; &#119907; and &#119906; &#8826; &#119908;. Let {&#119906;, &#119907;, &#119908; } be the triangle being processed while enumerating triangles in &#119866; &#8826; . WLOG, assume &#119906; is the source vertex in {&#119906;, &#119907;, &#119908; }. Thus, the number of times we visit {&#119906;, &#119907; } or {&#119906;, &#119908; } in a static triangle are limited by &#119889; + &#119866; &#8826; (&#119906;) that is bounded by &#120581;. But the number of times we visit the static edge {&#119907;, &#119908; } is not bounded by &#120581;, so we want to avoid enumerating temporal edges on {&#119907;, &#119908; }. Next, we show how to count the number of (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles corresponding to the static triangle {&#119906;, &#119907;, &#119908; }.</p><p>We define the temporal ordering of a temporal triangle corresponding to a static triangle {&#119906;, &#119907;, &#119908; } as a mapping &#120587; : {1, 2, 3} &#8594; {{&#119906;, &#119907; }, {&#119906;, &#119908; }, {&#119907;, &#119908; }}. There are six different possible temporal orderings as shown in Fig. <ref type="figure">3</ref>.</p><p>We define the orientation of a temporal triangle corresponding to a static triangle {&#119906;, &#119907;, &#119908; } as a mapping &#120588; from each pair of vertices of {&#119906;, &#119907;, &#119908; } to one of the two possible ordered pairs of the same pair of vertices. For example, &#120588; 1 ({&#119906;, &#119907; }) = (&#119906;, &#119907;) for &#120588; 1 in Fig. <ref type="figure">4</ref>. The orientation of a temporal triangle simply determines the direction of its temporal edges. Each such temporal edge can take two possible directions, so there are eight types of orientation such a temporal triangle can take as shown in Fig. <ref type="figure">4</ref>. Note that orientation of a temporal triangle is independent of its temporal ordering.</p><p>It is easy to see that the temporal ordering and orientation determine the type of the temporal triangle. But different combinations of temporal orderings and orientation could result in the same type. The temporal triangle type for all possible pairs of temporal ordering and orientation are shown in Tab. 1.</p><p>For a temporal ordering &#120587; and for &#119894; &#8712; {1, 2, 3}, we use &#119878; &#119894; (&#120587;, &#120588;) to denote the sequence of temporal edges between the pair of vertices &#120587; (&#119894;) that have the direction &#120588; (&#120587; (&#119894;)), in sorted order of timestamp. When &#120587; and &#120588; are clear from the context, we use &#119878; &#119894; instead of &#119878; &#119894; (&#120587;, &#120588;). We assume that we have access to &#119878; 1 , &#119878; 2 , and &#119878; 3 in constant time. Let &#120590; &#119894; denote the length of &#119878; &#119894; . We use &#119878; &#119894; [&#8467;] to denote the &#8467;-th edge in the sequence &#119878; &#119894; , and &#119878; &#119894; [&#8467; : &#8467; &#8242; ] to denote the consecutive subsequence of &#119878; &#119894; ranging from</p><p>For a sequence &#119878; of temporal edges in increasing order of tamp and timestamps &#119905; and &#119905; &#8242; where &#119905; &#8804; &#119905; &#8242; , let EC([&#119905;, &#119905; &#8242; ], &#119878;) denote the number of edges in &#119878; with a timestamp in the time window [&#119905;, &#119905; &#8242; ]. For given &#120575; 1,3 , &#120575; 1,2 , and &#120575; 2,3 , let TTC({&#119906;, &#119907;, &#119908; }, &#120587;, &#120588;) denote the number of (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles corresponding to the static triangle {&#119906;, &#119907;, &#119908; }, temporal ordering &#120587;, and orientation &#120588;. Lemma 5.1. For a static triangle {&#119906;, &#119907;, &#119908; }, a temporal ordering &#120587;, and an orientation &#120588;,</p><p>For a triangle {&#119906;, &#119907;, &#119908; } where &#119906; is the source vertex, we divide all six possible temporal orderings into three categories based on the place of {&#119907;, &#119908; } in them. Recall that we want to avoid enumerating temporal edges on {&#119907;, &#119908; }. In &#120587; 1 and &#120587; 2 , {&#119907;, &#119908; } is assigned to the third place. {&#119907;, &#119908; } is assigned to the second place in &#120587; 3 and &#120587; 4 , and finally to the first place in temporal ordering &#120587; 5 and &#120587; 6 .</p><p>Temporal orderings &#120587; 1 and &#120587; 2 : Using Lemma 5.1, one can compute TTC({&#119906;, &#119907;, &#119908; }, &#120587;, &#120588;) by enumerating pairs of temporal edges in</p><p>For each pair we compute EC([&#119905; (&#119890; 2 ), min(&#119905; (&#119890; 2 ) + &#120575; 2,3 , &#119905; (&#119890; 1 ) + &#120575; 1,3 ), &#119878; 3 ) using binary search. To get the final counts we sum EC([&#119905; (&#119890; 2 ), min(&#119905; (&#119890; 2 ) + &#120575; 2,3 , &#119905; (&#119890; 1 ) + &#120575; 1,3 ), &#119878; 3 ) over all pairs (&#119890; 1 , &#119890; 2 ) &#8712; &#119878; 1 &#215; &#119878; 2 . But enumerating &#119878; 1 &#215; &#119878; 2 could be expensive and this process overall runs in time &#119874; (&#120590; 1 &#120590; 2 log(&#120590; 3 )). Next, we show that we can compute the same count by enumerating edges in &#119878; 1 and &#119878; 2 separately and storing cumulative counts of compatible edges on &#119878; 3 for each edge.</p><p>For &#119894;, &#119895; &#8712; {1, 2, 3} where &#119894; &#8800; &#119895;, and &#8467;, &#8467; &#8242; &#8712; {1, . . . , &#120590; &#119894; } where &#8467; &#8804; &#8467; &#8242; we use</p><p>Cumulative counts CEC &#8734; , CEC -&#120575; 1,3 , and CEC -&#8734; , are defined the same way with time intervals [&#119905; (&#119890;), &#8734;), [&#119905; (&#119890;) -&#120575; 1,3 , &#119905; (&#119890;)], and (-&#8734;, &#119905; (&#119890;)], respectively. CEC -&#120575; 1,2 , CEC +&#120575; 1,2 , CEC -&#120575; 2,3 , and CEC +&#120575; 2,3 are defined similarly. Note that we can compute CEC(&#119878; &#119894; [1 : &#8467;], &#119878; &#119895; ) for each &#8467; &#8712; {1, . . . , &#120590; &#119894; } with one pass over &#119878; &#119894; , and once we have these counts, we can get the cumulative counts CEC(&#119878; &#119894; [&#8467; &#8242; : &#8467; &#8242;&#8242; ], &#119878; &#119895; ), for each consecutive subsequence &#119878; &#119894; [&#8467; &#8242; : &#8467; &#8242;&#8242; ] of &#119878; &#119894; as follows.</p><p>where</p><p>We first enumerate edges in &#119878; 1 . For each edge &#119890; 1 &#8712; &#119878; 1 we compute CEC +&#120575; 1,3 (&#119878; 1 [1 : &#8467;], &#119878; 3 ) and CEC &#8734; (&#119878; 1 [1 : &#8467;], &#119878; 3 ) for each &#8467; &#8712; {1, . . . , &#120590; 1 } and store them for &#119890; 1 . Next, we enumerate edges in &#119878; 2 and compute CEC &#8734; (&#119878; 2 [1 : &#8467;], &#119878; 3 ) for each &#8467; &#8712; {1, . . . , &#120590; 2 }.</p><p>Fix an edge &#119890; 2 &#8712; &#119878; 2 . Let &#8467; &#119891; and &#8467; &#8467; be the indices of the first and last edges in &#119878; 1 with a timestamp in [&#119905; (&#119890; 2 ) -&#120575; 1,2 , &#119905; (&#119890; 2 )]. Also let &#8467; &#120575; 2,3 be the index of the last edge in &#119878; 1 with a timestamp at most &#119905; (&#119890; 2 ) -&#120575; 1,3 + &#120575; 2,3 . We can find &#8467; &#119891; , &#8467; &#120575; 2,3 , and &#8467; &#8467; using a binary search on &#119878; 1 . Note that</p><p>First consider the temporal edges &#119878; 1 [&#119894;] where &#8467; &#119891; &#8804; &#119894; &#8804; &#8467; &#120575; 2,3 . For any such edge &#119905; (&#119878;</p><p>Having stored the cumulative counts described above, we can compute the number of pairs of temporal edges</p><p>)-temporal triangle on {&#119906;, &#119907;, &#119908; } with &#119890; 2 , complying with &#120587; 1 and &#120588;, as follows.</p><p>Now, we count the number of temporal edges in &#119878; 3 that compose a triangle with &#119890; 2 and &#119878; 1 <ref type="bibr">[&#119894;]</ref>, where &#8467; &#120575; 2,3 &lt; &#119894; &#8804; &#8467; &#8467; . For a temporal edge &#119878; 1 [&#119894;] where &#8467; &#120575; 2,3 &lt; &#119894; &#8804; &#8467; &#8467; , we have &#119905; (&#119878; 1 [&#119894;])+&#120575; 1,3 &gt; &#119905; (&#119890; 2 )+&#120575; 2,3 . Thus, there are EC([&#119905; (&#119890; 2 ), &#119905; (&#119890; 2 ) + &#120575; 2,3 ], &#119878; 3 ) edges on &#119878; 3 that compose a triangle with &#119890; 2 and &#119878; 1 <ref type="bibr">[&#119894;]</ref>. So the final count of pairs (&#119890; 1 , &#119890; 3 ) &#8712; &#119878; 1 &#215;&#119878; 3 that are in a temporal triangle with &#119890; 2 corresponding to the static triangle {&#119906;, &#119907;, &#119908; } can be computed as follows.</p><p>By Lemma 5.1, to get TTC({&#119906;, &#119907;, &#119908; }, &#120587;, &#120588;), we only need to sum these counts over edges in &#119878; 2 . Let &#10216;&#119906;, &#119907;, &#119908;&#10217; denote a static triangle where &#119906; &#8826; &#119907; &#8826; &#119908;. Alg. 1 formalizes the procedure described above for computing TTC(&#10216;&#119906;, &#119907;, &#119908;&#10217;, &#120587;, &#120588;) where &#120587; is either &#120587; 1 or &#120587; 2 .</p><p>Algorithm 1 Counting (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles corresponding to a static triangle and temporal orientation &#120587; 1 or &#120587; 2</p><p>Enumerate &#119878; 1 and compute CEC +&#120575; 1,3 and CEC &#8734; on &#119878; 3 .</p><p>3: count = 0 4:</p><p>for &#119894; = 1, . . . , &#120590;</p><p>Let</p><p>Let</p><p>Let</p><p>return count</p><p>The algorithms for the category of &#120587; 3 and &#120587; 4 and the category of &#120587; 5 and &#120587; 6 are similar to Alg. 1, so we defer these to Appendix A. Here, we suffice to say that similar to Alg. 1, in algorithms for the remaining temporal orderings, for each static triangle {&#119906;, &#119907;, &#119908; } where &#119906; is the source vertex, we only enumerate temporal edges on {&#119906;, &#119907; } and {&#119906;, &#119908; }. And for each temporal edge we perform a constant number of binary searches on temporal edges on the other two static edges of the static triangle {&#119906;, &#119907;, &#119908; }.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="5.1">Getting the Counts for All Temporal</head><p>Triangle Types</p><p>Now that we can count (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles for each combination of temporal ordering and orientation, it only remains to get the counts for each temporal triangle type ( Fig. <ref type="figure">2</ref>). Let &#120595; (&#120587;, &#120588;) denote the triangle type for &#120587; and &#120588;. Alg. 2 gets the counts for all eight types. Now, we can finally prove Theorem 1.2.</p><p>Proof of Theorem 1.2. Extracting the static graph &#119866; from &#119879; can be done in &#119874; (&#119898;) time. We simply enumerate all temporal edges Algorithm 2 Counting (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles for each temporal triangle types</p><p>Extract the static graph &#119866; of &#119879; .</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>3:</head><p>Find the degeneracy ordering &#8826; of &#119866;.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>4:</head><p>Derive &#119866; &#8826; by orienting &#119866; with respect to &#8826;. for all Temporal ordering &#120587; and orientation &#120588; do</p><p>Counts(&#120595; (&#120587;, &#120588;)) += TTC(&#10216;&#119906;, &#119907;, &#119908;&#10217;, &#120587;, &#120588;) &#8882; Tab. 1 &#8882; Using Alg. 1, Alg. 3, and Alg. 4 of &#119879; and for each temporal edge &#119890; = (&#119907; 1 , &#119907; 2 , &#119905;), we add an static edge between {&#119907; 1 , &#119907; 2 } in &#119866; if they are not connected already. The degeneracy ordering of &#119866; could be obtained in &#119874; (&#119898; &#119904; ) time <ref type="bibr">[28]</ref>, and &#119866; &#8826; could also be derived in time &#119874; (&#119898; &#119904; ). For enumerating static triangles we first enumerate each edge in &#119866; &#8826; . For each edge (&#119906;, &#119907;), we enumerate &#119873; + (&#119906;) which takes &#119874; (&#120581;) as &#119889; + &#119866; &#8826; (&#119906;) &#8804; &#120581;. We can lookup if there is an edge between &#119907; and &#119908; in constant time. Thus, enumerating triangles take &#119874; (&#119898; &#119904; &#8226; &#120581;) time overall.</p><p>Note that for each static triangle we only enumerate temporal edges on static edges incident to the source vertex. So for the static triangle &#10216;&#119906;, &#119907;, &#119908;&#10217;, we only enumerate temporal edges on the pairs {&#119906;, &#119907; } and {&#119906;, &#119908; }. While processing a temporal edge during enumeration of temporal edges on {&#119906;, &#119907; } or {&#119906;, &#119908; }, we either perform a constant time operation, or spend &#119874; (log(&#120590; max )) time for a constant number of binary searches over the temporal edges of the other two static edges in the static triangle &#10216;&#119906;, &#119907;, &#119908;&#10217;. Thus, &#119879; (A) = &#119874; (&#119898; &#119904; &#8226; &#120581; + &#10216;&#119906;,&#119907;,&#119908; &#10217; (&#120590; (&#119906;, &#119907;) + &#120590; (&#119906;, &#119908;)) log(&#120590; max ))</p><p>where A denotes Alg. 2, and &#119879; (A) denotes the worst case time complexity of A.</p><p>For each vertex &#119906; &#8712; &#119881; , &#119889; + &#119866; &#8826; (&#119906;) &#8804; &#120581;, so each edge (&#119906;, &#119907;) in &#119866; &#8826; , is a part of at most &#120581; static triangles where &#119906; is the source vertex. Therefore, the temporal edges on each edge {&#119906;, &#119907; } in &#119866; are enumerated at most &#119874; (&#120581;) times. Thus,</p><p>Hence,</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head n="6">EXPERIMENTAL EVALUATIONS</head><p>We implemented our algorithm in C++ and used a commodity machine from AWS EC2: R5d.2xlarge to run our experiments. This EC2 instance has Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz and 64GB memory. On this AWS machine, PBL runs out of memory for the Bitcoin graph, so we used one with more than 256GB memory for this case. The implementation of DOTTT is available at <ref type="bibr">[1]</ref>. We performed our experiments on a collection of temporal graphs from SNAP <ref type="bibr">[23]</ref>, KONECT <ref type="bibr">[21]</ref>, and the Bitcoin transaction dataset from <ref type="bibr">[19]</ref>, consisting of all transactions up to Feb 9,  We fix &#120575; 1,3 to 2 hrs. We vary &#120575; 1,2 from 0 to 60 minutes and plot the ratio of (2 hrs, &#120575; 1,2 , &#120575; 2,3 )-temporal triangles to (2hrs, &#120575; 1,2 , 1hr)-temporal triangles for &#120575; 2,3 ranging from 0 to 60 minutes. (c) We plot the ratio of (2 hrs, 1 hr, &#120575; 2,3 )-temporal triangles to (2hrs, 1hr, 1hr)-temporal triangles for &#120575; 2,3 ranging from 0 to 60 minutes, for cyclic and acyclic triangles.</p><p>2018. The timestamp of each transaction is the creation time of the block on the blockchain that contains it <ref type="bibr">[40]</ref>.</p><p>Running time: All the running times are shown in Tab. 2. We ran all experiments on a single thread. In most instances, DOTTT takes a few seconds to run. For graphs with tens of millions of temporal edges, DOTTT runs in less than ten minutes. Even for the Bitcoin graph with 515M edges, DOTTT takes less than an hour.</p><p>Running time independent of time periods: The running time of both DOTTT and PBL algorithms are independent of the time periods. DOTTT has the same running time for time restrictions ranging from 0 to the time span of the input dataset. For comparison with &#119875;&#119861;&#119871;, we set &#120575; 1,3 = &#120575; 1,2 = &#120575; 2,3 = 1 hr.</p><p>Comparison with PBL : We compare our algorithm with the PBL algorithm that counts &#120575; 1,3 -temporal triangles, as it is the closest to our work. We typically get a 1.5x-2x speedup over PBL for large graphs (more than 0.5M edges) as shown in Fig. <ref type="figure">1a</ref>. Note that DOTTT computes (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangle counts while PBL only gets the counts of &#120575; 1,3 -temporal triangles.</p><p>Distribution of counts over types of triangles: The distribution of (1 hr, 1 hr, 1 hr)-temporal triangle counts for our datasets are shown in Fig. <ref type="figure">5a</ref>. As we expected <ref type="bibr">[29,</ref><ref type="bibr">33,</ref><ref type="bibr">51,</ref><ref type="bibr">57]</ref>, networks from similar domains have similar distributions. It is easy to see in Fig. <ref type="figure">5a</ref>, that all the stack exchange networks have similar distributions. The same holds for the message networks CollegeMsg and SMS-A.</p><p>We observe that cyclic temporal triangles, T 4 and T 8 , have a larger share in temporal triangle counts in messaging networks than in stack exchange networks.</p><p>Triadic closures in temporal networks: In static triangles, the transitivity measures the ratio of number of static triangles to the number of all wedges. In temporal graphs, in addition to transitivity, the time it takes for a wedge to appear and close is of importance <ref type="bibr">[58]</ref>. In Fig. <ref type="figure">5b</ref>, we study the effect of the time it takes for a wedge to appear from an edge, on the time it takes to close for CollegeMsg graph. We fix &#120575; 1,3 = 2 hrs. For &#120575; 1,2 ranging from zero to 60 minutes (10 minute steps), we vary &#120575; 2,3 from zero to 60 minutes and plot the ratio of (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles over (2hrs, &#120575; 1,2 , 1hr)-temporal triangles. We observe that the set of ratios for all values of &#120575; 2,3 are almost identical for different values of &#120575; 1,2 . For instance, for all values of &#120575; 1,2 , roughly half the triangles are formed in 10-20 minutes. This implies that once a wedge is formed, the time it took to appear does not affect the time it takes to close.</p><p>As another demonstration of DOTTT, for &#120575; 1,3 = 2 hrs and &#120575; 1,2 = 1 hrs, we plot the ratio of (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )-temporal triangles to (2hrs, 1hr, 1hr)-temporal triangles, this time separately for cyclic and acyclic temporal triangles in Fig. <ref type="figure">5c</ref>. We observe that for stack exchange networks, acyclic temporal triangles tend to take a shorter time to close from the moment their second edge appears than cyclic temporal triangles. As we see in Fig. <ref type="figure">5c</ref>, this is not the case for message networks.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>A MISSING ALGORITHMS FROM SECTION 5</head><p>Here we will provide the algorithms for counting (&#120575; 1,3 , &#120575; 1,2 , &#120575; 2,3 )temporal triangles for temporal orderings &#120587; 3 , &#120587; 4 , &#120587; 5 , and &#120587; 6 .</p><p>Temporal orderings &#120587; 3 and &#120587; 4 : Consider an orientation &#120588;, and a static triangle on vertices {&#119906;, &#119907;, &#119908; } enumerated in &#119866; &#8826; , where &#119906; is the source vertex. The category of temporal orderings &#120587; 3 and &#120587; 4 is more intricate because &#120587; 3 ({&#119907;, &#119908; }) = &#120587; 4 ({&#119907;, &#119908; }) = 2. Recall that we want to avoid enumerating temporal edges on {&#119907;, &#119908; }, so we do not enumerate edges on &#119878; 2 as in the case of &#120587; 1 and &#120587; 2 . Instead, we enumerate edges on &#119878; 1 , and compute the counts of edges on &#119878; 2 that form a temporal triangle with compatible edge in &#119878; 3 .</p><p>We start by enumerating edges on &#119878; 1 . Consider an edge &#119890; 1 &#8712; &#119878; 1 . Let &#8467; &#119891; and &#8467; &#8467; denote the indices of first and last edge in &#119878; 3 with a timestamp in [&#119905; (&#119890; 1 ), &#119905; (&#119890; 1 ) + &#120575; 1,3 ]. Also, let &#8467; &#120575; 1,2 denote the index of the first edge in &#119878; 3 with a timestamp greater than &#119905; (&#119890; 1 ) + &#120575; 1,2 , and &#8467; &#120575; 2,3 be the index of the first edge in &#119878; 3 that has a timestamp greater than &#119905; (&#119890; 1 ) + &#120575; 2,3 . Note that &#8467; &#120575; 1,2 and &#8467; &#120575; 2,3 divide &#119878; 3 [&#8467; : &#8467; &#8467; ] into three consecutive subsequences. We show how to count temporal triangles that involve temporal edges in each of these three subsequences.</p><p>For a temporal edge &#119878;  Temporal orderings &#120587; 5 and &#120587; 6 : This case is similar to the case of temporal ordering &#120587; 1 and &#120587; 2 . The difference is that while enumerating edges in &#119878; 2 , we will first find the compatible edges in &#119878; 3 instead of &#119878; 1 , and then count edges in &#119878; 1 that complete a temporal triangle. Consider a static triangle {&#119906;, &#119907;, &#119908; } and orientation &#120588;. return count</p></div></body>
		</text>
</TEI>
