You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
igraphs are annoying to check, since they contain weakrefs (pointers to memory addresses of external objects), which are unique each time they are created. That means that check_equal() doesn't work.
Typically, the exercise will ask the student to create a graph from a data frame. This code is taken from ?graph_from_data_frame.
After some experimentation, this is the best set of SCTs I can come up with.
ex() %>% {
check_object(., "g")
check_expr(., 'is_igraph(g)') %>%
check_result() %>%
check_equal(incorrect_msg='Did you use `graph_from_data_frame()` to make `g` into an igraph?')
check_expr(., 'as_data_frame(g)') %>%
check_result() %>%
check_equal(incorrect_msg='Did you use `relations` for the graph edges?')
check_expr(., 'as_data_frame(g, "vertices")') %>%
check_result() %>%
check_equal(incorrect_msg='Did you use `actors` for the graph vertices?')
check_expr(., 'is_directed(g)') %>%
check_result() %>%
check_equal(incorrect_msg='Did you set `directed` to `TRUE`?')
}
Long term, it would be nice to have check_igraph() that wraps this functionality. In the short term, having an example like this in the docs would be helpful.
The text was updated successfully, but these errors were encountered:
igraph
s are annoying to check, since they contain weakrefs (pointers to memory addresses of external objects), which are unique each time they are created. That means thatcheck_equal()
doesn't work.Typically, the exercise will ask the student to create a graph from a data frame. This code is taken from
?graph_from_data_frame
.After some experimentation, this is the best set of SCTs I can come up with.
Long term, it would be nice to have
check_igraph()
that wraps this functionality. In the short term, having an example like this in the docs would be helpful.The text was updated successfully, but these errors were encountered: