pyssg is pre-1.0 and under active development - APIs, config, and themes may change.
pyssg.core.graph

1 min read

pyssg.core.graph

The dependency graph.

A single graph is the source of truth for the data plane from after Load until before Emit. It maintains a forward index (by src) and a reverse index (by dst) so that dirty propagation can walk incoming edges. The reverse index holds only connections declared reverse=True; in_edges is therefore meaningful only for those edges.

class DependencyGraph

Forward + reverse indexed graph of nodes and connections.

DependencyGraph.__init__(self) -> None

DependencyGraph.add_node(self, node: Node) -> None

DependencyGraph.get(self, nid: NodeId) -> Node | None

DependencyGraph.nodes(self) -> list[Node]

DependencyGraph.remove(self, nid: NodeId) -> None

Remove a node and every edge incident to it (both directions).

DependencyGraph.connect(self, c: Connection) -> None

Record a connection in the forward (and, if reverse, reverse) index.

DependencyGraph.disconnect(self, c: Connection) -> None

Remove a previously recorded connection (by identity).

DependencyGraph.out_edges(self, nid: NodeId, kind: ConnectionKind | None = None) -> list[Connection]

DependencyGraph.in_edges(self, nid: NodeId, kind: ConnectionKind | None = None) -> list[Connection]

Incoming reverse edges (only reverse=True edges).

DependencyGraph.connection_of(self, nid: NodeId, dep: Dependency) -> Connection | None

The forward connection of nid carrying dep.