nodes_generator
This module generates members and assign them to punctual communities.
- class CommunityMember(id_, coreness=0, intermittence=0)
Bases:
MemberClass representing a community member.
- Parameters:
id –
coreness (float) – tendancy of the member to join already visited communities
intermittence (float) – tendency of the member to stay out of the network
- Attr id:
- property evolving_communities: Dict[int, EvolvingCommunity]
Return evolving communities which member is part of.
- Return type:
Dict[int,EvolvingCommunity]- Returns:
evolving communities as a dictionary with snapshots as keys
- property snapshots: List[int]
Return snapshots where member is present.
- Return type:
List[int]- Returns:
- class NodeMembership
Bases:
MembershipThis class gathers evolving and static communities along their members and ensures their coherency.
It uses
CommunityMemberas the class for its members.- Attr evolving_communities:
evolving communities with ids as keys
- Attr static_communities:
static communities with ids as keys
- Attr members:
members with ids as keys
Warning
This class ensures coherency of data as long as you only modify them through its methods!
- add_evolving_community(evolving_community_id)
Create and add evolving community by id if not present.
- Parameters:
evolving_community_id –
- Return type:
EvolvingCommunity- Returns:
evolving community with given id
- add_member(member_id)
Create and add member by id if not present.
- Parameters:
member_id –
- Return type:
- Returns:
member with given id
- add_static_community(static_community_id, snapshot)
Create and add static community by id if not present.
- Parameters:
static_community_id –
- Return type:
StaticCommunity- Returns:
static community with given id
- attach_member(member_id, static_community_id)
Attach static community to evolving community.
- Parameters:
member_id –
static_community_id –
- Raises:
IndexError –
If member_id member doesn’t exist
If static_community_id static community doesn’t exist
ValueError – If member is already in an other community at same snapshot
- attach_static_community(static_community_id, evolving_community_id)
Attach static community to evolving community.
- Parameters:
static_community_id –
evolving_community_id –
- Raises:
IndexError –
If static_community_id static community doesn’t exist
If evolving_community_id static community doesn’t exist
ValueError – If evolving community already exists at same snapshot
- commlist(snapshot)
Return commlist representing data at given snapshot.
- Parameters:
snapshot (
int) –- Return type:
- Returns:
- property community_graph: EvolvingCommunitiesGraph
Return community flow graph representing data.
- Return type:
- Returns:
- detach_member(member_id, snapshot)
Detach member from its static community at given snapshot (by id).
- Parameters:
member_id –
snapshot (
int) –
- Raises:
IndexError – If member_id member doesn’t exist
- detach_static_community(static_community_id)
Detach static community from its evolving community (by id).
- Parameters:
static_community_id –
- Raises:
IndexError – If static_community_id static community doesn’t exist
- classmethod from_community_graph(graph)
Create membership object from community flow graph.
As community flow graph is not as complete, only evolving and static communities are added (no members).
- Parameters:
graph (
EvolvingCommunitiesGraph) –- Return type:
- Returns:
membership object
- classmethod from_tcommlist(tcommlist_)
Create membership object from tcommlist.
- Parameters:
tcommlist –
- Return type:
- Returns:
membership object
- property snapshots: List[int]
Return all existing snapshots.
- Return type:
List[int]- Returns:
- class RandomMemberGenerator(seed=None)
Bases:
IGeneratorThis class generate random members following a provided community flow graph.
- Parameters:
seed (
Optional[Any]) –- Attr community_graph:
latest community flow graph provided
- Attr membership:
latest community membership object built by generator
- configure_seed(seed)
Set :attr`seed` and :attr`rng`.
- Parameters:
seed (
Any) –- Returns:
instance generator
Note
necessary to easily override it while being able to call it
- copy()
Return a copy of generator.
- Return type:
Self- Returns:
- create_member()
Create one member
- Return type:
- create_tcommlist_rows_generator(community_graph=None)
Return membership as tcommlist rows generator.
- Parameters:
community_graph (
Optional[EvolvingCommunitiesGraph]) –- Return type:
GeneratorLen[TcommlistRow]- Returns:
- generate(community_graph=None)
Generate clusters of members corresponding to community_graph attribute.
- Parameters:
community_graph (
Optional[EvolvingCommunitiesGraph]) – if not provided, will use last one provided- Return type:
- Returns:
generated tcommlist
- property rng: Generator
Random number generator of the generator
- Return type:
Generator
- property seed: SeedSequence
Seed of the generator
- Return type:
SeedSequence
- spawn(n_children=1)
Spawn a copy of the generated with a child seed.
- Return type:
Union[Sequence[Self],Self]- Returns:
new generator
- write_commlist(directory)
Write the benchmark to commlist files, one per snapshot.
There are one commlist file per timestep, with the following filename format: directory/timestep.commlist
- Parameters:
directory (str) –
- write_tcommlist(filename)
Write the benchmark to a tcommlist file.
- Parameters:
filename (str) –