Metadata
Component models such as VertexModel and EdgeModel can store metadata. We distinguish between two kinds of metadata: component metadata and symbol metadata.
Component Metadata
Component metadata is a Dict{Symbol,Any} attached to each component to store various information. Use metadata to retrieve the full dict.
To access the data, you can use the methods has_metadata, get_metadata, set_metadata! and delete_metadata! (see Component Metadata API).
Special metadata:
:graphelement: optional field to specialize the graphelement for each component (vidx) for vertices,(;src,dst)named tuple of either vertex names or vertex indices for edges. Has special accessorshas_/get_/set_graphelement.:callback: optional field to define callback functions on the component level. See Callbacks and Callbacks API for more information.:position: Store a tuple(x, y)with position of the node for plotting. Has special accessorshas_/get_/set_position.:marker: Store aSymbolfor the graph plot. Possible values could be:circle,:rect,:utriangle,:cross,:diamond,:dtriangle,:pentagon,:xcrossor anything which works as amarkerkeyword argument in Makie.:initconstraint: Store additional initialization constrains. Has specialhas_/get_/set_/delete_initconstraintaccessors. See Initialization for further
details.
:initformula: Similar to initconstraint, but is a straight forward explicit mapping to initialize some variables.
Symbol Metadata
Each component stores symbol metadata. The symbol metadata is a Dict{Symbol, Dict{Symbol, Any}} which stores a metadata dict per symbol. Symbols are everything that appears in sym, psym, obssym and insym.
To access the data, you can use the methods has_metadata, get_metadata, set_metadata! and delete_metadata! (see Per Symbol Metadata API). These functions also support pattern matching using String or Regex patterns to match symbol names, making it easier to work with symbols containing special characters or when you only know part of the symbol name.
Special cases for symbol metadata are:
default: Stores default values for states/parameters. In initialization, those are considered fixed.guess: Stores a guess for a state/parameter which needs to be solved during initialization ("free" variables).bounds: Stores bounds for variables/parametersinit: Stores the solution of the "free" variables, this is rarely set manually but instead when callinginitialize_component!.
For those, there are special functions has_*, get_*, set_*!, delete_*! and strip_*!. The strip_*! functions remove all metadata of a specific type from all symbols in a component. See Per Symbol Metadata API.
These are closely aligned with the metadata use in ModelingToolkit. They are automatically copied from the System if you use MTK models to create NetworkDynamics models.
Metadata Utils
Accessing metadata (especially defaults) of states and parameters is a very common task. We provide several helper methods to do so. Please check out their docstrings for further explanation:
dump_statedump_initial_stateget_initial_statefree_u- find variables without default valuesfree_p- find parameters without default valuesdescribe_vertices(needsDataFrames.jlloaded)describe_edges(needsDataFrames.jlloaded)