{-# LANGUAGE ScopedTypeVariables #-}
--------------------------------------------------------------------------------
-- |
-- Module : Data.PlanarGraph
-- Copyright : (C) Frank Staals
-- License : see the LICENSE file
-- Maintainer : Frank Staals
--
-- Data type for representing connected planar graphs
--------------------------------------------------------------------------------
module Data.PlanarGraph( -- $setup
-- * The Planar Graph type
PlanarGraph
, embedding, vertexData, dartData, faceData, rawDartData
, edgeData
, World(..)
, DualOf
-- * Representing edges: Arcs and Darts
, Arc(..)
, Direction(..), rev
, Dart(..), arc, direction
, twin, isPositive
-- * Vertices
, VertexId(..), VertexId'
-- * Building a planar graph
, planarGraph, planarGraph', fromAdjacencyLists
, toAdjacencyLists
, fromAdjRep, toAdjRep
-- , buildFromJSON
-- * Quering a planar graph
, numVertices, numDarts, numEdges, numFaces
, darts', darts, edges', edges, vertices', vertices, faces', faces
, traverseVertices, traverseDarts, traverseFaces
, tailOf, headOf, endPoints
, incidentEdges, incomingEdges, outgoingEdges, neighboursOf
, nextIncidentEdge, prevIncidentEdge
, nextIncidentEdgeFrom, prevIncidentEdgeFrom
-- * Associated Data
, HasDataOf(..), endPointDataOf, endPointData
, dual
-- * Faces
, FaceId(..), FaceId'
, leftFace, rightFace
, boundaryDart, boundary, boundary', boundaryVertices
, nextEdge, prevEdge
) where
import Data.PlanarGraph.Core
import Data.PlanarGraph.Dart
import Data.PlanarGraph.Dual
import Data.PlanarGraph.IO
--------------------------------------------------------------------------------
-- $setup
-- >>> import qualified Data.Vector as V
-- >>> import Control.Lens
-- >>> :{
-- let dart i s = Dart (Arc i) (read s)
-- (aA:aB:aC:aD:aE:aG:_) = take 6 [Arc 0..]
-- myGraph :: PlanarGraph () Primal String String String
-- myGraph = planarGraph [ [ (Dart aA Negative, "a-")
-- , (Dart aC Positive, "c+")
-- , (Dart aB Positive, "b+")
-- , (Dart aA Positive, "a+")
-- ]
-- , [ (Dart aE Negative, "e-")
-- , (Dart aB Negative, "b-")
-- , (Dart aD Negative, "d-")
-- , (Dart aG Positive, "g+")
-- ]
-- , [ (Dart aE Positive, "e+")
-- , (Dart aD Positive, "d+")
-- , (Dart aC Negative, "c-")
-- ]
-- , [ (Dart aG Negative, "g-")
-- ]
-- ] & vertexData .~ V.fromList ["u","v","w","x"]
-- & faceData .~ V.fromList ["f_3", "f_infty","f_1","f_2"]
-- showWithData :: HasDataOf s i => s -> i -> (i, DataOf s i)
-- showWithData g i = (i, g^.dataOf i)
-- :}
--
--
-- This represents the following graph. Note that the graph is undirected, the
-- arrows are just to indicate what the Positive direction of the darts is.
--
-- 
--------------------------------------------------------------------------------
-- Testing stuff
-- testPerm :: Permutation (Dart s)
-- testPerm = let (a:b:c:d:e:g:_) = take 6 [Arc 0..]
-- in toCycleRep 12 [ [ Dart a Negative
-- , Dart c Positive
-- , Dart b Positive
-- , Dart a Positive
-- ]
-- , [ Dart e Negative
-- , Dart b Negative
-- , Dart d Negative
-- , Dart g Positive
-- ]
-- , [ Dart e Positive
-- , Dart d Positive
-- , Dart c Negative
-- ]
-- , [ Dart g Negative
-- ]
-- ]
-- data Test
-- testG :: PlanarGraph Test Primal () String ()
-- testG = planarGraph [ [ (Dart aA Negative, "a-")
-- , (Dart aC Positive, "c+")
-- , (Dart aB Positive, "b+")
-- , (Dart aA Positive, "a+")
-- ]
-- , [ (Dart aE Negative, "e-")
-- , (Dart aB Negative, "b-")
-- , (Dart aD Negative, "d-")
-- , (Dart aG Positive, "g+")
-- ]
-- , [ (Dart aE Positive, "e+")
-- , (Dart aD Positive, "d+")
-- , (Dart aC Negative, "c-")
-- ]
-- , [ (Dart aG Negative, "g-")
-- ]
-- ]
-- where
-- (aA:aB:aC:aD:aE:aG:_) = take 6 [Arc 0..]
--------------------------------------------------------------------------------