I am trying to use the LightGraphs and associated packages to implement Maximal-Independent-Set algorithms: Luby, Blelloch
Both algorithms work by iterating over vertices and based on a relation between a vertex and its neighbors, add the vertex to the MIS (maximal independent set) and mark that vertex and its neighbors as “inactive” (ignoring them in the following iterations of the algorithm)
I tried to create a copy of the graph (squash
/ copy
) in the beginning of the function, and remove inactive vertices making the graph gradually smaller (focusing on a sequential implementation of these algorithms)
However, removing vertices from the graph (rem_vertex!
, rem_vertices!
) relabels the vertices of the graph, thus the algorithms fails
My “solution” was to convert the copy of the graph to a MetaGraph
and add an :active
property (initially true
).
This works, but it is not elegant, and worse it is very inefficient since as the algorithm progresses it has to iterate over all vertices skipping the ones marked as inactive
Is there a way to remove vertices from a graph while maintaining the original vertex numbers?