yawning_titan.networks.network_creator#
Network Creator module enables the creation of pre-defined types of networks.
Networks that can be created are:
The standard 18-node network from the Ridley 2017 paper.
The DCBO network used in the RL Baseline module.
A mesh network.
A star network.
A ring network.
A P2P network.
A randomly generated binominal network.
A custom network using user-input options.
Functions
Check if a randomly generated point is close to points already generated. |
|
Create a mesh node environment. |
|
Create a two group network. |
|
Create a ring network. |
|
Create a star node environment. |
|
Create custom network through user interaction. |
|
Creates the same network used to generated DCBO data. |
|
Generate a random position for each node and saves it as a dictionary. |
|
The standard 18 node network found in the Ridley 2017 research paper. |
|
Get nodes and edges from a numpy matrix and a dictionary of positions. |
|
Create a randomly connected graph. |
- yawning_titan.networks.network_creator.check_if_nearby(pos, full_list, value)[source]#
Check if a randomly generated point is close to points already generated.
- Parameters:
pos – The x,y position as a list.
full_list – The full list of positions.
value – The separation value.
- Returns:
True if nearby, otherwise False.
- yawning_titan.networks.network_creator.generate_node_positions(matrix)[source]#
Generate a random position for each node and saves it as a dictionary.
- Parameters:
matrix – The adjacency matrix for the network.
- Returns:
A dictionary of node positions.
- yawning_titan.networks.network_creator.get_network_from_matrix_and_positions(matrix, positions)[source]#
Get nodes and edges from a numpy matrix and a dictionary of positions.
- Parameters:
matrix – A 2D numpy array adjacency matrix.
positions – The node positions on a graph.
- Returns:
An instance of
Network
.
- yawning_titan.networks.network_creator.get_18_node_network_mesh()[source]#
The standard 18 node network found in the Ridley 2017 research paper.
- Returns:
An instance of
Network
.
- yawning_titan.networks.network_creator.dcbo_base_network()[source]#
Creates the same network used to generated DCBO data.
- Returns:
An instance of
Network
.
New in version 1.0.1.
- yawning_titan.networks.network_creator.create_mesh(size=100, connectivity=0.7)[source]#
Create a mesh node environment.
- Parameters:
size – The number of nodes in the environment.
connectivity – How connected each of the nodes should be (percentage chance for any node to be connected to any other).
- Returns:
An instance of
Network
.
- yawning_titan.networks.network_creator.create_star(first_layer_size=8, group_size=5, group_connectivity=0.5)[source]#
Create a star node environment.
This is one node in the middle with groups of nodes around it. There is only one connection between a group and the center node. Groups cannot connect to each other.
- Parameters:
first_layer_size – The number of collections of nodes in first “outer ring”.
group_size – How many nodes are in each collection.
group_connectivity – How connected the nodes in the connections are.
- Returns:
An instance of
Network
.
- yawning_titan.networks.network_creator.create_p2p(group_size=5, inter_group_connectivity=0.1, group_connectivity=1)[source]#
Create a two group network.
You can modify the connectivity between the two groups and the connectivity within the groups.
- Parameters:
group_size – The amount of nodes in each group (before random variance).
inter_group_connectivity – The connectivity between the two groups.
group_connectivity – The connectivity within the group.
- Returns:
An instance of
Network
.
- yawning_titan.networks.network_creator.create_ring(break_probability=0.3, ring_size=60)[source]#
Create a ring network.
- Parameters:
break_probability – The probability that two nodes will not be
connected.
- Parameters:
ring_size – The number of nodes in the network.
- Returns:
An instance of
Network
.
- yawning_titan.networks.network_creator.custom_network()[source]#
Create custom network through user interaction.
- Returns:
An instance of
Network
.
- yawning_titan.networks.network_creator.gnp_random_connected_graph(n_nodes, probability_of_edge)[source]#
Create a randomly connected graph.
With the guarantee that each node will have at least one connection.
This is taken from the following stack overflow Q&A with a bit of a refactor for clarity.
- Parameters:
n_nodes – the number of nodes in the graph.
probability_of_edge – the probability for a node to have an edge.
- Returns:
An instance of
Network
.