Skip to content

Unify Graph Views #48

Description

@IanChenUIUC

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; }
    // ...
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions