Hi, this is what I get, with igraph 0.7.0.

g <- structure(list(9, FALSE, c(6, 2, 7, 8, 7, 5), c(0, 1, 1, 1, 2,
3), c(1, 5, 0, 2, 4, 3), c(0, 1, 2, 3, 4, 5), c(0, 0, 0, 1, 1,
1, 2, 3, 5, 6), c(0, 1, 4, 5, 6, 6, 6, 6, 6, 6), list(c(1, 0,
1), structure(list(), .Names = character(0)), structure(list(
    name = c("16052361", "16052513", "16052618", "16052962",
    "rs11703994", "rs62224614", "rs78724352", "rs3013006", "rs55926024"
    ), x = c(16052361L, 16052513L, 16052618L, 16052962L, 16053791L,
    16053862L, 16053863L, 16054667L, 16054740L), y = c(2.156147,
    2.547104, 1.587586, 4.037532, 3.734964, 5.026869, 2.514876,
    1.543943, 0.579408)), .Names = c("name", "x", "y")), structure(list(
    weight = c(0.526203, 0.725426, 0.681783, 0.579408, 0.86216,
    0.718093), color = c("grey", "blue", "grey", "grey", "red",
    "blue")), .Names = c("weight", "color")))), class = "igraph")

g

# IGRAPH UNW- 9 6 --
# + attr: name (v/c), x (v/n), y (v/n), weight (e/n), color (e/c)

gg <- g
gu <- graph.union(gg, g)
gu

# IGRAPH UN-- 9 6 --
# + attr: x_1 (v/n), x_2 (v/n), y_1 (v/n), y_2 (v/n), name (v/c),
#   weight_1 (e/n), weight_2 (e/n), color_1 (e/c), color_2 (e/c)

Your graph has symbolic vertex names. From version 0.7.0 graph.union works
on those by default if they are present:

str(g)
# IGRAPH UNW- 9 6 --
# + attr: name (v/c), x (v/n), y (v/n), weight (e/n), color (e/c)
# + edges (vertex names):
# [1] 16052361--rs78724352 16052513--16052618   16052513--rs3013006
# [4] 16052513--rs55926024 16052618--rs3013006  16052962--rs62224614

str(gu)
# IGRAPH UN-- 9 6 --
# + attr: x_1 (v/n), x_2 (v/n), y_1 (v/n), y_2 (v/n), name (v/c),
#   weight_1 (e/n), weight_2 (e/n), color_1 (e/c), color_2 (e/c)
# + edges (vertex names):
# [1] 16052962--rs62224614 16052618--rs3013006  16052513--rs55926024
# [4] 16052513--rs3013006  16052513--16052618   16052361--rs78724352

These are the same, only their order is different.

As for weighted graphs, if the two graphs both have an attribute with the
same name, it is renamed by adding a _1 and _2 (and _3, etc.) suffix. If
you want to keep the first operand's weights, assign them as 'weight', etc.

It is true that it could try and see if the attributes have the same values
for all graphs, but currently it does not do that.

This is all discussed in ?graph.union, so please consider reading the
manual.

Thanks. Gabor



On Tue, Feb 11, 2014 at 2:49 PM, Hermann Norpois <[email protected]> wrote:

> Hello,
>
> I was playing around with graph.union.
> I did a copy of my graph g
> gg -> g
> gu  -> graph.union (gg, g)
>
> I expected a graph identical to g (or gg) but this was not the case.
> The same should be the case for
> gi -> graph.intersect (gg,g)
>
> And it doesnt work for weighted graphs?
>
> Thanks Hermann
>
> dput (g)
> structure(list(9, FALSE, c(6, 2, 7, 8, 7, 5), c(0, 1, 1, 1, 2,
> 3), c(1, 5, 0, 2, 4, 3), c(0, 1, 2, 3, 4, 5), c(0, 0, 0, 1, 1,
> 1, 2, 3, 5, 6), c(0, 1, 4, 5, 6, 6, 6, 6, 6, 6), list(c(1, 0,
> 1), structure(list(), .Names = character(0)), structure(list(
>     name = c("16052361", "16052513", "16052618", "16052962",
>     "rs11703994", "rs62224614", "rs78724352", "rs3013006", "rs55926024"
>     ), x = c(16052361L, 16052513L, 16052618L, 16052962L, 16053791L,
>     16053862L, 16053863L, 16054667L, 16054740L), y = c(2.156147,
>     2.547104, 1.587586, 4.037532, 3.734964, 5.026869, 2.514876,
>     1.543943, 0.579408)), .Names = c("name", "x", "y")), structure(list(
>     weight = c(0.526203, 0.725426, 0.681783, 0.579408, 0.86216,
>     0.718093), color = c("grey", "blue", "grey", "grey", "red",
>     "blue")), .Names = c("weight", "color")))), class = "igraph")
> >
>
> _______________________________________________
> igraph-help mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to