CreateOutputTable

defSim.tools.CreateOutputTable.create_output_table(network: networkx.classes.graph.Graph, realizations=None, colnames=None, agents=None, settings_dict=None, tickwise_output=None, **kwargs)

This function works as a factory method for the OutputTableCreator component. It calls the create_output function of a specific implementation of the OutputTableCreator and passes to it the kwargs dictionary.

Parameters
  • network – A NetworkX object

  • realizations

    The specific OutputTableCreator that will be used. Currently, the options are:

    • Basic: Returns the realizations Regions, Zones, Isolates, Homogeneity, AverageDistance

    • ClusterFinder: Method to find clusters based on minimal allowed distance between network neighbors as defined by the user in the kwargs dictionary. Default is to return the same output as the Regions realization

    • Regions: Returns the number of regions (i.e. the number of connected components in the graph after preserving only the links with perfect similarity)

    • RegionsList: Returns a list with the sizes of all regions (i.e. the number of agents in each connected component in the graph after preserving only the links with perfect similarity)

    • Zones: Returns the number of zones (i.e. the number of connected components in the graph after preserving only the links with dissimilarity != 1)

    • ZonesList: Returns a list with the sizes of all zones (i.e. the number of agents in each connected component in the graph after preserving only the links with dissimilarity != 1)

    • Isolates: Reports the number of isolates as found in the ClusterFinder method, based on minimal allowed distance between network network neighbors as defined by the user in the kwargs dictionary. Default is to return the same output as the Regions realization

    • Homogeneity: Size of the largest cluster divided by the number of agents

    • AverageDistance: Reports average distance between connected agents, based on dissimilarity calculated during simulation.

    • AverageOpinion: Reports average opinion (requires a list of features for which this needs to be calculated if number of features > 1. Pass this list in the kwargs dictionary as AverageOpinionFeatures.)

    • Spread: Reports the spread (distance between maximum and minimum opinion)

    • Dispersion: Returns the amount of dispersion defined as the average absolute deviation from the mean on a given feature [Bramson2016]

    • Coverage: Report coverage for nondiscrete features, following [Bramson2016]

    • Graph: Returns the entire NetworkX Graph

  • agents – A list of the indices of all agents that will be considered by the output table.

  • settings_dict – A dictionary of column names and values that will be added to the output table. Can be used to merge output with parameter setting values.

  • tickwise_output – A dictionary with a list of lists with values of agents on some given feature at each tick during the simulation run. This function will create a column for each key in the dictionary.

Returns

A dictionary.

ABC of CreateOutputTable

The Abstract Base Class of the CreateOutputTable method:

class defSim.tools.CreateOutputTable.OutputTableCreator(**kwargs)

Bases: abc.ABC

This class is responsible for creating output for the output table. Inherit from this class and implement the create_output method to generate the desired output cell for the output table. If you want the output cell to have a descriptive column name, overwrite the class variable ‘label’. Otherwise, column names are autogenerated.

__init__(**kwargs)

Initialize self. See help(type(self)) for accurate signature.

abstract create_output(network: networkx.classes.graph.Graph, **kwargs)

This method receives a NetworkX object, performs some calculation, and outputs a cell for the output table.

Parameters

network – A NetworkX graph object.

Returns

label = ''