how-monochromatic-0.1.0.0
Copyright(c) Sebastian Tee 2022
LicenseMIT
Maintainergithub.com/SebTee
Safe HaskellSafe-Inferred
LanguageHaskell2010

BCG

Description

Library for handling bi-coloured graphs

Synopsis

Data Types

data BCG Source #

Bi-Colored Graph

Constructors

BCG 

Fields

Instances

Instances details
Show BCG Source # 
Instance details

Defined in BCG

Methods

showsPrec :: Int -> BCG -> ShowS #

show :: BCG -> String #

showList :: [BCG] -> ShowS #

data BCE Source #

Bi-Coloured Edge

Constructors

BCE 

Fields

Instances

Instances details
Show BCE Source # 
Instance details

Defined in BCG

Methods

showsPrec :: Int -> BCE -> ShowS #

show :: BCE -> String #

showList :: [BCE] -> ShowS #

type IVC = Set (Int, Int) Source #

Inherited Vertex Coloring

type PM = BCG Source #

Perfect Matching

Constructors

empty :: BCG Source #

A BCG with no edges or vertices and the number of different colors is 0

Functions

dist :: BCG -> Double Source #

Return a value between 0 and 1 representing a BCG's distance to the monochromatic \[dist(G) = \begin{cases} 0 & G \text{ has no perfect matchings} \\ \frac{\left|\displaystyle\sum_{c_i \in G,\ c_i\ \text{is monochromatic}} w(c_i)\right|^2}{d\cdot\left(\displaystyle\sum_{c_i \in G} |w(c_i)|^2\right)} & \text{Otherwise} \end{cases}\] Where \(c_i\) is an IVC on \(G\), \(d\) is the number of different colors on \(G\) and \(w(c_i)\) is the colouring weight of \(c_i\).

enumeratePM :: BCG -> [BCG] Source #

Get a list of perfect matchings on a BCG The perfect matchings are represented by the BCG data type

getIncidentEdges :: BCG -> Int -> [BCE] Source #

Get a list of BCEs connected to a vertex

isIncident :: Int -> BCE -> Bool Source #

Determines if a vertex is connected to an BCE

removeEdgeAndIncidentVertices :: BCG -> BCE -> BCG Source #

Removes a BCE from a BCG and the vertices it was incident to

removeVertex :: BCG -> Int -> BCG Source #

Removes a vertex and the connected BCEs from a BCG

removeVertices :: BCG -> [Int] -> BCG Source #

Removes a list of vertices and their connected BCEs from a BCG

isMonochromatic :: PM -> Bool Source #

Checks if all edges on a PM are monochromatic and have the same color

coloringWeight :: [PM] -> Complex Double Source #

Takes a list of PMs with the same IVC and returns the IVC's weight

pmsIvc :: PM -> IVC Source #

Get the IVC of a PM

groupByIvc :: [PM] -> [[PM]] Source #

Groups a list of PM's by IVC

isAdjacent :: BCG -> Int -> Int -> Bool Source #

Check if 2 vertices are adjacent

getAdjacent :: BCG -> Int -> IntSet Source #

Get a set of adjacent nodes

getConnected :: BCG -> Int -> IntSet Source #

get list of vertices connected to a vertex on a BCG

isConnectedGraph :: BCG -> Bool Source #

Determine if a given BCG is a fully connected graph

numberDifferentColors :: BCG -> Int Source #

Counts the number of different colors on a BCG