algraph-0.7.0.0: Graph library using adjacency list representation
CopyrightThodoris Papakonstantinou 2017-2026
LicenseLGPL-3
Maintainerdev@tpapak.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Graph.AdjacencyList.Grid

Description

Generators for d-dimensional cubic lattices with periodic boundary conditions (toroidal topology). A PBCSquareLattice L D is the Cartesian product of D cycle graphs of length L: \( C_L \square^D \).

Provides both directed (graphCubicPBC, forward edges only) and undirected (undirectedGraphCubicPBC, forward + backward edges) variants, plus coordinate conversion between flat vertex IDs and Cartesian coordinates.

Synopsis

Documentation

type L = Natural Source #

Linear size of the lattice (number of vertices per dimension).

type D = Natural Source #

Dimensionality of the lattice (2 = square, 3 = cubic, etc.).

type CVertex = [Vertex] Source #

Cartesian coordinates of a lattice vertex: a list of per-dimension indices.

fromTuple :: (Vertex, Vertex) -> Edge Source #

Construct an Edge from a (source, target) tuple.

toTuple :: Edge -> (Vertex, Vertex) Source #

Convert an Edge to a (source, target) tuple.

adjacentEdges :: Graph -> Vertex -> [Edge] Source #

All outgoing edges from a vertex.

vertexToCVertex :: L -> D -> Vertex -> CVertex Source #

Given a Vertex returns a tuple of the Cartesian product of a L sized Cycle graph

cVertexToVertex :: L -> D -> CVertex -> Vertex Source #

The reverse function of vertexToCVertex

data PBCSquareLattice Source #

A PBCSquareLattice is the Cartesian product of a cycle graph of length L (C_L) => (C_L)▢^d

Constructors

PBCSquareLattice L D 

pbcEdgeIx :: L -> D -> Edge -> Maybe Int Source #

Index of edge of a grid with periodic boundary conditions Very inefficient, better use Data.Map for lookups.

gridSize :: PBCSquareLattice -> Natural Source #

Total number of vertices in the lattice: L^D.

gridNumEdges :: PBCSquareLattice -> Natural Source #

Number of directed (forward) edges in the lattice: D * L^D.

pbcForwardEdges :: L -> D -> Vertex -> [Edge] Source #

Returns tuple (edge) giving forward vertices of given vertex on a Toroidal Boundary Conditions (pbc) grid

pbcBackwardEdges :: L -> D -> Vertex -> [Edge] Source #

Returns tuple (edge) giving backward vertices of given vertex on a Toroidal Boundary Conditions (pbc) grid

Undirected cubic graph with PBC

undirectedGraphCubicPBC :: PBCSquareLattice -> Graph Source #

Undirected graph on a PBC cubic lattice (both forward and backward edges). Contains 2 * D * L^D directed edges (two per neighbor pair).

Directed cubic graph with PBC

graphCubicPBC :: PBCSquareLattice -> Graph Source #

Directed graph embeded in cubic lattice