Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disjoint_union() and vertex attributes #1640

Open
krlmlr opened this issue Dec 30, 2024 · 2 comments
Open

disjoint_union() and vertex attributes #1640

krlmlr opened this issue Dec 30, 2024 · 2 comments

Comments

@krlmlr
Copy link
Contributor

krlmlr commented Dec 30, 2024

Needs same treatment as #761.

options(conflicts.policy = list(warn = FALSE))
library(igraph)

# create two graphs
g1 <- make_graph(~ B - -C, C - -D)
g2 <- make_graph(~ A - -G, E - -F)

# add an edge attribute of class POSIXct to each graph
g1 <- set_vertex_attr(g1, "date", value = as.POSIXct(c("2021-01-01 01:01:01", "2022-02-02 02:02:02", "2023-03-03 03:03:03")))
g2 <- set_vertex_attr(g2, "date", value = as.POSIXct(c("2021-03-03 03:03:03", "2022-04-04 04:04:04", "2023-05-05 05:05:05", "2024-06-06 06:06:06")))

# create the union of the two graphs
u <- disjoint_union(g1, g2)

# now print the structure of g1, g2, and u
vertex_attr(u, "date")
#> [1] 1609459261 1643763722 1677808983 1614736983 1649037844 1683255905 1717646766

Created on 2024-12-20 with reprex v2.1.1

CC @bockthom @maxloeffler.

@bockthom
Copy link

bockthom commented Dec 30, 2024

I'd suggest to rename this issue, as it actually is about vertex attributes, not edge attributes (edge attributes have been addressed already in #761 and #1587).

@krlmlr krlmlr changed the title disjoint_union() and edge attributes disjoint_union() and vertex attributes Dec 31, 2024
@krlmlr
Copy link
Contributor Author

krlmlr commented Dec 31, 2024

Good catch, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants