powered by
Converts various network representations to an igraph object. Supports matrices, igraph objects, network objects, cograph_network, and tna objects.
to_igraph(x, directed = NULL)
An igraph object.
Network input. Can be:
A square numeric matrix (adjacency/weight matrix)
An igraph object (returned as-is or converted if directed differs)
A statnet network object
A cograph_network object
A tna object
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected.
to_data_frame, as_cograph
to_data_frame
as_cograph
# From matrix adj <- matrix(c(0, 1, 1, 1, 0, 1, 1, 1, 0), 3, 3) rownames(adj) <- colnames(adj) <- c("A", "B", "C") g <- to_igraph(adj) # Force directed g_dir <- to_igraph(adj, directed = TRUE)
Run the code above in your browser using DataLab