Closed luukvdmeer closed 2 years ago
In some tidygraph functions it is actually also documented to work that way: https://tidygraph.data-imaginist.com/reference/local_graph.html
I have always hated that some magic attribute name would completely change the computations in igraph, so I'm afraid I will not change this behaviour... The example you shared with local_ave_degree()
also follows the rest of the tidygraph approach but the documentation is wrong - it is inherited from igraph but I'll change that to make sure it doesn't falsely state the behaviour of the "weight" attribute
When working with tidygraph I always struggle with the following. In igraph setting
weights = NULL
(the default) will always use an edge attribute named "weight" as edge weights, whenever this attribute is present. In tidygraph,weights = NULL
always means that no weights are used, no matter if there is an edge attribute named "weight".I understand both ideas. From the one hand, it is nice that you can create an edge attribute "weight" once and know this will be always used as edge weights in any function in which weights play a role, without always having to set explicitly
weights = "weight"
every time you call such a function. From the other hand, it may be more intuitive thatweights = NULL
means that no weights are used (in igraph you can do this instead withweights = NA
).However, now the situation is quite confusing, since the same setting (
weights = NULL
) means something completely different in tidygraph than it does in igraph. That means you have to know about this and always remember it when you are using an igraph function inside a tidygraph workflow, or vice versa. Speaking for myself, I can say this already got me wrong results a few times (without warning). Taken from the tidygraph introduction, the idea is that tidygraph and igraph objects and/or functions can be easily used together:Would it be an idea to stick to the igraph default regarding the default handling of edge weights? Hence, whenever your edges table has a column named "weight" these will be used as edge weights without having to set that explicitly at every function call. I know this is a backwards incompatible change, but it might save more confusion on the long run.