graph-rewriting-0.7.10: Monadic graph rewriting of hypergraphs with ports and multiedges

GraphRewriting.Graph.Write

Description

Functions for modifying the graph. Although the graph structure is entirely expressed by the graph's node collection, for convenience and efficiency the graph representation also comprises a complementary collection of edges, that has to be synchronised with the node collection. Therefore each of the functions below involves a test for whether the graph structure has been changed, and if so, measures are taken to ensure the graph remains consistent.

Invariants for graph consistency:

• Every edge attached to some node points back to that node: ∀n∊N ∀e∊E: n→e ⇔ e→n
• There are no orphaned edges: ∀e∊E ∃n∊N: e→n

Synopsis

# Documentation

writeNode :: View [Port] n => Node -> n -> Rewrite n () Source #

assign new value to given node

modifyNode :: View [Port] n => Node -> (n -> n) -> Rewrite n () Source #

modify the node value

updateNode :: (View [Port] n, View v n) => Node -> v -> Rewrite n () Source #

Wraps update to update aspect v of a node.

adjustNode :: (View [Port] n, View v n) => Node -> (v -> v) -> Rewrite n () Source #

Wraps adjust to adjust aspect v of a node.

adjustNodeM :: (View [Port] n, View v n) => Node -> (v -> Rewrite n v) -> Rewrite n () Source #

newNode :: View [Port] n => n -> Rewrite n Node Source #

add a new node with value n to the graph

copyNode :: (View [Port] n, View v n) => Node -> v -> Rewrite n Node Source #

Create a new node by cloning another, at the same time updating aspect v. When defining rewrites in a context where it is not known what type n the nodes of the graph have, this is the only way to add new nodes to the graph.

Create a new (unconnected) edge. It is expected that the created edge is connected to a port sooner or later. Otherwise the graph will invove unconnected edges.

deleteNode :: View [Port] n => Node -> Rewrite n () Source #

remove node from the graph

deleteEdge :: View [Port] n => Edge -> Rewrite n [Edge] Source #

Disconnect ports connected to the given edge by assigning a new (dangling) edge to each of the ports. Then the edge is deleted.

mergeEdges :: View [Port] n => Edge -> Edge -> Rewrite n () Source #

Reconnects the ports connected to the second edge to the first one. Then the second edge is deleted.

module Data.View