Potentially, we can have CoarsenedGraphView and InducedSubgraphView share the same base class, e.g. this is the interface proposed by Arun. Any algorithm that takes a Graph instance should also work on these views, which do not copy the edges.
/**
* @ingroup graph
* Base class for zero-copy graph views.
*/
class GraphView : public Graph {
protected:
const Graph& original;
// Common cached state (can be protected or accessed via virtuals)
count n = 0;
count m = 0;
bool isDirected = false;
bool isWeighted = false;
// ... other flags you already have
explicit GraphView(const Graph& g);
// Helper for derived classes
bool isValidNode(node u) const; // to be implemented by subclass
void invalidateCache(); // when nodes change
public:
// Common implementations that can be overridden
count numberOfNodes() const override { return n; }
count numberOfEdges() const override { return m; }
bool isDirectedGraph() const override { return isDirected; }
// ...
};
Potentially, we can have
CoarsenedGraphViewandInducedSubgraphViewshare the same base class, e.g. this is the interface proposed by Arun. Any algorithm that takes a Graph instance should also work on these views, which do not copy the edges.