Last active
June 24, 2021 08:20
-
-
Save jinhangjiang/d1118eec7407eddfcb7a773df5904361 to your computer and use it in GitHub Desktop.
igraph manipulate graphs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## check out the vertices and the order | |
V(g) | |
#output: | |
# + 7/7 vertices, named, from bd40644: | |
# [1] 1 2 3 4 5 6 7 8 | |
vcount(g) | |
# [1] 8 | |
## check out the edges and the size | |
E(g) | |
# + 10/10 edges from bd40644 (vertex names): | |
# [1] 1--2 1--3 1--7 2--3 2--4 3--4 3--5 7--4 7--6 7--8 4--5 4--6 5--6 5--8 | |
ecount(g) | |
# [1] 14 | |
## summary | |
g$name <- "undirected graph" | |
print_all(g) | |
# IGRAPH 50df64b UN-- 8 14 -- undirected graph | |
# + attr: name (g/c), name (v/c) | |
# + edges (vertex names): | |
# 1 -- 2, 3, 7 | |
# 2 -- 1, 3, 4 | |
# 3 -- 1, 2, 4, 5 | |
# 7 -- 1, 4, 6, 8 | |
# 4 -- 2, 3, 7, 5, 6 | |
# 5 -- 3, 4, 6, 8 | |
# 6 -- 7, 4, 5 | |
# 8 -- 7, 5 | |
# 7 -- 4, 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment