Documentation ¶
Overview ¶
Package lib provides various functions, data structures and methods to aid in the design of algorithms to compute structural decomposition methods.
Index ¶
- Variables
- func Diff(a, b []int) []int
- func GetGraph(s string) (Graph, ParseGraph)
- func GetPercentagesSlice(cs []*CombinationIterator) (int, int)
- func IntHash(vertices []int) uint32
- func Inter(as, bs []int) []int
- func PrintVertices(vertices []int) string
- func RemoveDuplicates(elements []int) []int
- func Subset(as []int, bs []int) bool
- type AlgorithmH
- type BalancedCheck
- type Cache
- func (c *Cache) AddNegative(sep Edges, comp Graph)
- func (c *Cache) AddPositive(sep Edges, comp Graph)
- func (c *Cache) CheckNegative(sep Edges, comps []Graph) bool
- func (c *Cache) CheckPositive(sep Edges, comps []Graph) bool
- func (c *Cache) CopyRef(other *Cache)
- func (c *Cache) Init()
- func (c *Cache) Len() int
- func (c *Cache) Reset()
- type CombinationIterator
- type Cover
- type Decomp
- type Edge
- type Edges
- func CutEdges(edges Edges, vertices []int) Edges
- func FilterVertices(edges Edges, vertices []int) Edges
- func FilterVerticesStrict(edges Edges, vertices []int) Edges
- func GetDegreeOrder(edges Edges) Edges
- func GetEdgeDegreeOrder(edges Edges) Edges
- func GetMSCOrder(edges Edges) Edges
- func GetMaxSepOrder(edges Edges) Edges
- func GetSubset(edges Edges, s []int) Edges
- func NewEdges(slice []Edge) Edges
- func (e *Edges) Diff(other Edges) Edges
- func (e Edges) FullString() string
- func (e *Edges) Hash() uint64
- func (e Edges) Len() int
- func (e Edges) Less(i, j int) bool
- func (e *Edges) RemoveDuplicates()
- func (e Edges) Slice() []Edge
- func (e Edges) String() string
- func (e Edges) Swap(i, j int)
- func (e *Edges) Vertices() []int
- type GYÖReduct
- type Graph
- func (g Graph) ComputeSubEdges(K int) Graph
- func (g Graph) GYÖReduct() (Graph, []GYÖReduct)
- func (g Graph) GetBIP() int
- func (g Graph) GetComponents(sep Edges) ([]Graph, map[int]int, []Edge)
- func (g Graph) GetSubset(s []int) Edges
- func (g *Graph) Hash() uint64
- func (g Graph) Len() int
- func (g Graph) String() string
- func (g Graph) ToHyberBenchFormat() string
- func (g Graph) ToPACE() string
- func (g Graph) TypeCollapse() (Graph, map[int][]int, int)
- func (g *Graph) Vertices() []int
- type Hingetree
- type Node
- func (n *Node) CombineNodes(subtree Node, connecting Edges) *Node
- func (n Node) Reroot(child Node) Node
- func (n Node) RerootEdge(edge []int) Node
- func (n Node) RestoreGYÖ(reducts []GYÖReduct) (Node, bool)
- func (n Node) RestoreTypes(restoreMap map[int][]int) (Node, bool)
- func (n Node) String() string
- func (n *Node) Vertices() []int
- type ParentCheck
- type ParseGraph
- type Predicate
- type Search
- type SepSub
Constants ¶
This section is empty.
Variables ¶
var Empty struct{}
Empty used for maps of type struct{}
Functions ¶
func GetGraph ¶
func GetGraph(s string) (Graph, ParseGraph)
GetGraph parses a string in HyperBench format into a graph
func GetPercentagesSlice ¶ added in v1.6.1
func GetPercentagesSlice(cs []*CombinationIterator) (int, int)
GetPercentagesSlice calculates a total percentage from a slice of CombinationIterators
func PrintVertices ¶
PrintVertices will pretty print an int slice using the encodings in the m map
func RemoveDuplicates ¶
RemoveDuplicates is using an algorithm from "SliceTricks" https://github.com/golang/go/wiki/SliceTricks
Types ¶
type AlgorithmH ¶
type AlgorithmH interface { Name() string FindDecomp() Decomp FindDecompGraph(G Graph) Decomp SetWidth(K int) }
AlgorithmH is strict generalisation on the Algorithm interface.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache implements a caching mechanism for generic hypergraph decomposition algorithms
func (*Cache) AddNegative ¶
AddNegative adds a separator sep and subgraph comp as a known failure case
func (*Cache) AddPositive ¶
AddPositive adds a separator sep and subgraph comp as a known successor case TODO: not really used and tested
func (*Cache) CheckNegative ¶
CheckNegative checks for a separator sep and a subgraph whether it is a known failure case
func (*Cache) CheckPositive ¶
CheckPositive checks for a separator sep and a subgraph whether it is a known successor case TODO: not really used and tested
type CombinationIterator ¶
type CombinationIterator struct {
// contains filtered or unexported fields
}
A CombinationIterator generates combinations iteratively.
func SplitCombin ¶
func SplitCombin(n int, k int, split int, unextended bool) []*CombinationIterator
SplitCombin generates multiple iterators, splitting the search space into multiple "splits"
func (CombinationIterator) GetPercentage ¶
func (c CombinationIterator) GetPercentage() float32
GetPercentage returns the current progress as a percentage, with 100% representing that all combinations have been visited
type Cover ¶
type Cover struct { InComp []bool //indicates for each Edge if its in comp. or not Subset []int //The current selection HasNext bool // contains filtered or unexported fields }
Cover is used to quickly iterate over all valid hypergraph covers for a subset of vertices
func (*Cover) NextSubset ¶
NextSubset returns number of selected edges, or -1 if no alternative possible
type Decomp ¶
A Decomp (short for Decomposition) consists of a labelled tree which subdivides a graph in a certain way
func GetDecompGML ¶
GetDecompGML can parse an input string in GML format to produce a decomp
func (Decomp) CheckWidth ¶
CheckWidth returns the size of the largest bag of any node in a decomp
func (Decomp) Correct ¶
Correct checks if a decomp full fills the properties of a GHD when given a hypergraph g as input. It also checks for the special condition of HDs, though it merely prints a warning if it is not satisfied, the output is not affected by this additional check.
func (*Decomp) RestoreSubedges ¶
func (d *Decomp) RestoreSubedges()
RestoreSubedges replaces any ad-hoc subedge with actual edges occurring in the graph
type Edge ¶
An Edge (used here for hyperedge) consists of a collection of vertices and a name
func (Edge) FullString ¶
FullString always prints the list of vertices of an edge, even if the edge is named
func (Edge) FullStringInt ¶ added in v1.5.7
FullStringInt always prints the list of vertices of an edge, even if the edge is named
type Edges ¶
type Edges struct {
// contains filtered or unexported fields
}
Edges struct is a slice of Edge, defined for the use of the sort interface, as well as various other optimisations which are only possible on the slice level
func CutEdges ¶
CutEdges filters an Edges slice for a given set of vertices. Edges are transformed to their intersection against the vertex set, producing the induced subgraph
func FilterVertices ¶
FilterVertices filters an Edges slice for a given set of vertices. Edges are only removed, if they have an empty intersection with the vertex set.
func FilterVerticesStrict ¶
FilterVerticesStrict filters an Edges slice for a given set of vertices. Edges are removed if they are not full subsets of the vertex set
func GetDegreeOrder ¶
GetDegreeOrder orders the edges based on the sum of the vertex degrees
func GetEdgeDegreeOrder ¶
GetEdgeDegreeOrder orders the edges based on the sum of the edge degrees
func GetMSCOrder ¶
GetMSCOrder produces the Maximal Cardinality Search Ordering. Implementation is based det-k-decomp of Samer and Gottlob '09
func GetMaxSepOrder ¶
GetMaxSepOrder orders the edges by how much they increase shortest paths within the hypergraph, using basic Floyd-Warschall (using the primal graph)
func GetSubset ¶
GetSubset produces a selection of edges from slice of integers s used as indices. This is used to select new potential separators. Note that special edges are ignored here, since they should never be considered when choosing a separator
func (Edges) FullString ¶
FullString always prints the list of vertices of an edge, even if named
func (*Edges) Hash ¶
Hash computes a (non-cryptographic) hash. This hash is the same for all permutations of edges
func (*Edges) RemoveDuplicates ¶
func (e *Edges) RemoveDuplicates()
RemoveDuplicates removes duplicate edges from an Edges struct
type GYÖReduct ¶
type GYÖReduct interface {
// contains filtered or unexported methods
}
A GYÖReduct (that's short for GYÖ (Graham - Yu - Özsoyoğlu) Reduction ) consists of a list of operations that simplify a graph by 1) removing isolated vertices or 2) removing edges fully contained in other edges (and applying these two operations iteratively, until convergence)
type Graph ¶
A Graph is a collection of (special) edges
func GetGraphPACE ¶
GetGraphPACE parses a string in PACE 2019 format into a graph
func (Graph) ComputeSubEdges ¶
ComputeSubEdges computes all relevant subedges to produce a GHD of width K
func (Graph) GetComponents ¶
GetComponents uses Disjoint Set data structure to compute connected components
func (Graph) GetSubset ¶
GetSubset is as above, but the first parameter is omitted when used as the method call of a graph
func (*Graph) Hash ¶
Hash computes a (non-cryptographic) hash. This hash is the same for all permutations of edges
func (Graph) ToHyberBenchFormat ¶ added in v1.5.7
ToHyberBenchFormat transforms the graph structure to a string in HyperBench Format. This is only relevant for generated instances with no existing string representation. Using this with a parsed graph is not the target use case, only used for internal testing
func (Graph) TypeCollapse ¶
TypeCollapse performs type collapse on the graph, the mapping that's also output can be used to restore the original hypergraph.
Possible optimization: When computing the distances, use the matrix to speed up type detection
type Hingetree ¶
type Hingetree struct {
// contains filtered or unexported fields
}
A Hingetree is a tree with each node representing a subgraph and its respective decomposition and connected by exactly one edge, which is the sole intersection between the two graphs of its connecting nodes
func GetHingeTree ¶
GetHingeTree produces a hingetree for a given graph
func (Hingetree) DecompHinge ¶
func (h Hingetree) DecompHinge(alg AlgorithmH, g Graph) Decomp
DecompHinge computes a decomposition of the original input graph, using the hingetree to speed up the computation
func (Hingetree) GetLargestGraph ¶
GetLargestGraph returns the largest graph within the hinge tree
type Node ¶
type Node struct { Bag []int Cover Edges Children []Node // contains filtered or unexported fields }
A Node is the root of a labelled tree, where the labels are the bag and the (edge) cover
func (*Node) CombineNodes ¶
CombineNodes attaches subtree to n, via the connecting special edge
func (Node) RerootEdge ¶
RerootEdge reroots G at node covering edge, producing an isomorphic graph
func (Node) RestoreGYÖ ¶
RestoreGYÖ can restore any performed reductions on the graph, given a slice of reducts
func (Node) RestoreTypes ¶
RestoreTypes can restore any performed Type reductions given a mapping of the reductions
type ParentCheck ¶
ParentCheck looks a separator that could function as the direct ancestor (or "parent") of some child node in the GHD, where the connecting vertices "Conn" are explicitly provided
type ParseGraph ¶
ParseGraph contains data used to parse a graph, potentially useful for testing
func (*ParseGraph) GetEdge ¶
func (p *ParseGraph) GetEdge(input string) Edge
GetEdge can be used parse additional hyperedges. Useful for testing purposes
type Search ¶
type Search struct { H *Graph Edges *Edges BalFactor int Result []int Generators []*CombinationIterator ExhaustedSearch bool }
A Search implements a parallel search for separators fulfilling some given predicate