Print the graph object
snafun
snafun :: print ( x )
igraph
igraph :: print.igraph ( x )
network
network :: print.network ( x )
Check characteristics of the graph object
snafun
snafun :: has_edge_attributes ( x )
snafun :: has_vertex_attributes ( x )
snafun :: has_vertex_attribute ( x , attrname )
snafun :: has_edge_attribute ( x , attrname )
snafun :: has_vertexnames ( x )
snafun :: has_loops ( x )
snafun :: is_bipartite ( x )
snafun :: is_connected ( x , rule = c ( "weak" , "strong" ) )
snafun :: is_directed ( x )
snafun :: is_network ( x )
snafun :: is_igraph ( x )
snafun :: is_signed ( x )
snafun :: is_weighted ( x )
igraph
# various functions, including
igraph :: any_loop ( g )
igraph :: any_multiple ( g )
igraph :: is_bipartite ( graph )
igraph :: is_connected ( graph , mode = c ( "weak" , "strong" ) )
igraph :: is_directed ( graph )
igraph :: is_igraph ( graph )
igraph :: is_named ( graph )
igraph :: is_simple ( graph )
igraph :: is_weighted ( graph )
network
# various functions, including:
network :: has.loops ( x )
network :: is.bipartite ( x )
network :: is.directed ( x )
network :: is.multiplex ( x )
network :: is.network ( x )
sna :: is.connected ( g , connected = "strong" )
Access the vertices and edges
snafun
—
igraph
igraph :: V ( x ) # vertices
igraph :: E ( x ) # edges
network
—
snafun
snafun :: extract_vertex_attribute ( x , name )
snafun :: extract_vertex_names ( x ) # specific to access the vertex names attribute
snafun :: extract_edge_attribute ( x , name )
snafun :: extract_graph_attribute ( x , name )
igraph
igraph::vertex_attr(graph, name, index = V(graph))
igraph::V(graph)
a t t r i b u t e n a m e i g r a p h : : e d g e a t t r ( g r a p h , n a m e , i n d e x = E ( g r a p h ) ) i g r a p h : : E ( g r a p h ) attributename
igraph::edge_attr(graph, name, index = E(graph))
igraph::E(graph) a tt r ib u t e nam e i g r a p h :: e d g e a tt r ( g r a p h , nam e , in d e x = E ( g r a p h )) i g r a p h :: E ( g r a p h ) attributename
igraph::graph_attr(graph, name)
network
network :: get.vertex.attribute ( x , attrname )
network :: get.edge.attribute ( x , attrname )
network :: get.network.attribute ( x , attrname )
igraph
—
network
—
snafun
snafun :: extract_edge_id ( object , ego , alter , edgelist )
snafun
snafun :: extract_vertex_names ( x )
igraph
igraph :: V ( x ) $ name
igraph :: vertex_attr ( x , name = "names" )
network
network :: get.vertex.attribute ( x , "vertex.names" )
network :: network.vertex.names ( x )
set vertex names
snafun
snafun :: add_vertex_names ( x , value )
igraph
igraph :: V ( x ) $ name <- value
igraph :: set_vertex_attr ( x , name = "names" )
network
network :: set.vertex.attr ( x , "vertex.names" , value )
network :: network.vertex.names ( x ) <- value
List vertex / edge / graph attributes
snafun
snafun :: list_vertex_attribute ( x , name )
snafun :: list_edge_attribute ( x , name )
snafun :: list_graph_attribute ( x , name )
igraph
igraph :: vertex_attr_names ( graph )
igraph :: edge_attr_names ( graph )
igraph :: graph_attr_names ( graph )
network
network::list.vertex.attributes(x)
network::list.edge.attributes(x
network::list.network.attributes(x)
snafun
snafun :: extract_all_vertex_attributes ( g )
igraph
—
network
—
Add vertex / edge / graph attributes
snafun
# very flexible and powerful functions to add attributes
# in several ways, with the same function
snafun :: add_edge_attributes ( object , attr_name , value , edgelist , overwrite = FALSE )
snafun :: add_vertex_attributes ( x , attr_name = NULL , value )
snafun :: add_graph_attribute ( x , attr_name = NULL , value )
igraph
igraph::set_edge_attr(g, "name", value)
igraph::E(g)
n a m e < − v a l u e i g r a p h : : s e t v e r t e x a t t r ( g , " n a m e " , v a l u e ) i g r a p h : : V ( g ) name <- value
igraph::set_vertex_attr(g, "name", value)
igraph::V(g) nam e < − v a l u e i g r a p h :: se t v er t e x a tt r ( g , " nam e " , v a l u e ) i g r a p h :: V ( g ) name <- value
igraph::set_graph_attr(g, "name", value)
g$name <- value
network
network::set.edge.attribute(g, "new_name", value, e = seq_along(g
m e l ) ) n e t w o r k : : s e t . e d g e . v a l u e ( g , " n e w n a m e " , v a l u e , e = s e q a l o n g ( g mel))
network::set.edge.value(g, "new_name", value, e = seq_along(g m e l )) n e tw or k :: se t . e d g e . v a l u e ( g , " n e w n am e " , v a l u e , e = se q a l o n g ( g mel))
network::set.network.attribute(g, "new_name", value)
network::set.vertex.attribute(g, "new_name", value, v = seq_len(network::network.size(g)))
Remove vertex / edge / graph attributes
snafun
snafun :: remove_edge_attribute ( x , attr_name )
snafun :: remove_edge_weight ( x ) # remove edge weights
snafun :: remove_vertex_attribute ( x , attr_name )
snafun :: remove_vertex_names ( x ) # specific for the vertex name attribute
snafun :: remove_graph_attribute ( x , attr_name )
igraph
igraph :: delete_edge_attr ( graph , name )
igraph :: delete_vertex_attr ( graph , name )
igraph :: delete_graph_attr ( graph , name )
network
network :: delete.edge.attribute ( x , attrname , ... )
network :: delete.vertex.attribute ( x , attrname , ... )
network :: delete.network.attribute ( x , attrname , ... )
Add vertices or edges
snafun
—
igraph
igraph :: add_vertices ( graph , nv , ... , attr = list ( ) )
igraph :: add_edges ( graph , edges , ... , attr = list ( ) )
network
network :: add.vertices ( x , nv , vattr = NULL , last.mode = TRUE , ... )
network :: add.edge ( x , tail , head , names.eval = NULL , vals.eval = NULL , edge.check = FALSE , ... )
network :: add.edges ( x , tail , head , names.eval = NULL , vals.eval = NULL , ... )
Remove vertices or edges
snafun
snafun :: remove_vertices ( x , vertices )
igraph
igraph :: delete_vertices ( graph , v )
igraph :: delete_edges ( graph , edges )
network
network :: delete.edges ( x , eid )
network :: delete.vertices ( x , vid )
Contract vertices into one
snafun
snafun :: contract_vertices ( g , vertices , method = c ( "min" , "max" , "union" , "add" ) ,
attr = NULL , new_name = "set" , out_as_igraph = TRUE )
igraph
—
network
—
snafun
# single function to do it all
snafun :: extract_subgraph ( x , v_to_keep , e_to_keep )
igraph
# subset based on vertices
igraph :: induced_subgraph ( g , vids = theVerticesYouWantToKeep )
# subset based on edges
igraph :: subgraph.edges ( g , eids = theEdgesYouWantToKeep )
network
# subset based on vertices
network :: get.inducedSubgraph ( g , v = theVerticesYouWantToKeep )
# subset based on edges
network :: get.inducedSubgraph ( g , eid = theEdgesYouWantToKeep )
snafun
snafun :: extract_egonet ( x , vertices = NULL , order = 1 , type = c ( "all" , "out" , "in" ) )
igraph
igraph :: make_ego_graph ( g , order = 1 , nodes = V ( graph ) , mode = c ( "all" , "out" , "in" ) , mindist = 0 )
network
sna :: ego.extract ( dat , ego = NULL , neighborhood = c ( "combined" , "in" , "out" ) )
Clean up the graph
snafun
snafun :: find_isolates ( x , names = TRUE , loops = FALSE )
snafun :: remove_isolates ( x , loops = FALSE )
snafun :: remove_loops ( x )
igraph
igraph :: simplify ( g )
# for example
igraph :: simplify ( g , remove.multiple = TRUE ,
remove.loops = TRUE , edge.attrib.comb = list ( weight = 'max' ) )
network
sna :: isolates ( g , diag= FALSE )
Union of graphs
snafun
snafun :: make_union ( net1 , net2 , net3 , byname = 'auto' )
igraph
igraph :: union ( net1 , net2 , net3 )
network
—
Intersection of graphs
snafun
snafun :: extract_intersection ( net , net2 , net3 , byname = 'auto' , keep.all.vertices = TRUE )
igraph
igraph :: intersection ( net , net2 , net3 )
network
—