Robin Jesson
Robin Jesson

Reputation: 1

Graph with only one vertex in R

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

Answers (2)

G5W
G5W

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

missuse
missuse

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)     

enter image description here

Upvotes: 1

Related Questions