Classes implemented on top of ABC

In this section we will examine some implementations that are based on top of ABCs.

A static Graph

Given a nodeset and a linkset one can define, an elementary Graph, g as the one found in classic graph theory. This graph consists of a g.nodeset and a g.linkset (as these attributes return copies, if you don’t want a copy of the data add a “_” to the end), the last of which can be optionally be weighted . The number of nodes of the Graph, can be accessed through g.n, where the number of edges of the Graph, can be accessed through g.m (g.wm gives access to the weighted number of edges). The classic density of a graph, can be refered in this context as coverage. As so by accessing the attributes g.total_coverage and g.weighted_total_coverage the user can calculate the ratios \(\frac{m}{n^{2}}\) and \(\frac{\sum_{uv}w_{uv}}{n^{2}}\). Moreover neighbor-density per-node can be calculated as g.neighbor_coverage, having again the option of calculating it for each node as a NodeCollection, if a node is ommited, as well as a direction for 'in', 'out' or 'both' and an argument for weights. Finally in order to be possible to apply more complicated functions on the graph, you can convert it to a networkx graph by executing: g.to_networkx.

The Stream Graph

The most import class of the package, whose standard and only implementation relies only on ABCs, is that of the StreamGraph. This class is meant to properly implement a Stream Graph as defined in the introduction, as a collection of a node-set, a time-set, a temporal-node-set and a temporal-link-set.

The stream-graph: sg is characterized by two attributes sg.n and sg.m as in normal graph theory, standing for the total-number of nodes and the total-number of edges, defined as the duration of all nodes inside the temporal-node-set divided by the duration of the timeset and by the duration of all links inside the temporal-link-set divided by the duration of the timeset, respectively. All methods that were defined on a single ABC, can be accessed through the attributes: sg.nodeset, sg.timeset, sg.temporal_nodeset, sg.temporal_linkset (as these attributes return copies, if you don’t want a copy of the data add a “_” to the end).

Moreover measures that combine information of different ABCs are those of coverage. When calculating sg.temporal_nodeset_coverage, we calculate what percentage the temporal-node-set duration covers total possible duration this set would have if all the nodes existed for all the time defined from the time-set: \(\frac{|W|}{|V\times T|}\). Similarly the sg.temporal_linkset_coverage evaluates the total-duration the links exist, compared to the duration that the nodes that constitute these links exist, as \(\frac{|E|}{\sum_{uv \in V\times V}|T_{u} \cap T_{v}|}\) (sg.weighted_temporal_linkset_coverage stands for the weighted case). Following the same logic, we can calculate the sg.time_coverage_node of a certain node (or the NodeCollection of it for all the nodes inside the nodeset) as ratio of its duration to the duration of the time-set: \(\frac{|T_{u}|}{|T|}\), as well as the sg.time_coverage_link of a certain link (or the LinkCollection of it for all the links inside the nodeset) as a ratio of its duration to the duration that both of it’s two consisting exist at the same time, inside the temporal-node-set: \(\frac{|T_{uv}|}{|T_{u} \cap T_{v}|}\). Also by calculating sg.neighbor_coverage, we can calculate the ratio of the duration of all temporal-neighbors of a node, to all the possible neighbor duration of this node, as defined by calculating the amount of the time co-occurance of this node and all the others inside the temporal-node-set, formalized as \(\frac{|N(u)|}{\sum_{v\in V}|T_{u}\cap T_{v}|}\) (a generalization of neighbor-desnity in classical graphs).

At any point in time the stream-graph can be represented by what is a called a snapshot graph. To access this graph, or to trace it throughout time what you can do is call the method sg.graph_at. Next a notion of coverage of the graph time-stamp at a certain point in time (or throughout time as a TimeCollection), can be calculated as sg.node_coverage_at, ls.link_coverage_at, as well as sg.neighbor_coverage_at, as well as its sg.mean_degree_at, which is stands for the number of links of the snapshot graph divided by the number of neighbors \(\frac{|E_{t}|}{|V_{t}|}\). Any of the above methods that is related with links, accepts a weights argument, for calculating a weighted result (for the nominator).

The binary operators of &, |, - as well as the issuperset are defined here as the collective result of all of these operators on the lower objects. Additionaly the method induced_substream of the temporal-link-set is advanced as a method of the stream-graph, by applying an intersection, to the temporal-node-set also. Similarly we can discretize the whole stream-graph, through the method sg.descritize. To conclude, a stream-graph can be also constructed through a temporal-link-set ls, through the methods ls.as_stream_graph_basic and ls.as_stream_graph_minimal according to the type of the temporal-node-set derived from the temporal-link-set.

TemporalNodeSetB

This mixed class can combine a time-set ABC and a node-set ABC, to define a TemporalNodeSetB. By doing so, it is implied that all the nodes inside the node-set exist for all the time of the time-set (accessed as tns.nodeset_, tns.timeset_). By building this class on top of that assumption, most of methods defined on a general ABC, can be simplified. Finally by iterating on this object, all the possible pairs are produced an idea which should be avoid, except if needed.