The "giant component" of a graph is defined as the component of the largest order (i.e. most number of nodes)
get_giant_component(gr) rm_giant_component(gr)
gr | tidygraph object |
---|
the giant component of the input tidygraph object or all components except for the giant component
gr_large <- quick_forestfire(10, name = LETTERS) gr_small <- quick_forestfire(5, name = letters) gr <- tidygraph::bind_graphs(gr_large, gr_small) gr#> # A tbl_graph: 15 nodes and 28 edges #> # #> # A directed acyclic simple graph with 2 components #> # #> # Node Data: 15 x 1 (active) #> name #> <chr> #> 1 A #> 2 B #> 3 C #> 4 D #> 5 E #> 6 F #> # … with 9 more rows #> # #> # Edge Data: 28 x 2 #> from to #> <int> <int> #> 1 1 2 #> 2 1 3 #> 3 2 3 #> # … with 25 more rowsget_giant_component(gr)#> # A tbl_graph: 10 nodes and 21 edges #> # #> # A directed acyclic simple graph with 1 component #> # #> # Node Data: 10 x 1 (active) #> name #> <chr> #> 1 A #> 2 B #> 3 C #> 4 D #> 5 E #> 6 F #> # … with 4 more rows #> # #> # Edge Data: 21 x 2 #> from to #> <int> <int> #> 1 1 2 #> 2 1 3 #> 3 2 3 #> # … with 18 more rowsrm_giant_component(gr)#> # A tbl_graph: 5 nodes and 7 edges #> # #> # A directed acyclic simple graph with 1 component #> # #> # Node Data: 5 x 1 (active) #> name #> <chr> #> 1 a #> 2 b #> 3 c #> 4 d #> 5 e #> # #> # Edge Data: 7 x 2 #> from to #> <int> <int> #> 1 1 2 #> 2 2 3 #> 3 1 3 #> # … with 4 more rows