## 5.3 Nodes, Edges and Graphs

POs are combined into Graph s. The manual way (= hard way) to construct a Graph is to create an empty one first, fill it with POs, and then connect edges between the POs. POs are identified by their $id. Note that the operations all modify the object in-place and return the object itself, so multiple modifications can be chained. For this example we use the “pca” PO defined above and a new PO named “mutate”. The latter creates a new feature from existing variables. mutate = mlr_pipeops$get("mutate")
graph = Graph$new()$
add_pipeop(mutate)$add_pipeop(filter)$
add_edge("mutate", "variance")  # add connection mutate -> filter

The much quicker way is to use the %>>% operator to chain POs or Graph s. The same result as above can be achieved by doing

graph = mutate %>>% filter

Now the Graph can be inspected using its $plot() function: graph$plot(html = TRUE) %>% visInteraction(zoomView = FALSE) # disable zoom

Chaining multiple POs of the same kind

If multiple POs of the same kind should be chained it is necessary to change the id to avoid name clashes. This can be done by either accessing the $id slot or during construction. graph$add_pipeop(mlr_pipeops$get("pca")) graph$add_pipeop(mlr_pipeops\$get("pca", id = "pca2"))