# Pick a small data set and create preference / BTG
df <- mtcars[1:10,]
pref <- high(mpg) * high(hp)
btg <- get_btg(df, pref)
# Create labels for the nodes with relevant values
labels <- paste0(df$mpg, "\n", df$hp)
# 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(list(x = 1:3), list(y = 1:3)), list(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