View source: R/11-grafos-NPdif.R
plot_cover | R Documentation |
Plot of a vertex cover in a graph.
plot_cover(X, G)
X |
Cover to be plotted; an output list returned by some cover-building function, see below. |
G |
Graph on which to superimpose the cover. |
It plots a graph, then superimposes a vertex cover in a different color. It also draws the covered edges, to help in detecting non-covers by inspection.
This function is called for its side effect of plotting.
Cesar Asensio
is_cover checks if a vertex subset is a vertex cover, build_cover_greedy builds a cover using a greedy heuristic, build_cover_approx builds a cover using a 2-approximation algorithm, improve_cover_flip improves a cover using local search, search_cover_random looks for a random cover of fixed size, search_cover_ants looks for a random cover using a version of the ant-colony optimization heuristic, find_cover_BB finds covers using a branch-and-bound technique.
set.seed(1)
g <- sample_gnp(25, p=0.25) # Random graph
X1 <- build_cover_greedy(g)
plot_cover(X1, g)
st <- 1:5 # Not a vertex cover
plot_cover(list(set = st, size = length(st)), g) # See covered edges
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.