CopyMeGraph
— A good place to start with your graph-based model#
This template model supplies a minimal graph-based Utopia model. On top of what the CopyMeBare model template provides, this model contains:
Infrastructure for graph setup and data writing
A customisable
GraphType
(based on the Boost Graph Library), including vertex and edge propertiesConfiguration files showcasing some of the graph setup and plotting capabilities
A
cfgs
directory with further example configuration files
Use this model if you want to start “from scratch” but want to avoid setting up the infrastructure itself.
Hint
Refer to Step-by-step Guide for information on how to implement your own model based on this template.
Default configuration parameters#
Below are the default configuration parameters for the CopyMeGraph
model.
# --- Space parameters
# The physical space this model is embedded in
space:
periodic: true
# -- Network and agent initialization -----------------------------------------
create_graph:
model: regular
num_vertices: 30
mean_degree: 1
# --- Model-specific parameters
regular:
# Whether the underlying lattice is oriented (directed only)
oriented: true
ErdosRenyi:
# Allow parallel edges
parallel: false
# Allow self edges
self_edges: false
WattsStrogatz:
# Rewiring probability
p_rewire: 0.
# Orientation of the underlying lattice (directed only)
oriented: false
BarabasiAlbert:
# Allow parallel edges
parallel: false
BollobasRiordan:
# Graph generating parameters
alpha: 0.2
beta: 0.8
gamma: 0.
del_in: 0.
del_out: 0.5
# Vertex initialization parameters
init_some_state: 3.14
init_some_trait: 42
# Edge initialization parameters
init_weight: 1.
# Use a random weight between zero and `init_weight`
init_random_weight: true
# --- Other initialization parameters
# Add parameters and their documentation here ...
# -- Dynamics
# Some parameter that controls some mechanism during some part of the dynamics
some_parameter: 0.1
# Add further parameters and their documentation here ...
Available plots#
The following plot configurations are available for the CopyMeGraph
model:
Default Plot Configuration#
# -- Graph plots --------------------------------------------------------------
graph:
based_on: graph
# -- Time series plots --------------------------------------------------------
time_series/some_state_mean_and_std:
based_on: some_state_mean_and_std
time_series/some_trait_mean_and_std:
based_on: some_trait_mean_and_std
time_series/single_vertex_states:
based_on: single_vertex_states
time_series/single_vertex_states_dynamic:
based_on: single_vertex_states_dynamic
Base Plot Configuration#
.variables:
base_path: &base_path data/CopyMeGraph
# =============================================================================
# ╔╦╗╔═╗╔╦╗╔═╗╦ ╔═╗╔╦╗╔═╗╔═╗
# ║ ║╣ ║║║╠═╝║ ╠═╣ ║ ║╣ ╚═╗
# ╩ ╚═╝╩ ╩╩ ╩═╝╩ ╩ ╩ ╚═╝╚═╝
# =============================================================================
# -- Overloads ----------------------------------------------------------------
# Overload some configs to insert model-specific settings
# Model-specific defaults
.defaults:
based_on: .defaults
# Can define something here ...
# .. Creators .................................................................
.creator.universe:
based_on:
- .creator.universe
- .defaults
dag_options:
select_path_prefix: *base_path
.creator.multiverse:
based_on:
- .creator.multiverse
- .defaults
select_and_combine:
base_path: *base_path
# -- Plot templates -----------------------------------------------------------
# Time series facet grid plots
.plot.time_series.base:
based_on:
- .hlpr.kind.time_series
- .plot.facet_grid.with_auto_encoding
- .plot.facet_grid.line
x: time
.plot.time_series.uni:
based_on:
- .creator.universe
- .plot.time_series.base
.plot.time_series.mv:
based_on:
- .creator.multiverse
- .plot.time_series.base
# A graph plot for universe data
.plot.graph:
based_on:
- .creator.universe
- .plot.graph
# =============================================================================
# ╔═╗╦ ╔═╗╔╦╗╔═╗
# ╠═╝║ ║ ║ ║ ╚═╗
# ╩ ╩═╝╚═╝ ╩ ╚═╝
# =============================================================================
# .. Mean value time series ...................................................
some_state_mean_and_std:
# Base it on existing configurations
based_on:
- .plot.time_series.uni
- .plot.facet_grid.errorbands
# Select the data by defining a variable that is also used to set the y label
dag_options:
define:
data_to_select: g_static/some_state
select:
_data:
path: "."
transform:
- getitem: [!dag_prev , !dag_tag data_to_select]
# Compute mean and std and assemble into Dataset for errorbar plot
transform:
- .mean: [!dag_tag _data, [vertex_idx]]
tag: mean
- .std: [!dag_tag _data, [vertex_idx]]
tag: std
- xr.Dataset:
- mean: !dag_tag mean
std: !dag_tag std
tag: data
y: mean
yerr: std
helpers:
set_labels:
y: !dag_result data_to_select
# Same for the trait value
some_trait_mean_and_std:
based_on: some_state_mean_and_std
# Need only adapt the path to the dataset, rest is inherited
dag_options:
define:
data_to_select: g_static/some_trait
# .. Individual cell states ...................................................
# Plot individual vertex states over time using a generic plotting function
single_vertex_states:
based_on: .plot.time_series.uni
# Select some single vertices to plot the states of
select:
data:
path: g_static/some_state
with_previous_result: true # makes the select data available as first
# positional argument to the transform
# operation; and the result of the first
# transformation to the first argument of the
# second transformation, etc.
transform:
- .sel: {vertex_idx: [0, 1, 2, 4, 8]}
helpers:
set_title:
title: Individual Vertex States
# Perform the same plot with the data from the graph group 'g_dynamic'. In this
# case, the data is loaded as a `TimeSeriesGroup` (and not as Xarray) which
# also supports important xarray-methods such as coordinate access using .sel.
single_vertex_states_dynamic:
based_on: single_vertex_states
select:
data:
path: g_dynamic/some_state
helpers:
set_labels:
y: cell state
# .. Graph plot ...............................................................
# Plot the final graph. Map the 'some_state' data to the node color, the node
# degree to the size of the nodes, and the weights to the edge width.
graph:
based_on: .plot.graph
select:
graph_group: g_dynamic
# Configure the created networkx graph object
graph_creation:
at_time_idx: -1 # Select the last timestep
node_props: ['some_trait', 'some_state'] # Select node and edge
edge_props: ['weights'] # properties from the GraphGroup
# Configure the graph layout
graph_drawing:
positions:
model: spring # The spring model positions the nodes
# such that edge lengths are reduced.
k: 1 # Tweaking the spring model by adjusting
# the optimal edge length (k) and the
iterations: 100 # maximum number of iterations done.
nodes:
node_color:
from_property: some_state # Map the 'some_state' data to the color
node_size:
from_property: degree # Map the node degree to the node size
scale_to_interval: [10, 200] # Scale the (degree-)data to the given
# interval (the default size is 300).
edges:
width:
from_property: weights # Map the 'weights' data to the edge
scale_to_interval: [0.1, 1.2] # width and scale the data accordingly.
helpers:
set_title:
title: Final Graph
For available base plots, see Base Plot Configuration Pool.