Remove singleton-pairs from graph visualisation?

Looking for input on how to remove singleton-pairs, when visualising a graph using ggraph?

I.e remove all o-o, but keep o-o-o-... :thinking:

Okay, I'm going to take the liberty to come up with my solution. Instead of looking at the graph, pre-filtering the data like so will do the trick:

> d = tibble(
+   x = c("A", "B", "C", "D", "D"),
+   y = c("G", "H", "H", "J", "K")
+ )
> d
# A tibble: 5 x 2
  x     y    
  <chr> <chr>
1 A     G    
2 B     H    
3 C     H    
4 D     J    
5 D     K    
> d %>% full_join(count(d, x), by = "x") %>% full_join(count(d, y), by = "y")
# A tibble: 5 x 4
  x     y       n.x   n.y
  <chr> <chr> <int> <int>
1 A     G         1     1
2 B     H         1     2
3 C     H         1     2
4 D     J         2     1
5 D     K         2     1
> d %>% full_join(count(d, x), by = "x") %>% full_join(count(d, y), by = "y") %>% filter(!(n.x == 1 & n.y == 1))
# A tibble: 4 x 4
  x     y       n.x   n.y
  <chr> <chr> <int> <int>
1 B     H         1     2
2 C     H         1     2
3 D     J         2     1
4 D     K         2     1
> d %>% full_join(count(d, x), by = "x") %>% full_join(count(d, y), by = "y") %>% filter(!(n.x == 1 & n.y == 1)) %>% select(-n.x, -n.y)
# A tibble: 4 x 2
  x     y    
  <chr> <chr>
1 B     H    
2 C     H    
3 D     J    
4 D     K    

No exactly "simple", but it does seem to get the trick done - Open for more elegant solutions :thinking:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.