Skip to content

Instantly share code, notes, and snippets.

@jinhangjiang
Created June 24, 2021 09:38
Show Gist options
  • Save jinhangjiang/c69e88888ac80b4bbbfa6164a696a914 to your computer and use it in GitHub Desktop.
Save jinhangjiang/c69e88888ac80b4bbbfa6164a696a914 to your computer and use it in GitHub Desktop.
## remove specific nodes/vertices
h1 <- g - vertices(c("Adam","Judy"))
## generate subgraph by manual input
h2 <- graph_from_literal("Adam"-"Judy", "Adam"-"Bobby", "Adam"-"Sam", "Judy"-"Bobby","Judy"-"Frank")
## join graphs
h3 <- union(h1,h2)
# or, h3 <- h1 + h2
# compare the graphs
par(mfrow=c(2, 2))
set.seed(4)
plot(g)
plot(h1)
plot(h2)
plot(h3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment