| Copyright | (c) Marcelo Garlet Milani 2026 |
|---|---|
| License | MIT |
| Maintainer | mgmilani@pm.me |
| Stability | stable |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Nauty
Contents
Description
This module functions for encoding and decoding graphs in any of the supported formats.
In particular, encodeMany is capable of using the incremental sparse6 format as well.
If you want instead to work with a specific format, use Nauty.Graph6, Nauty.Sparse6 or Nauty.Digraph6 instead.
Synopsis
- data Graph = Graph {}
- data GraphType
- edgeExists :: Graph -> Word64 -> Word64 -> Bool
- toEdgeList :: Graph -> (Word64, [(Word64, Word64)])
- data Format
- = Graph6
- | Sparse6
- | Digraph6
- | Incremental
- parse :: Text -> [Either Text Graph]
- parse' :: Maybe Graph -> [Text] -> [Either Text Graph]
- encode :: Graph -> Text
- encodeMany :: [Graph] -> Text
- encodeMany' :: Maybe Graph -> [Graph] -> [Text]
Graph structure
A directed or undirected graph. See nauty documentation for an explanation of the format used by the adjacency matrix.
Constructors
| Graph | |
Fields
| |
Arguments
| :: Graph | |
| -> Word64 | From vertex in directed graphs. |
| -> Word64 | To vertex in directed graphs. |
| -> Bool |
Whether the graph contains and edge between two vertices. In digraph6 format, the edge is a directed edge from the first to the second vertex.
toEdgeList :: Graph -> (Word64, [(Word64, Word64)]) Source #
The number of vertices and the list of (potentially directed) edges of a graph.
Parsing
Format in used for encoding and decoding.
Constructors
| Graph6 | |
| Sparse6 | |
| Digraph6 | |
| Incremental |
parse :: Text -> [Either Text Graph] Source #
Parse a list of graphs encoded in graph6, sparse6 or digraph6 format. Each line encodes one graph.
Optionally, the first line might be a header of the form >>graph6<<, >>sparse6<< or >>digraph6<<.
Arguments
| :: Maybe Graph | Used in case the first graph of the list uses incremental sparse6 format. |
| -> [Text] | |
| -> [Either Text Graph] |
Parse a list of graphs in graph6, digraph6, sparse6 or incremental sparse6 format.
Encoding
encode :: Graph -> Text Source #
Encode a graph using the format given by the format field.
Graphs with the Incremental format are encoded using sparse6.
encodeMany :: [Graph] -> Text Source #
Encode a sequence of graphs using the given formats. Graphs may be encoded with the incremental format, but only if the previous graph is encoded with sparse6.
Arguments
| :: Maybe Graph | Used as a predecessor in case the first graph of the list is to be encoded in incremental sparse6 format. |
| -> [Graph] | |
| -> [Text] |
Encode a sequence of graphs using the given formats. Graphs may be encoded with the incremental format, but only if the previous graph is encoded with sparse6.