Reputation: 1
I'm trying to create a graph but with only one vertex.
Do you know if it is possible? To best I have obtained was one vertex called "29" but with an edge "29"->"29" (g=graph(c("29","29")).
Thank you by advance,
Robin
Upvotes: 0
Views: 106
Reputation: 37641
A different way is to create an empty graph and then add one node.
library(igraph)
g <- graph.empty(0, directed=FALSE)
g <- add_vertices(g, 1, label=29)
Upvotes: 0
Reputation: 19716
Here is an example:
mat1 = matrix(0)
rownames(mat1) = "19"
colnames(mat1) = "19"
library(igraph)
g <- graph_from_adjacency_matrix(mat1, weighted = "prob")
plot(g)
Upvotes: 1