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



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.



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 NodeSource

add a new node with value n to the graph

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

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.

newEdge :: Rewrite n EdgeSource

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