yawning_titan.envs.specific.core.nsa_node_collection.NodeCollection#
- class yawning_titan.envs.specific.core.nsa_node_collection.NodeCollection(network, chance_to_spread_during_patch)[source]#
Bases:
object
Class representing a collection of nodes for the 18-node Ridley Environment.
Methods
Calculate a reward for the current network state.
Create a list of all the nodes in the network that are compromised.
When given a node returns a list of all of the nodes connected to that node.
Create a list of all the isolated nodes in the network.
Get the underlying networkx graph.
Get graph positions.
Get the number of isolated nodes in the network.
Return the number of nodes in the network.
Get the number of safe nodes in the network.
Get the states of all the nodes in the network.
Create a list of all the safe nodes in the network.
Change the state of a single node.
Spread the red agent through all connected nodes.
- get_number_of_nodes()[source]#
Return the number of nodes in the network.
- Returns:
The number of nodes in the network (int)
- get_observation()[source]#
Get the states of all the nodes in the network.
- Returns:
The current state of the environment (numpy array)
- Return type:
observation
- modify_node(number, changes)[source]#
Change the state of a single node.
- Parameters:
number – the number of the node to change
changes –
a list with two variables in [isolate, compromise] isolate: A boolean that will if true change the isolation status of the node (true -> false,
false -> true) (boolean)
- compromise: a mode signal that will change the state of a node. 0 does nothing, 1 makes it safe and
2 compromises the node (int)
- get_compromised_nodes()[source]#
Create a list of all the nodes in the network that are compromised.
- Returns:
A list of nodes that are compromised (list of ints)
- Return type:
compromised_nodes
- get_un_compromised_nodes()[source]#
Create a list of all the safe nodes in the network.
- Returns:
A list of nodes that are safe (list of ints)
- Return type:
un_compromised_nodes
- get_isolated_nodes()[source]#
Create a list of all the isolated nodes in the network.
- Returns:
A list of nodes that are isolated (list of ints)
- Return type:
isolated_nodes
- get_number_of_isolated()[source]#
Get the number of isolated nodes in the network.
- Returns:
the number of isolated nodes in the network (int)
- get_number_of_un_compromised()[source]#
Get the number of safe nodes in the network.
- Returns:
the number of safe nodes in the network (int)
- get_connected_nodes(number)[source]#
When given a node returns a list of all of the nodes connected to that node.
- Parameters:
number – the number of the node to run on
- Returns:
a list of all the nodes connected to a specified node (list of ints)
- spread(number)[source]#
Spread the red agent through all connected nodes.
- Parameters:
number – the number of the node to spread from