#directed-acyclic-graph #dag #component #connection #frequenz #directed-graph #python-bindings #microgrid

frequenz-microgrid-component-graph

A library for representing the components of a microgrid and the connections between them as a Directed Acyclic Graph (DAG)

5 releases (3 breaking)

Uses new Rust 2024

0.4.0 Dec 21, 2025
0.3.0 Dec 9, 2025
0.2.0 Nov 26, 2025
0.1.2 Nov 19, 2025
0.1.0 Oct 28, 2025

#536 in FFI

Download history 246/week @ 2025-10-28 451/week @ 2025-11-11 2951/week @ 2025-11-18 515/week @ 2025-11-25 2/week @ 2025-12-02 283/week @ 2025-12-09 834/week @ 2025-12-16 24/week @ 2025-12-30 21/week @ 2026-01-06 13/week @ 2026-01-13 2/week @ 2026-01-20

60 downloads per month
Used in frequenz-microgrid

MIT license

250KB
5.5K SLoC

Frequenz Microgrid Component Graph

This is a library for representing the components of a microgrid and the connections between them as a Directed Acyclic Graph (DAG).

A graph representation makes it easy to reason about the relationships between the components and to come up with formulas for calculating aggregated metrics for the microgrid.

The Node and Edge traits

The main struct is ComponentGraph, instances of which can be created by passing an iterator of components and the connections between them to the try_new method.

But because component_graph is an independent library, it doesn't know about the component and connection types and instead uses traits to interact with them.

Therefore, to be usable with this library, the component and connection types must implement the Node and Edge traits, respectively. Check out the documentation for these traits for sample implementations.

Validation

The try_new method several checks on the graph including checking that:

  • There is exactly one root node.
  • All edges point to existing nodes.
  • All nodes are reachable from the root node.
  • There are no cycles in the graph.
  • The components have sensible neighbor types. For example, a battery shouldn't have successors and should have a battery inverter as a predecessor.

If any of the validation steps fail, the method will return an Error, and a ComponentGraph instance otherwise.

Formula generation

The component graph library has methods for generating formulas for various metrics of the microgrid. The following formulas are supported:


Frequenz Microgrid Component Graph

docs.rs Crates.io

This is a library for representing the components of a microgrid and the connections between them as a Directed Acyclic Graph (DAG).

Current features:

  • Validating the graph
  • Traversing the graph
  • Formula generation

Upcoming features:

  • Python bindings

Dependencies

~9.5MB
~82K SLoC