These functions operate to help extract certain attributes from given network data. They are also useful as helpers within other functions.

graph_*() functions always relate to the overall graph or network, usually returning a scalar. node_*() and tie_*() always return vectors the same length as the number of nodes or edges in the network, respectively.

node_names(object)

node_mode(object)

node_attribute(object, attribute)

tie_attribute(object, attribute)

tie_weights(object)

tie_signs(object)

graph_nodes(object)

graph_ties(object)

graph_dims(object)

graph_node_attributes(object)

graph_tie_attributes(object)

Arguments

object

An object of a migraph-consistent class:

  • matrix (adjacency or incidence) from {base} R

  • edgelist, a data frame from {base} R or tibble from {tibble}

  • igraph, from the {igraph} package

  • network, from the {network} package

  • tbl_graph, from the {tidygraph} package

attribute

Character string naming an attribute in the object.

Functions

  • node_names: Extracts the names of the nodes in a network.

  • node_mode: Extracts the mode of the nodes in a network.

  • node_attribute: Extracts an attribute's values for the nodes in a network.

  • tie_attribute: Extracts an attribute's values for the edges in a network.

  • tie_weights: Extracts the weights of the edges in a network.

  • tie_signs: Extracts the signs of the edges in a network.

  • graph_nodes: Returns the total number of nodes (of any mode) in a network.

  • graph_ties: Returns the number of edges in a network.

  • graph_dims: Returns the dimensions of a network in a vector as long as the number of modes in the network.

  • graph_node_attributes: Returns a vector of nodal attributes in a network

  • graph_tie_attributes: Returns a vector of edge attributes in a network

See also

Other manipulations: add, as(), reformat, transform()

Examples

node_names(mpn_elite_usa_advice)
#>  [1] "Albright"  "Argyros"   "Armitage"  "Curry"     "Fukuyama"  "Gray"     
#>  [7] "Greenberg" "Hills"     "Kissinger" "Peterson"  "Scowcroft" "Wald"     
#> [13] "West"      "Zakheim"   "ACUS"      "AEI"       "ASPEN"     "CATO"     
#> [19] "CFR"       "CGD"       "CNAS"      "CNI"       "CSIS"      "EWI"      
#> [25] "FPRI"      "GMFUS"     "HOOVER"    "IAD"       "IIE"       "MI"       
#> [31] "NAF"       "RAND"      "RF"        "RFF"      
node_mode(mpn_elite_usa_advice)
#>  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [13] FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
#> [25]  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE
node_attribute(mpn_elite_mex, "full_name")
#>  [1] "Trevino, Jacinto B."        "Madero, Francisco"         
#>  [3] "Carranza, Venustiano"       "Aguilar, Candido"          
#>  [5] "Obregon, Alvaro"            "Calles, Plutarco E."       
#>  [7] "Aleman Gonzalez, Miguel"    "Portes Gil, Emilio"        
#>  [9] "Cardenas, Lazaro"           "Avila Camacho, Manuel"     
#> [11] "Beteta, Ignacio"            "Jara, Heriberto"           
#> [13] "Beteta, Ramon"              "Aleman Valdes, Miguel"     
#> [15] "Sanchez Taboada, Rodolfo"   "Serra Rojas, Andres"       
#> [17] "Ruiz Galindo, Antonio"      "Bustamante, Eduardo"       
#> [19] "Loyo, Gilberto"             "Carvajal, Angel"           
#> [21] "Ruiz Cortines, Adolfo"      "Carrillo Flores, Antonio"  
#> [23] "Ortiz Mena, Antonio"        "Gonzalez Blanco, Salomon"  
#> [25] "Salinas Lozano, Raul"       "Lopez Mateos, Adolfo"      
#> [27] "Margain, Hugo B."           "Diaz Ordaz, Gustavo"       
#> [29] "Beteta, Mario Ramon"        "Echeverria Alvarez, Luis"  
#> [31] "Lopez Portillo, Jose"       "Cardenas, Cuauhtemoc"      
#> [33] "De la Madrid, Miguel"       "Salinas de Gortari, Carlos"
#> [35] "Aleman Velasco, Miguel"    
tie_attribute(ison_algebra, "task_tie")
#> NULL
tie_weights(to_mode1(ison_southern_women))
#>   [1] 6 6 7 3 4 3 3 3 2 2 2 2 2 1 2 1 1 6 6 3 4 4 3 2 2 2 2 2 1 1 1 6 4 4 4 4 3
#>  [38] 3 3 3 2 2 2 2 1 1 4 4 4 3 2 2 2 2 2 1 1 1 2 2 2 1 1 1 1 3 2 2 1 1 1 1 1 1
#>  [75] 1 3 2 2 2 2 2 1 1 1 2 2 2 2 2 2 1 2 1 1 3 3 2 2 2 2 2 1 1 4 3 3 3 3 3 1 1
#> [112] 4 4 3 4 3 1 1 6 5 4 5 1 1 6 6 4 1 1 6 3 2 2 3 1 1 1 1 2
tie_signs(ison_marvel_relationships)
#>   [1] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1  1  1  1 -1 -1 -1  1 -1 -1 -1 -1 -1 -1
#>  [26] -1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
#>  [51]  1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1  1  1  1  1  1  1
#>  [76]  1  1  1  1  1  1  1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1
#> [101]  1  1  1  1  1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1  1 -1 -1 -1 -1  1  1
#> [126]  1  1  1  1  1  1  1  1  1  1  1  1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1
#> [151]  1  1  1  1  1  1  1  1  1  1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1  1  1
#> [176]  1  1  1  1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1  1
#> [201]  1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1  1  1 -1 -1 -1 -1 -1 -1 -1 -1  1
#> [226]  1  1  1  1  1  1  1  1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [251] -1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1  1  1  1  1 -1 -1 -1
#> [276] -1  1  1 -1  1  1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1  1 -1 -1
#> [301]  1 -1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1 -1  1  1  1  1  1  1  1  1  1 -1
#> [326] -1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1  1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [351] -1 -1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1  1  1  1  1  1 -1 -1 -1 -1 -1 -1
#> [376] -1 -1 -1  1  1  1  1  1  1  1  1  1  1  1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1
#> [401]  1  1  1  1  1  1  1  1  1 -1 -1 -1 -1 -1 -1 -1  1  1 -1  1  1 -1 -1 -1 -1
#> [426] -1 -1 -1 -1 -1 -1 -1 -1  1  1 -1 -1  1  1  1  1  1  1 -1 -1 -1  1 -1 -1 -1
#> [451] -1 -1 -1  1  1 -1 -1 -1 -1 -1  1  1  1  1  1  1  1 -1 -1 -1 -1 -1 -1 -1 -1
#> [476] -1 -1 -1  1  1  1  1  1 -1 -1 -1 -1 -1  1  1  1  1  1 -1 -1  1  1  1  1  1
#> [501]  1  1 -1  1  1  1  1 -1  1  1  1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  1  1  1
#> [526] -1 -1 -1 -1  1  1  1  1 -1 -1  1  1  1  1  1 -1 -1 -1  1  1  1 -1 -1 -1 -1
#> [551]  1  1 -1 -1  1 -1  1 -1
graph_nodes(ison_southern_women)
#> [1] 32
graph_ties(ison_southern_women)
#> [1] 93
graph_dims(ison_southern_women)
#> [1] 18 14
graph_dims(to_mode1(ison_southern_women))
#> [1] 18
graph_node_attributes(mpn_elite_mex)
#> [1] "name"         "full_name"    "entry_year"   "military"     "in_mpn"      
#> [6] "PlaceOfBirth" "state"        "region"      
graph_tie_attributes(mpn_elite_mex)
#> character(0)