toysolver-0.9.0: Assorted decision procedures for SAT, SMT, Max-SAT, PB, MIP, etc
Copyright(c) Masahiro Sakai 2020
LicenseBSD-style
Maintainermasahiro.sakai@gmail.com
Stabilityprovisional
Portabilitynon-portable
Safe HaskellSafe-Inferred
LanguageHaskell2010

ToySolver.Graph.Base

Description

 
Synopsis

Graph data types

type EdgeLabeledGraph a = Array Vertex (IntMap a) Source #

Labelled directed graph without multiple edges

We also represent undirected graphs as symmetric directed graphs.

type Graph = EdgeLabeledGraph () Source #

Directed graph without multiple edges

We also represent undirected graphs as symmetric directed graphs.

type Vertex = Int Source #

Vertex data type

type VertexSet = IntSet Source #

Set of vertexes

type Edge a = (Vertex, Vertex, a) Source #

Edge data type

Conversion

Directed graphs

graphFromEdges :: HasCallStack => Int -> [Edge a] -> EdgeLabeledGraph a Source #

Construct a directed graph from edges.

If there are multiple edges with the same starting and ending vertexes, the last label is used.

graphFromEdgesWith :: HasCallStack => (a -> a -> a) -> Int -> [Edge a] -> EdgeLabeledGraph a Source #

Construct a directed graph from edges.

If there are multiple edges with the same starting and ending vertexes, the labels are combined using the given function.

graphToEdges :: EdgeLabeledGraph a -> [Edge a] Source #

Set of edges of directed graph

Undirected graphs

graphFromUnorderedEdges :: HasCallStack => Int -> [Edge a] -> EdgeLabeledGraph a Source #

Construct a symmetric directed graph from unordered edges.

If there are multiple edges with the same starting and ending vertexes, the last label is used.

graphFromUnorderedEdgesWith :: HasCallStack => (a -> a -> a) -> Int -> [Edge a] -> EdgeLabeledGraph a Source #

Construct a symmetric directed graph from unordered edges.

If there are multiple edges with the same starting and ending vertexes, the labels are combined using the given function.

graphToUnorderedEdges :: EdgeLabeledGraph a -> [Edge a] Source #

Set of edges of undirected graph represented as a symmetric directed graph.

Operations

converseGraph :: EdgeLabeledGraph a -> EdgeLabeledGraph a Source #

Converse of a graph.

It returns another directed graph on the same set of vertices with all of the edges reversed. This is also called transpose or reverse of a graph.

complementGraph :: EdgeLabeledGraph a -> EdgeLabeledGraph () Source #

Complement of a graph

Note that applying it to a graph with no self-loops results in a graph with self-loops on all vertices.

complementSimpleGraph :: EdgeLabeledGraph a -> EdgeLabeledGraph () Source #

Complement of a simple graph

It ignores self-loops in the input graph and also does not add self-loops to the output graph.

Properties

numVertexes :: EdgeLabeledGraph a -> Int Source #

Number of vertexes of a graph

isSimpleGraph :: EdgeLabeledGraph a -> Bool Source #

A graph is simple if it contains no self-loops.

isIndependentSet :: EdgeLabeledGraph a -> VertexSet -> Bool Source #

Deprecated: Use isIndependentSetOf instead

Alias of isIndependentSetOf

isIndependentSetOf :: VertexSet -> EdgeLabeledGraph a -> Bool Source #

An independent set of a graph is a set of vertices such that no two vertices in the set are adjacent.

This function ignores self-loops in the input graph.

isCliqueOf :: VertexSet -> EdgeLabeledGraph a -> Bool Source #

A clique of a graph is a subset of vertices such that every two distinct vertices in the clique are adjacent.