Dynamic Communities Classes¶
For each representation of dynamic graphs, there is a corresponding representation of dynamic partitions:
- DynGraphSN == DynCommunitiesSN (snapshots)
- DynGraphIG == DynCommunitiesIG (interval graphs)
Dynamic communities are (currently) identified by labels, i.e. each community is associated with a unique label, and two nodes that have the same labels (in the same or in different time steps) belongs to the same (dynamic) community.
Sequences of snapshots representations¶
-
class
tnetwork.
DynCommunitiesSN
(snapshots=None)[source]¶ Dynamic communities as sequences of snapshots
Communities are represented as a SortedDict, key:time, value: dict id:{set of nodes}
Adding and removing affiliations¶
DynCommunitiesSN.add_affiliation (nodes, …) |
Affiliate node(s) to community(ies) at time(s) |
DynCommunitiesSN.add_community (t, nodes[, id]) |
Add a community at a time |
DynCommunitiesSN.set_communities (t[, …]) |
Affiliate nodes given a dictionary representation |
Accessing affiliations¶
DynCommunitiesSN.affiliations ([t]) |
Affiliations by nodes |
DynCommunitiesSN.communities ([t]) |
Communities |
DynCommunitiesSN.snapshot_affiliations ([t]) |
Affiliations by snapshots |
DynCommunitiesSN.snapshot_communities ([t]) |
Affiliations by communities |
Statistics/Other¶
DynCommunitiesSN.communities_duration () |
Duration of each community |
DynCommunitiesSN.affiliations_durations ([…]) |
Duration of affiliations |
DynCommunitiesSN.snapshots_timesteps () |
Return the list of time steps |
DynCommunitiesSN.automatic_node_order () |
Return an order of nodes optimized for longitudinal plotting |
Converting¶
DynCommunitiesSN.to_DynCommunitiesIG (sn_duration) |
Convert to SG communities |
Interval graph representations¶
-
class
tnetwork.
DynCommunitiesIG
(start=None, end=None)[source]¶ Dynamic communities as interval graphs
This class maintains a redondant representation for faster access:
- _by_node: for each node, for each community, Interval of affectation (affectations)
- _by_com: for each com, for each node, Interval of affectation (communities)
Note that they are hidden for this reason, if you modify one, you need to be careful maintaining the other one. You can however access them without problem directly, or use the corresponding functions (affiliation and communities)
Adding and removing snapshot_affiliations¶
DynCommunitiesIG.add_affiliation (nodes, …) |
Affiliate node n to community com for period times |
DynCommunitiesIG.add_affiliations_from (…) |
Add communities provided as a cluster |
DynCommunitiesIG.remove_affiliation (n, com, …) |
Remove affiliations |
Accessing snapshot_affiliations¶
DynCommunitiesIG.affiliations ([t]) |
Affiliations by nodes |
DynCommunitiesIG.communities ([t]) |
Affiliations by communities |
DynCommunitiesIG.affiliations_durations ([…]) |
Durations of affiliations |
Other functions¶
DynCommunitiesIG.nodes_main_com () |
Main community for each node |
DynCommunitiesIG.nodes_natural_order () |
Nodes by lexicographic order |
DynCommunitiesIG.nodes_ordered_by_com ([node2com]) |
Nodes ordered by their main community |