AssetGraph#
- class eclypse.graph.asset_graph.AssetGraph[source]#
Bases:
DiGraphAssetGraph represents an heterogeneous network infrastructure.
Methods
__init__(graph_id[, node_assets, ...])Initializes the AssetGraph object.
add_edge(u_of_edge, v_of_edge[, symmetric, ...])Adds an edge to the graph with the given assets.
add_node(node_for_adding[, strict])Adds a node to the graph with the given assets.
evolve()Updates the graph according to its update policies.
Attributes
Checks if the graph is dynamic, i.e., if it has an update policy.
Get a logger for the graph, binding the graph id in the logs.
- __init__(graph_id, node_assets=None, edge_assets=None, update_policies=None, attr_init='min', flip_assets=False, seed=None)[source]#
Initializes the AssetGraph object.
- Parameters:
graph_id (str) – The ID of the graph.
node_assets (dict[str, Asset] | None, optional) – The assets of the nodes. Defaults to None.
edge_assets (dict[str, Asset] | None, optional) – The assets of the edges. Defaults to None.
update_policies (Callable | list[Callable] | None) – The graph update policies to execute during
evolve(). Defaults to None.attr_init (InitPolicy, optional) – The initialization policy for the assets. Defaults to “min”.
flip_assets (bool, optional) – Whether to flip the assets. Defaults to False.
seed (int | None, optional) – The seed for the random number generator. Defaults to None.
- add_node(node_for_adding, strict=True, **assets)[source]#
Adds a node to the graph with the given assets.
It also checks if the assets values are consistent with their spaces.
- Parameters:
node_for_adding (str | None, optional) – The node to add. Defaults to None.
**assets – The assets of the node.
strict (bool, optional) – If True, raises an error if the assets are inconsistent. If False, logs a warning. Defaults to True.
- Raises:
ValueError – If the assets are inconsistent and strict is True.
- add_edge(u_of_edge, v_of_edge, symmetric=False, strict=True, **assets)[source]#
Adds an edge to the graph with the given assets.
It also checks if the assets values are consistent with their spaces.
- Parameters:
u_of_edge (str) – The source node.
v_of_edge (str) – The target node.
symmetric (bool, optional) – If True, adds the edge in both directions. Defaults to False.
strict (bool, optional) – If True, raises an error if the assets are inconsistent. If False, logs a warning. Defaults to True.
**assets – The assets of the edge.
- Raises:
ValueError – If the source or target node is not found in the graph.
ValueError – If the assets are inconsistent and strict is True.
- property is_dynamic: bool#
Checks if the graph is dynamic, i.e., if it has an update policy.
- Returns:
True if the graph is dynamic, False otherwise.
- Return type:
bool
- property logger: Logger#
Get a logger for the graph, binding the graph id in the logs.
- Returns:
The logger for the graph.
- Return type:
Logger