Terminology note: "vertices"="nodes", "vertex/node labels" = "indices"
LightGraphs
in Julia changes node indices when producing induced subgraphs.
For instance, if a graph has nodes [1, 2, 3, 4]
, its LightGraphs.induced_subgraph
induced by nodes [3,4]
will be a new graph with nodes [3,4]
getting relabeled as [1,2]
.
In state-of-the-art graph algorithms, recursive subgraphing is used, with sets of nodes being modified and passed up and down the recursion layers. For these algorithms to properly keep track of node identities (labels), subgraphing must not change the indices.
Subgraphing in networkx
in Python, for instance, preserves node labels.
One can use MetaGraphs
by adding a node attribute :id
, which is preserved by subgraphing, but then you have to write a lot of extra code to convert between node indices and node :id
's.
Is there not a Julia package that "just works" when it comes to subgraphing and preserving node identities?