Immunization¶
-
class
contagion.
Immunization
(network)¶ Some baseline algorithms for generating immunization arrays.
Methods
generate_bfs_immunization_array
([Q])Generates an immunization array consisting of Q first nodes encountered in a breadth-first search. generate_centrality_immunization_array
([Q, …])Generates an immunization array with the Q lowest or highest centrality nodes immunized. generate_dfs_immunization_array
([Q])Generates an immunization array consisting of Q first nodes encountered in a depth-first search. generate_highest_degrees_immunization_array
([Q])Generates an immunization array with the Q highest-degree nodes immunized. generate_largest_cliques_immunization_array
([Q])Generates an immunization array consisting of the Q unique individuals in the largest cliques. generate_longest_chains_immunization_array
([Q])Generates an immunization array consisting of the Q unique individuals in the longest decomposed chains. generate_lowest_degrees_immunization_array
([Q])Generates an immunization array with the Q lowest-degree nodes immunized. generate_random_immunization_array
([Q])Generates an immunization array with Q nodes randomly immunized. generate_smallest_cliques_immunization_array
([Q])Generates an immunization array consisting of the Q unique individuals in the smallest cliques of size greater than 1. -
generate_bfs_immunization_array
(Q=1)¶ Generates an immunization array consisting of Q first nodes encountered in a breadth-first search.
Parameters: Q : int
Number of individuals to immunize; default to 1
Returns: Im : numpy.ndarray
an (n, 1) array with 1 at indices to be immunized and 0 elsewhere
Raises: ValueError : if BFS fails.
-
generate_centrality_immunization_array
(Q=1, centrality_type='betweenness', order='highest')¶ Generates an immunization array with the Q lowest or highest centrality nodes immunized. Three measures of centrality are implemented: betweenness, eigenvector, and closeness.
Parameters: Q : int
Number of individuals to immunize; default to 1
centrality_type : str
Flavor of centrality to use. Defaults to betweenness
order : str
Either “highest” or “lowest”
Returns: Im : numpy.ndarray
an (n, 1) array with 1 at indices to be immunized and 0 elsewhere
Raises: NotImplementedError : for invalid centrality type or how not in
[“highest”, “lowest”]
-
generate_dfs_immunization_array
(Q=1)¶ Generates an immunization array consisting of Q first nodes encountered in a depth-first search.
Parameters: Q : int
Number of individuals to immunize; default to 1
Returns: Im : numpy.ndarray
an (n, 1) array with 1 at indices to be immunized and 0 elsewhere
Raises: ValueError : if DFS fails.
-
generate_highest_degrees_immunization_array
(Q=1)¶ Generates an immunization array with the Q highest-degree nodes immunized.
Parameters: Q : int
Number of individuals to immunize; default to 1
Returns: Im : numpy.ndarray
an (n, 1) array with 1 at indices to be immunized and 0 elsewhere
-
generate_largest_cliques_immunization_array
(Q=1)¶ Generates an immunization array consisting of the Q unique individuals in the largest cliques.
Parameters: Q : int
Number of individuals to immunize; default to 1
Returns: Im : numpy.ndarray
an (n, 1) array with 1 at indices to be immunized and 0 elsewhere
Raises: ValueError : if no cliques are found.
-
generate_longest_chains_immunization_array
(Q=1)¶ Generates an immunization array consisting of the Q unique individuals in the longest decomposed chains.
Parameters: Q : int
Number of individuals to immunize; default to 1
Returns: Im : numpy.ndarray
an (n, 1) array with 1 at indices to be immunized and 0 elsewhere
Raises: ValueError : if no cliques are found.
-
generate_lowest_degrees_immunization_array
(Q=1)¶ Generates an immunization array with the Q lowest-degree nodes immunized.
Parameters: Q : int
Number of individuals to immunize; default to 1
Returns: Im : numpy.ndarray
an (n, 1) array with 1 at indices to be immunized and 0 elsewhere
-
generate_random_immunization_array
(Q=1)¶ Generates an immunization array with Q nodes randomly immunized.
Parameters: Q : int
Number of individuals to immunize; default to 1
Returns: Im : numpy.ndarray
an (n, 1) array with 1 at indices to be immunized and 0 elsewhere
-
generate_smallest_cliques_immunization_array
(Q=1)¶ Generates an immunization array consisting of the Q unique individuals in the smallest cliques of size greater than 1.
Parameters: Q : int
Number of individuals to immunize; default to 1
Returns: Im : numpy.ndarray
an (n, 1) array with 1 at indices to be immunized and 0 elsewhere
Raises: ValueError : if no cliques are found.
-