
These functions allow users to add attributes to a graph from another graph or from a specified vector supplied by the user.
add_node_attributes(object, attr_name, vector)add_edge_attributes(object, attr_name, vector)
copy_node_attributes(object, object2)
join_edges(object, object2, attr_name)
An object of a migraph-consistent class:
matrix, 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
Name of the new attribute in the resulting object.
A vector of values for the new attribute.
A second object to copy nodes or edges from.
add_node_attributes
: Insert specified values from a vector into the graph
as node attributes
add_edge_attributes
: Insert specified values from a vector into the graph
as edge attributes
copy_node_attributes
: Copies node attributes from a given graph into specified graph
join_edges
: Copies edges from another graph to specified graph and
adds an edge attribute identifying the edges that were newly added
# NOT RUN {
add_node_attributes(mpn_elite_mex, "wealth", 1:35)
add_node_attributes(mpn_elite_usa_advice, "wealth", 1:14)
add_edge_attributes(ison_adolescents, "weight", c(1,2,1,1,1,3,2,2,3,1))
autographr(mpn_elite_mex)
both <- join_edges(mpn_elite_mex, generate_random(mpn_elite_mex), "random")
autographr(both)
random <- to_uniplex(both, "random")
autographr(random)
autographr(to_uniplex(both, "orig"))
# }
Run the code above in your browser using DataLab