Is there a faster way to modify the topology of the graph?

The only official APIs provided by DGL for modifying graph topology seem to be the four shown in the figure above

Is there a more convenient way to add and remove edges? For example, assigning values to the adjacency matrix directly?

Currently no, but we are watching very closely on whether we should provide a general adj matrix support. Question: what type of operations/algorithms in your mind are more suitable to be written in adj matrix than using add/remove_nodes/edges?

At this stage, I think it is enough to provide a new API that allows me to modify the edge-set in the graph by change adj matrix, for example:
reset_structure_by_adj(adj)

As for adding or removing nodes, the existing add/remove_nodes is convenient enough

3 Likes

In this case, why don’t you create a new graph instead?

@zihao Won’t this be slow if only a few edges have to modified for a large graph

helpful in edge rewiring operations for adversarial attacks

Internally, DGL stores a graph using sparse adjacency matrix so it is as fast as modifying non-zero values in a large sparse matrix.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.