xgi icon indicating copy to clipboard operation
xgi copied to clipboard

new add method

Open nwlandry opened this issue 2 years ago • 2 comments

Allows users to add two hypergraphs together. This reindexes all edges and keeps them all.

nwlandry avatar Oct 28 '22 16:10 nwlandry

I haven't read the entire code yet BUT the + operator should absolutely at all times represent an operation that is commutative. If it is not commutative, then we shouldn't use the + operator.

leotrs avatar Oct 28 '22 18:10 leotrs

😭

nwlandry avatar Oct 28 '22 18:10 nwlandry

OK how about this?

# Keeps edge ids of H1 and relabels the edge ids of H2
# All edges (after relabeling) keep all their attributes
# The node attributes of H1 take precedence over the node attributes of H2
# The hypergraph attributes of H1 take precedence over the hypergraph attributes of H2
X = H1 << H2

Since this is not commutative, I propose we use << since I don't think we'd be using it for any other purpose.

Note that if H1 and H2 have no attributes at all, then H1 << H2 and H2 << H1 are isomorphic (though the edge ids are different).

leotrs avatar Oct 29 '22 13:10 leotrs

Okay, I did your suggestion with the small difference that H2 attributes take preference, but very happy to change to H1 precedence.

nwlandry avatar Oct 31 '22 17:10 nwlandry