Skip to content

disjoint_union() and vertex attributes #1640

@krlmlr

Description

@krlmlr

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions