Remove parts of the graph

remove_edge_attribute(x, attr_name)

remove_edge_weight(x)

remove_vertex_attribute(x, attr_name)

remove_graph_attribute(x, attr_name)

remove_vertex_names(x)

Arguments

x

input graph (class igraph or network)

attr_name

name of the attribute to be removed

Value

graph, without the removed elements

Functions

  • remove_edge_attribute(): remove an edge attribute from the graph

  • remove_edge_weight(): remove an edge weight attribute from the graph. If x is a matrix, this function will dichotomize it by turning every non-zero cell into a 1.

  • remove_vertex_attribute(): remove a vertex attribute from the graph

  • remove_graph_attribute(): remove a graph attribute from the graph

  • remove_vertex_names(): remove vertex names from the graph

Examples

data(emon, package = "network")
texas <- emon$Texas
remove_edge_attribute(texas, "Frequency")
#>  Network attributes:
#>   vertices = 25 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   total edges= 186 
#>     missing edges= 0 
#>     non-missing edges= 186 
#> 
#>  Vertex attribute names: 
#>     Command.Rank.Score Decision.Rank.Score Formalization Location Paid.Staff Sponsorship Volunteer.Staff vertex.names 
#> 
#> No edge attributes
remove_vertex_attribute(texas, "Formalization")
#>  Network attributes:
#>   vertices = 25 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   total edges= 186 
#>     missing edges= 0 
#>     non-missing edges= 186 
#> 
#>  Vertex attribute names: 
#>     Command.Rank.Score Decision.Rank.Score Location Paid.Staff Sponsorship Volunteer.Staff vertex.names 
#> 
#>  Edge attribute names: 
#>     Frequency 
remove_graph_attribute(texas, "directed")
#>  Network attributes:
#>   vertices = 25 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   total edges= 186 
#>     missing edges= 0 
#>     non-missing edges= 186 
#> 
#>  Vertex attribute names: 
#>     Command.Rank.Score Decision.Rank.Score Formalization Location Paid.Staff Sponsorship Volunteer.Staff vertex.names 
#> 
#>  Edge attribute names: 
#>     Frequency 

texas_i <- to_igraph(texas)
remove_edge_attribute(texas_i, "Frequency")
#> IGRAPH dfd4e3c DN-- 25 186 -- 
#> + attr: name (v/c), vertex.names (v/c), Sponsorship (v/c), Paid.Staff
#> | (v/n), Volunteer.Staff (v/n), Location (v/c), Formalization (v/n),
#> | Decision.Rank.Score (v/n), Command.Rank.Score (v/n)
#> + edges from dfd4e3c (vertex names):
#> [1] US.Army.MAST..Ft..Sam.Houston.         ->Texas.Highway.Patrol          
#> [2] US.Army.MAST..Ft..Sam.Houston.         ->Bandera.County.Sheriffs.Office
#> [3] Division.of.Disaster.Emergency.Services->US.Army.MAST..Ft..Sam.Houston.
#> [4] Division.of.Disaster.Emergency.Services->Texas.Highway.Patrol          
#> [5] Division.of.Disaster.Emergency.Services->Texas.State.Parks.and.Wildlife
#> [6] Division.of.Disaster.Emergency.Services->Texas.State.Highway.Department
#> + ... omitted several edges
remove_vertex_attribute(texas_i, "Formalization")
#> IGRAPH dfd4e3c DN-- 25 186 -- 
#> + attr: name (v/c), vertex.names (v/c), Sponsorship (v/c), Paid.Staff
#> | (v/n), Volunteer.Staff (v/n), Location (v/c), Decision.Rank.Score
#> | (v/n), Command.Rank.Score (v/n), Frequency (e/n)
#> + edges from dfd4e3c (vertex names):
#> [1] US.Army.MAST..Ft..Sam.Houston.         ->Texas.Highway.Patrol          
#> [2] US.Army.MAST..Ft..Sam.Houston.         ->Bandera.County.Sheriffs.Office
#> [3] Division.of.Disaster.Emergency.Services->US.Army.MAST..Ft..Sam.Houston.
#> [4] Division.of.Disaster.Emergency.Services->Texas.Highway.Patrol          
#> [5] Division.of.Disaster.Emergency.Services->Texas.State.Parks.and.Wildlife
#> [6] Division.of.Disaster.Emergency.Services->Texas.State.Highway.Department
#> + ... omitted several edges