Macaulay2 » Documentation
Packages » EdgeIdeals :: complementGraph
next | previous | forward | backward | up | index | toc

complementGraph -- returns the complement of a graph or hypergraph

Synopsis

Description

The function complementGraph finds the complement of a graph and hypergraph. Note that this function behaves differently depending upon the type of input. When applied to a graph, complementGraph returns the graph whose edge set is the set of edges not in G. When applied to a hypergraph, the edge set is found by taking the complement of each edge of H in the vertex set.

i1 : R = QQ[a,b,c,d,e];
i2 : c5 = graph {a*b,b*c,c*d,d*e,e*a}; -- graph of the 5-cycle
i3 : complementGraph c5 -- the graph complement of the 5-cycle

o3 = Graph{"edges" => {{a, d}, {a, c}, {b, e}, {b, d}, {c, e}}}
           "ring" => R
           "vertices" => {a, b, c, d, e}

o3 : Graph
i4 : c5hypergraph = hyperGraph c5 -- the 5-cycle, but viewed as a hypergraph

o4 = HyperGraph{"edges" => {{a, b}, {b, c}, {c, d}, {a, e}, {d, e}}}
                "ring" => R
                "vertices" => {a, b, c, d, e}

o4 : HyperGraph
i5 : complementGraph c5hypergraph

o5 = HyperGraph{"edges" => {{c, d, e}, {a, d, e}, {a, b, e}, {b, c, d}, {a, b, c}}}
                "ring" => R
                "vertices" => {a, b, c, d, e}

o5 : HyperGraph

Caveat

Notice that complementGraph works differently on graphs versus hypergraphs.

Ways to use complementGraph :

For the programmer

The object complementGraph is a method function.