You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@gulshan-123 implemented a graph product feature in the C core as igraph_product(). It would be great to expose this in R/igraph. Two product types are already released and two more will land soon.
@schochastics, what do you think a nice interface could be for this? Do we want an operator like * or %*% for the classic Cartesian product, or do we restrict this to a plain function? Other graph operators, such as union, have operators such as %u%.
For the explicit function, what's a better name? Just product() (risk of collision, but short) or graph_product()?
I think product() might be fine because we also have union() . I also think an operator would be good to have but then separate ones for cartesian/tensor with "%"?
But @maelle is better at naming things than me!
Perhaps this operation is just not common enough to introduce an operator form for it. If one introduced, I would only do it for the Cartesian product, which is the classic graph product concept, and which is set as the default in interfaces.yaml.
If the graphs have vertex names, it'd be nice to auto-generate names for the product as well. For example if graph 1 has vertices A and B, and graph 2 has 3 vertices but no vertex names, the result graph could have names
A-1
A-2
A-3
B-1
B-2
B-3
Here I used - as the concatenation character. What this should be is up for debate.
I have an R implementation of products here: https://github.com/schochastics/netUtils/blob/main/R/graph_products.R and I also used "-". I think it makes the most sense. The problem with autogenerating names is also touching #1932. From a consistency point, throwing an error should be correct? Or we decide on a general naming scheme for unnamed graphs. In that case I would vote for "V1..Vn". Up to debate
There's now a separate function for yet another product type that requires an extra parameter: igraph_rooted_product(). I would recommend using the same function in the R interface, with an extra argument that is valid only for this product.
Activity
schochastics commentedon Jul 2, 2025
I think
product()might be fine because we also haveunion(). I also think an operator would be good to have but then separate ones for cartesian/tensor with "%"?But @maelle is better at naming things than me!
maelle commentedon Jul 3, 2025
Sounds good to me.
szhorvat commentedon Jul 3, 2025
Perhaps this operation is just not common enough to introduce an operator form for it. If one introduced, I would only do it for the Cartesian product, which is the classic graph product concept, and which is set as the default in
interfaces.yaml.schochastics commentedon Jul 3, 2025
Then maybe no operator. You are right, I don't think that the function is common enough that a shortcut is needed
szhorvat commentedon Jul 3, 2025
If the graphs have vertex names, it'd be nice to auto-generate names for the product as well. For example if graph 1 has vertices
AandB, and graph 2 has 3 vertices but no vertex names, the result graph could have namesHere I used
-as the concatenation character. What this should be is up for debate.schochastics commentedon Jul 4, 2025
I have an R implementation of products here: https://github.com/schochastics/netUtils/blob/main/R/graph_products.R and I also used "-". I think it makes the most sense. The problem with autogenerating names is also touching #1932. From a consistency point, throwing an error should be correct? Or we decide on a general naming scheme for unnamed graphs. In that case I would vote for "V1..Vn". Up to debate
szhorvat commentedon Aug 6, 2025
There's now a separate function for yet another product type that requires an extra parameter:
igraph_rooted_product(). I would recommend using the same function in the R interface, with an extra argument that is valid only for this product.