Infrastructure#

class eclypse.graph.infrastructure.Infrastructure[source]#

Bases: AssetGraph

Class to represent a Cloud-Edge infrastructure.

Methods

__init__([infrastructure_id, ...])

Create a new Infrastructure.

add_edge(u_of_edge, v_of_edge[, symmetric, ...])

Add an edge and invalidate the path cache.

add_node(node_for_adding[, strict])

Add a node and invalidate the path cache.

evolve()

Update the infrastructure and invalidate derived path caches.

is_available(n)

Check if the node is available.

path(source, target[, cost_attr])

Retrieve the hop-level path between two nodes, if it exists.

path_resources(source, target)

Retrieve the resources of the path between two nodes, if it exists.

processing_time(source, target)

Compute the total processing time of all nodes along the path.

remove_edge(u, v)

Remove an edge and invalidate the path cache.

remove_node(n)

Remove a node and invalidate the path cache.

validate(other)

Validate the infrastructure against a set of requirements.

Attributes

available

Return a filtered view containing only the available nodes.

__init__(infrastructure_id='Infrastructure', update_policies=None, node_assets=None, edge_assets=None, include_default_assets=True, path_assets_aggregators=None, path_algorithm=None, resource_init='min', seed=None)[source]#

Create a new Infrastructure.

Parameters:
  • infrastructure_id (str) – The ID of the infrastructure.

  • update_policies (Callable | list[Callable] | None) – Graph update policies executed during evolve().

  • node_assets (dict[str, Asset] | None) – The assets of the nodes.

  • edge_assets (dict[str, Asset] | None) – The assets of the edges.

  • include_default_assets (bool) – Whether to include the default assets. Defaults to True.

  • path_assets_aggregators (dict[str, Callable[[list[Any]], Any]] | None) – The aggregators to use for the path assets.

  • path_algorithm (Callable[[nx.Graph, str, str], list[str]] | None) – The algorithm to use to compute the paths.

  • resource_init (InitPolicy) – The initialization method for the resources.

  • seed (int | None) – The seed for the random number generator.

evolve()[source]#

Update the infrastructure and invalidate derived path caches.

add_node(node_for_adding, strict=False, **assets)[source]#

Add a node and invalidate the path cache.

Parameters:
  • node_for_adding (str) – The node to add.

  • strict (bool) – If True, raise an error if the node already exists.

  • **assets – Additional node assets.

add_edge(u_of_edge, v_of_edge, symmetric=False, strict=False, **assets)[source]#

Add an edge and invalidate the path cache.

Parameters:
  • u_of_edge (str) – The source node of the edge.

  • v_of_edge (str) – The target node of the edge.

  • symmetric (bool) – If True, add the edge in both directions.

  • strict (bool) – If True, raise an error if the edge already exists.

  • **assets – Additional edge assets.

remove_node(n)[source]#

Remove a node and invalidate the path cache.

Parameters:

n (str) – The node to remove.

remove_edge(u, v)[source]#

Remove an edge and invalidate the path cache.

Parameters:
  • u (str) – The source node of the edge.

  • v (str) – The target node of the edge.

validate(other)[source]#

Validate the infrastructure against a set of requirements.

Compares the requirements of the nodes and edges in the PlacementView with the resources of the nodes and edges in the Infrastructure.

Parameters:

other (Infrastructure) – The Infrastructure to compare with.

Returns:

A list of nodes whose requirements are not respected or

whose connected links are not respected.

Return type:

list[str]

path(source, target, cost_attr='latency')[source]#

Retrieve the hop-level path between two nodes, if it exists.

If the path has not been computed yet, or if any hop cost has changed by more than the configured threshold, the path is recomputed and cached.

Parameters:
  • source (str) – The name of the source node.

  • target (str) – The name of the target node.

  • cost_attr (str) – The edge attribute to consider as the cost for determining whether to recompute the path. Defaults to “latency”.

Returns:

The per-hop costs as (source, target, edge_attributes), or None if no path exists.

Return type:

list[tuple[str, str, dict[str, Any]]] | None

processing_time(source, target)[source]#

Compute the total processing time of all nodes along the path.

Calls path() first to ensure the node list is cached, then sums the processing_time attribute of every node on that path. Returns 0.0 when source and target are the same node or when no path exists.

Parameters:
  • source (str) – The name of the source node.

  • target (str) – The name of the target node.

Returns:

The total processing time along the path, in the same unit as the individual node processing_time attributes.

Return type:

float

path_resources(source, target)[source]#

Retrieve the resources of the path between two nodes, if it exists.

If the path does not exist, it is computed and cached.

Parameters:
  • source (str) – The name of the source node.

  • target (str) – The name of the target node.

Returns:

The resources of the path between the two nodes, or None if the path does not exist.

Return type:

PathResources

property available: DiGraph#

Return a filtered view containing only the available nodes.

Uses nx.subgraph_view to avoid creating a full Infrastructure instance. The view is dynamic: it reflects the current state of the graph at all times, filtering out nodes where availability <= 0.

Returns:

A subgraph view with only the available nodes.

Return type:

nx.DiGraph

is_available(n)[source]#

Check if the node is available.

Parameters:

n (str) – The node to check.

Returns:

True if the node is available, False otherwise.

Return type:

bool