I have a graph g1
and I need to find the
Question. Is it possible to solve the task without using the additional attribute V(g1)$label?
CodePudding user response:
You should use $name
(instead of $names
) to add vertex name attribute, e.g.,
g1 <- graph_from_adjacency_matrix(m, weighted = TRUE, mode = "directed")
V(g1)$name <- letters[1:n]
g2 <- contract(g1, components(g1, mode = "strong")$membership, vertex.attr.comb = toString)
g2 <- simplify(g2)
then, when you run plot(g2)
, you will see