PenroseKiteDart-1.0.0: Library to explore Penrose's Kite and Dart Tilings.
Copyright(c) Chris Reade 2021
LicenseBSD-style
Maintainerchrisreade@mac.com
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Tgraph.Relabelling

Description

This module includes relabelling functions for Tgraphs whose main purpose is to implement a guided union of Tgraphs (fullUnion and tryFullUnion) and also a commonFaces operation (a kind of intersection which need not be a Tgraph) and a guided equality check (sameGraph).

Synopsis

Assisted Union (and matching) operations

fullUnion :: (Tgraph, Dedge) -> (Tgraph, Dedge) -> Tgraph Source #

fullUnion (g1,e1) (g2,e2) will try to create the union of g1 and g2. That is, it will try to combine the faces of g1 and (possibly relabelled) faces of g2 as a Tgraph. It does this by first matching the respective edges e1 and e2 and relabelling g2 to match g1 on a tile-connected region containing e1. It will raise an error if there is a mismatch. If succesfull it then uses geometry of tiles (vertex locations) to correct for multiple overlapping regions of tiles in g1 and relabelled g2 by a further relabelling of any touching vertices. The resulting union of faces requires an expensive tryTgraphProps if touching vertices were found. However the check is not needed when there are no touching vertices (i.e. a single tile-connected overlap).

tryFullUnion :: (Tgraph, Dedge) -> (Tgraph, Dedge) -> Try Tgraph Source #

tryFullUnion (g1,e1) (g2,e2) will try to create the union of g1 and g2. That is, it will try to combine the faces of g1 and (possibly relabelled) faces of g2 as a Tgraph. It does this by first matching the respective edges e1 and e2 and relabelling g2 to match g1 on a tile-connected region containing e1. It returns Left lines if there is a mismatch (where lines explains the problem). If succesfull it then uses geometry of tiles (vertex locations) to correct for multiple overlapping regions of tiles in g1 and relabelled g2 by a further relabelling of any touching vertices. The resulting union of faces requires an expensive tryTgraphProps if any touching vertices were found, and will return Left ... if this fails and Right t otherwise, where t is a Tgraph containing the union of faces. The check is not used when there are no touching vertices (i.e. a single tile-connected overlap).

commonFaces (Assisted Intersection) and sameGraph (Assisted Equivalence)

commonFaces :: (Tgraph, Dedge) -> (Tgraph, Dedge) -> [TileFace] Source #

commonFaces (g1,e1) (g2,e2) relabels g2 to match with g1 (where they match) and returns the common faces as a subset of faces of g1. i.e. with g1 vertex labelling. It requires a face in g1 with directed edge e1 to match a face in g2 with directed edge e2, (apart from the third vertex label) otherwise an error is raised. This uses vertex locations to correct touching vertices in multiply overlapping regions. >>>> touching vertices being 1-1 is sensitive to nearness check of touchingVerticesGen <<<<<<<<<

sameGraph :: (Tgraph, Dedge) -> (Tgraph, Dedge) -> Bool Source #

sameGraph (g1,e1) (g2,e2) checks to see if g1 and g2 are the same Tgraph after relabelling g2. The relabelling is based on directed edge e2 in g2 matching e1 in g1 (where the direction is clockwise round a face) and uses tryRelabelToMatch.

Creating Relabellings

newtype Relabelling Source #

Relabelling is a special case of mappings from vertices to vertices that are not the identity on a finite number of vertices. They are represented by keeping the non identity cases in a finite map. When applied, we assume the identity map for vertices not found in the representation domain (see relabelV). Relabellings must be 1-1 on their representation domain, and redundant identity mappings are removed in the representation. Vertices in the range of a relabelling must be >0.

Constructors

Relabelling (IntMap Vertex) 

newRelabelling :: [(Vertex, Vertex)] -> Relabelling Source #

newRelabelling prs - make a relabelling from a finite list of vertex pairs. The first item in each pair relabels to the second in the pair. The resulting relabelling excludes any identity mappings of vertices. An error is raised if second items of the pairs contain duplicated numbers or a number<1

Relabellings and matching

relabelToMatch :: (Tgraph, Dedge) -> (Tgraph, Dedge) -> Tgraph Source #

relabelToMatch (g1,e1) (g2,e2) produces a relabelled version of g2 that is consistent with g1 on a single tile-connected region of overlap. The overlapping region must contain the directed edge e1 in g1. The edge e2 in g2 will be identified with e1 by the relabelling of g2. This produces an error if a mismatch is found anywhere in the overlap.

CAVEAT: The relabelling may not be complete if the overlap is not just a SINGLE tile-connected region in g1. If the overlap is more than a single tile-connected region, then the union of the relabelled faces with faces in g1 will be tile-connected but may have touching vertices. This limitation is addressed by fullUnion.

tryRelabelToMatch :: (Tgraph, Dedge) -> (Tgraph, Dedge) -> Try Tgraph Source #

tryRelabelToMatch (g1,e1) (g2,e2) produces either Right g where g is a relabelled version of g2 that is consistent with g1 on an overlapping tile-connected region or Left lines if there is a mismatch (lines explaining the problem). The overlapping region must contain the directed edge e1 in g1. The edge e2 in g2 will be identified with e1 by the relabelling of g2.

CAVEAT: The relabelling may not be complete if the overlap is not just a SINGLE tile-connected region in g1. If the overlap is more than a single tile-connected region, then the union of the relabelled faces with faces in g1 will be tile-connected but may have touching vertices. This limitation is addressed by tryFullUnion.

relabelToMatchIgnore :: (Tgraph, Dedge) -> (Tgraph, Dedge) -> Tgraph Source #

same as relabelToMatch but ignores non-matching faces (except for the initial 2) The initial 2 faces are those on the given edges, and an error is raised if they do not match. This is used by commonFaces

Using Relabellings

relabelGraph :: Relabelling -> Tgraph -> Tgraph Source #

relabelGraph rlab g - uses a Relabelling rlab to change vertices in a Tgraph g. Caveat: This should only be used when it is known that: rlab is 1-1 on its (representation) domain, and the vertices of g are disjoint from those vertices that are in the representation range but which are not in the representation domain of rlab. This ensures rlab (extended with the identity) remains 1-1 on vertices in g, so that the resulting Tgraph does not need an expensive check for Tgraph properties. (See also checkRelabelGraph)

checkRelabelGraph :: Relabelling -> Tgraph -> Tgraph Source #

checkRelabelGraph uses a relabelling map to change vertices in a Tgraph, then checks that the result is a valid Tgraph. (see also relabelGraph)

relabelFace :: Relabelling -> TileFace -> TileFace Source #

Uses a relabelling to relabel the three vertices of a face. Any vertex not in the domain of the mapping is left unchanged. The mapping should be 1-1 on the 3 vertices to avoid creating a self loop edge.

relabelV :: Relabelling -> Vertex -> Vertex Source #

relabelV rlab v - uses relabelling rlab to find a replacement for v (leaves as v if none found). I.e relabelV turns a Relabelling into a total function using identity for undefined cases in the Relabelling representation.

prepareFixAvoid :: [Vertex] -> VertexSet -> Tgraph -> Tgraph Source #

prepareFixAvoid fix avoid g - produces a new Tgraph from g by relabelling. Any vertex in g that is in the set avoid but not in the list fix will be changed to a new vertex that is neither in g nor in the set (avoid with fix removed). All other vertices of g (including those in fix) will remain the same. Usage: This is used to prepare a graph by avoiding accidental label clashes with the avoid set (usually vertices of another graph). However we fix a list of vertices which we intend to control in a subsequent relabelling. (this is usually a pair of vertices from a directed edge that will get a specific subsequent relabelling). Note: If any element of the list fix is not a vertex in g, it could end up in the relabelled Tgraph.

relabelContig :: Tgraph -> Tgraph Source #

Relabel all vertices in a Tgraph using new labels 1..n (where n is the number of vertices).

renumberFaces :: [(Vertex, Vertex)] -> [TileFace] -> [TileFace] Source #

renumberFaces allows for a non 1-1 relabelling represented by a list of pairs. It is used only for tryCorrectTouchingVs in Tgraphs which then checks the result