networks
networks
Custom contact networks
Functions
| Name | Description |
|---|---|
| plot_household_structure | Plot the structure of household networks showing connections within households. |
plot_household_structure
networks.plot_household_structure(
households,
title='Household Network Structure',
figsize=(12, 8),
)Plot the structure of household networks showing connections within households.
This function creates a network visualization where: - Nodes represent individual agents - Edges represent household connections (complete graphs within households) - Different colors represent different households - Node size is proportional to household size
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| households | list | List of lists, where each inner list contains agent UIDs in a household | required |
| title | str | Title for the plot | 'Household Network Structure' |
| figsize | tuple | Figure size (width, height) | (12, 8) |
Returns
| Name | Type | Description |
|---|---|---|
| networkx.Graph: The NetworkX graph object for further analysis |
Example
from tbsim.networks import plot_household_structure households = [[0, 1, 2], [3, 4], [5, 6, 7, 8]] G = plot_household_structure(households, “My Household Network”)