-- | updates a typed graph morphism, mapping node n1 to node n2. It assumes both nodes already exist.
updateNodeRelation :: NodeId -> NodeId -> NodeId -> TypedGraphMorphism a b -> TypedGraphMorphism a b
updateNodeRelation n1 n2 tp tgm =
  TypedGraphMorphism { domainGraph = GM.updateNodeRelation n1 tp (domainGraph tgm)
                     , codomainGraph = GM.updateNodeRelation n2 tp (codomainGraph tgm)
                     , mapping = GM.updateNodeRelation n1 n2 (mapping tgm)
                     }
updateNodeRelation :: NodeId -> NodeId -> NodeId -> TypedGraphMorphism a b -> TypedGraphMorphism a b
updateNodeRelation n1 n2 tp tgm =
  TypedGraphMorphism { domainGraph = GM.updateNodeRelation n1 tp (domainGraph tgm)
                     , codomainGraph = GM.updateNodeRelation n2 tp (codomainGraph tgm)
                     , mapping = GM.updateNodeRelation n1 n2 (mapping tgm)
                     }
updateNodeRelation n1 n2 tp tgm =
  TypedGraphMorphism { domainGraph = GM.updateNodeRelation n1 tp (domainGraph tgm)
                     , codomainGraph = GM.updateNodeRelation n2 tp (codomainGraph tgm)
                     , mapping = GM.updateNodeRelation n1 n2 (mapping tgm)
                     }