Skip to content

feat(export): export an edge list or Cypher result as dense CSR #202

Done

Description

@prrao87

Follow-up to #200.

Why

CypherEngine.export_graph builds dense CSR arrays from whole relationship types. Many graph-algorithm pipelines need a subgraph instead: select edges with a Cypher query, run an algorithm on just those, then filter by the scores. Today the query result has to be turned into CSR by hand (key-to-dense-id mapping, symmetrising, deduplication, weights), repeating the rules export_graph already implements, and slower.

In a filter → PageRank → filter pipeline on the SNAP Twitter graph (2.4M edge rows), building that CSR in numpy takes 0.13 s of a 0.18 s pipeline. export_graph handles all 2.4M rows, scan included, in 0.066 s, so a Rust build of the subgraph should cut that stage well below half (an estimate until measured).

Proposal

A way to export an arbitrary edge list, such as a Cypher result already in Arrow, as the same GraphExport:

  • inputs: the edge table, its source and target key columns, and the options export_graph has: directed, weight (a column of the table), default_weight (one per row, which counts repeated rows), combine_edges;
  • the same semantics as export_graph: repeated edges combined by combine_edges, undirected a -> b and b -> a as one edge, self-loops once, null weights dropped and counted, in-edges built by transposing the out-edge CSR;
  • reuse the CSR builders in crates/lance-csr/src/graph_export.rs rather than duplicating them.

Open questions

  • Dense ids over only the endpoints present (a subgraph), or an optional list of node keys so isolated nodes are kept?
  • A function taking an Arrow table, or a method on CypherEngine taking a query string, or both?
  • Keys from several node labels can collide in a plain edge list: limit it to one key space, or take label columns too?
  • Keys are int64 only, as in export_graph?

Done when

  • Rust implementation with unit tests (duplicates, reciprocal pairs, self-loops, weights, nulls);
  • Python and TypeScript bindings, docstrings and TSDoc, a section and parameter table on the graph algorithms page, regenerated TypeDoc;
  • measured on the Twitter pipeline above: identical arrays and scores to the numpy build, and the stage time before and after.

Activity

  1. added
    enhancement
    on Nov 25, 2026
  2. added a commit that references this issue on Nov 25, 2026
    413daa0
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions