This repository contains some algorithms for generating, recognizing, and solving problems on chordal graphs in Go.
The following algorithms are contained:
- Algorithms for random graph generation (file randomgraph.go)
- Algorithms for random interval graph generation. Recall that interval graphs are chordal. (file randomintervalgraph.go)
- A struct to represent chordal graphs by a graph and a perfect elimination scheme (file chordalgraph.go)
- Algorithms for solving problems on chordal graphs. Contains Clique, Clique Cover, Independent Set, Coloring. (file algorithms.go)
- Algorithms for chordal graph recognition, i.e. LexBFS and checking whether a given ordering is a perfect elimination scheme (files chordalgraph.go and lexbfs.go)
First, generate a random interval graph:
graph := RandomIntervalGraph(n,20*n,seed)
Then, run a LexBFS on it to determine a (candidate) perfect elimation scheme:
order := LexBFS(graph)
Next, parse the order into a chordal graph structure. Then check whether this is really a perfect elimination scheme (thereby checking whether the graph is chordal):
cg := ChordalGraphFromGraphAndPES(graph, order)
IsValid(cg)
Run an algorithm on it, e.g. determine (the leftmost vertex of) a maximum clique:
v := Clique(cg)