The SimpleGraphRepresentations
module is an extension of
SimpleGraphs
. It provides methods for dealing with intersection
graphs and the like.
This module requires the Plots
, GR
,
SimpleGraphs
, ClosedIntervals
, and
Permutations
modules.
The functions in this module deal with the following types of graphs:
- Interval graphs (and interval digraphs)
- Permutation graphs
- Cographs
- Threshold graphs
- Tolerance graphs
- Geometric graphs
- Circle graphs
- Intersection graphs (of finite sets)
We provide the following functions for creating interval graphs and interval digraphs.
-
IntervalGraph(Jlist)
creates an interval graph from a list of closed intervals. The vertices are numbered1
ton
(wheren
is the length ofJlist
). -
IntervalGraph(f)
wheref
is a dictionary mapping vertex names to closed intervals creates an interval graph. -
RandomIntervalGraph(n)
creates a randomn
-vertex interval graph.
-
UnitIntervalGraph(x,t)
creates a unit interval graph in which the left end points of the intervals are given in the vectorx
and the lengths of the intervals ist
. -
UnitIntervalGraph(f,t)
creates a unit interval graph from a dictionaryf
mapping vertex names to the left end points of the intervals. The optional parametert
gives the length of the intervals. -
RandomUnitIntervalGraph(n,t)
creates a random unit interval graph in which the left end points aren
iid uniform values in [0,1] andt
is the length of the intervals. -
UnitIntervalGraphEvolution(pts)
gives the sequence of edges add as the lengths of the intervals (whose left end points are given inpts
) increases. This returns a pair consisting of the sequence of edges and the lengths at which those edges appear. -
UnitIntervalGraphEvolution(n::Int)
is equivalent toUnitIntervalGraphEvolution(sort(rand(n)))
.
-
IntervalDigraph1(Jlist)
creates a type I interval digraph from a list of intervals. -
IntervalDigraph(f)
wheref
is a dictionary mapping vertex names to closed intervals creates a type I interval digraph. -
RandomIntervalDigraph1(n)
creates a random type I interval digraph withn
vertices.
-
IntervalDigraph2(snd_list, rec_list)
creates a type II interval digraph from two lists of intervals. -
IntervalDigraph2(s,r)
creates a type II interval digraph wheres
andr
are dictionaries mapping a set of vertices to closed intervals. -
RandomIntervalDigraph2(n)
creates ann
-vertex random type II interval digraph.
Create permutation graphs from one or two Permutation
objects.
-
PermutationGraph(p,q)
creates a permutation graph in which there is an edge fromu
tov
iff(p[u]-p[v])*(q[u]-q[v])<0
. -
PermutationGraph(p)
is equivalent toPermutationGraph(p,id)
whereid
is the identity permutation. -
PermutationGraph(d)
whered
is aDict
creates a permutation graph whose vertices are the keys ind
. The values ind
should be pairs of numbers. That is,d
's type should beDict{Vtype, Tuple{R1,R2}}
whereVtype
is the type of the vertices andR1
andR2
are subtypes ofReal
. -
PermutationGraph(f,g)
wheref
andg
areDict
s mapping a vertex set to real values. -
RandomPermutationGraph(n)
creates ann
-vertex random permutation graph. -
PermutationRepresentation(G)
creates a pair of dictionaries from the vertex set ofG
to integers. These mappings are a permutation representation ofG
.
Note: We include an extra file in the src
directory entitled
PermutationRepresentationDrawing
that includes code for
visualizing permutation representations of graphs.
Sample output for one is shown here:
This code required Plots
.
A cograph (also called a complement reducible graph) is formed from single vertex graphs via the operations join and disjoint union. We provide the following functions:
RandomCograph(vlist)
creates a random cograph whose vertices are the elements ofvlist
.RandomCograph(n)
creates a random cograph whose vertices are1:n
.is_cograph(G)
determines whetherG
is a cograph.CographRepresentation(G)
returns aString
showing the construction ofG
as a cograph.
-
ThresholdGraph(wts)
creates a threshold graph from a list of weights. Vertices are named1:n
wheren=length(wts)
. -
ThresholdGraph(f)
creates a threshold graph from a dictionary mapping vertex names to weights. -
RandomThresholdGraph(n)
creates a random threshold graph with vertices named1:n
with IID uniform [0,1] weights. -
CreationSequence(G)
returns the creation sequence of a threshold graph (or raises an error ifG
is not threshold). This returns a pair(seq,vtcs)
whereseq
is the creation sequence andvtcs
is a listing of the vertices in the order in which they should be added. -
ThresholdRepresentation(G)
returns a threshold representation ofG
(or raises an error ifG
is not threshold). This returns a dictionary mapping the vertices ofG
to weights (of typeRational
).
-
IntersectionGraph(setlist)
creates an intersection graph from a list of sets (all of typeSet
or all of typeIntSet
). Vertices are named1:n
wheren
is the length of the list of sets. -
IntersectionGraph(f)
creates an intersection graph from a dictionary mapping vertex names to sets. -
IntersectionRepresentation(G,k)
creates an intersection representation ofG
using subsets of{1,2,...,k}
. Returns a dictionary mapping vertices ofG
to sets. -
IntersectionNumber(G)
returns the intersection number ofG
. Warning: This can be very slow. UseIntersectionNumber(G,false)
to supress some diagnostic output.
A geometric graph is a graph whose vertices are represented by points in a metric space (for our purposes, Euclidean space) in which a pair of vertices forms an edge iff the distance between their points is at most 1 (or some other specified value).
-
GeometricGraph(A)
whereA
is anm
byn
matrix creates a geometric graph in which the columns ofA
are the points representing the vertices1:n
. Two vertices are adjacent iff the distance between the points is at most 1 (or an optional second parameter,d
). -
GeometricGraph(f)
wheref
is aDict
mapping vertex names to vectors creates a geometric graph in which two vertices are adjacent iff distance between their points is at most 1 (ord
if given as a second argument). -
RandomGeometricGraph(n::Int, dim::Int=2, d::Real=1)
creates a random geometric graph by generatingn
points at random in the unitdim
-cube. Vertices are adjacent if their corresponding points are at distance at mostd
.
A tolerance graph is a graph whose vertices are represented by a pair consisting of a closed interval and a real tolerance. Two vertices are adjacent if the length of the intersection of their intervals exceeds either tolerance.
-
ToleranceGraph(Jlist, tlist)
creates a tolerance graph with vertex set1:n
whereJlist
is ann
-long list of closed intervals andtlist
is ann
-long list of real tolerances. -
ToleranceGraph(f)
wheref
is aDict
creates a tolerance graph wheref
maps vertex names to pairs(J,t)
whereJ
is a closed interval andt
is a real tolerance. For example:f = Dict{ASCIIString, Tuple{ClosedInterval{Int},Float64}}() f["alpha"] = ( ClosedInterval(3,6), 0.2 )
A circle graph is the intersection graph of the chords of a circle. We provide the following:
-
CircleGraph(list)
creates a circle graph wherelist
is a list of elements each of which appears exactly twice. Here, list is typically anArray
but may also be anASCIIString
. -
RandomCircleGraph(n)
creates a random circle graph with vertex set1:n
.
This representation drawing was created with CircleRepresentationDrawing
.
See also RainbowDrawing
.
CircleGraphRepresentation(G)
returns a circle graph representation of the graphG
(or throws an error if the graph is not a circle graph). The current implementation works but is slow. New one is in the works.
Thanks to Tara Abrishami for contributing these functions:
CreationSequence
ThresholdRepresentation
PermutationRepresentation
CircleGraphRepresentation