Thanks to visit codestin.com
Credit goes to github.com

Skip to content

geom_edge_link doesn't handle graphs without edges. #76

@mailund

Description

@mailund

For the special case where a graph doesn't have any edges, calling geom_edge_link. For example, with a simple graph with three nodes and no edges, you can plot it if you do not call geom_edge_link():

graph <- list(nodes = tibble(1:3), 
              edges = tibble(from = vector("numeric"), 
                             to = vector("numeric")))

tbl_graph(graph$nodes, graph$edges) %>% 
  ggraph(layout = "tree") + 
  geom_node_point() +
  theme_graph()

The result isn't that exciting, it is just three dots, but here it is:

screen shot 2017-07-12 at 17 34 26

If you then also call geom_edge_link, you get an error:

tbl_graph(graph$nodes, graph$edges) %>% 
  ggraph(layout = "tree") + 
  geom_node_point() +
  geom_edge_link() +
  theme_graph()
Error in `$<-.data.frame`(`*tmp*`, "circular", value = FALSE) : 
  replacement has 1 row, data has 0

I would expect it to just not draw any edges.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions