# pick a small data set and create preference and BTG
df <- mtcars[1:10,]
pref <- high(mpg) * low(wt)
# directly plot the BTG with row numbers as labels
plot_btg(df, pref)
# create the BTG and labels for the nodes with relevant values
btg <- get_btg(df, pref)
labels <- paste0(df$mpg, "\n", df$wt)
# plot the graph using igraph
library(igraph)
plot(btg$graph, layout = btg$layout, vertex.label = labels,
vertex.size = 25)
# add colors for the maxima nodes and plot again
colors <- rep(rgb(1, 1, 1), nrow(df))
colors[psel.indices(df, pref)] <- rgb(0,1,0)
plot(btg$graph, layout = btg$layout, vertex.label = labels,
vertex.size = 25, vertex.color = colors)
# show lattice structure of 3-dimensional Pareto preference
df <- merge(merge(data.frame(x = 1:3), data.frame(y = 1:3)), data.frame(z = 1:2))
labels <- paste0(df$x, ",", df$y, ",", df$z)
btg <- get_btg(df, low(x) * low(y) * low(z))
plot(btg$graph, layout = btg$layout, vertex.label = labels,
vertex.size = 20)
Run the code above in your browser using DataLab