@@ -26,9 +26,11 @@ pathrex/
2626│ │ └── inmemory.rs # InMemory marker, InMemoryBuilder, InMemoryGraph
2727│ └── formats/
2828│ ├── mod.rs # FormatError enum, re-exports
29- │ └── csv.rs # Csv<R> — CSV → Edge iterator (CsvConfig, ColumnSpec)
29+ │ ├── csv.rs # Csv<R> — CSV → Edge iterator (CsvConfig, ColumnSpec)
30+ │ └── mm.rs # MatrixMarket directory loader (vertices.txt, edges.txt, *.txt)
3031├── tests/
31- │ └── inmemory_tests.rs # Integration tests for InMemoryBuilder / InMemoryGraph
32+ │ ├── inmemory_tests.rs # Integration tests for InMemoryBuilder / InMemoryGraph
33+ │ └── mm_tests.rs # Integration tests for MatrixMarket format
3234├── deps/
3335│ └── LAGraph/ # Git submodule (SparseLinearAlgebra/LAGraph)
3436└── .github/workflows/ci.yml # CI: build GraphBLAS + LAGraph, cargo build & test
@@ -178,18 +180,26 @@ pub trait Backend {
178180### InMemoryBuilder / InMemoryGraph
179181
180182[ ` InMemoryBuilder ` ] ( src/graph/inmemory.rs:35 ) is the primary ` GraphBuilder ` implementation.
181- It collects edges in RAM, then [ ` build() ` ] ( src/graph/inmemory.rs:110 ) calls
183+ It collects edges in RAM, then [ ` build() ` ] ( src/graph/inmemory.rs:131 ) calls
182184GraphBLAS to create one ` GrB_Matrix ` per label via COO format, wraps each in an
183- ` LAGraph_Graph ` , and returns an [ ` InMemoryGraph ` ] ( src/graph/inmemory.rs:153 ) .
185+ ` LAGraph_Graph ` , and returns an [ ` InMemoryGraph ` ] ( src/graph/inmemory.rs:173 ) .
184186
185187Multiple CSV sources can be chained with repeated ` .load() ` calls; all edges are merged
186188into a single graph.
187189
190+ ** Node ID representation:** Internally, ` InMemoryBuilder ` uses ` HashMap<usize, String> ` for
191+ ` id_to_node ` (changed from ` Vec<String> ` to support sparse/pre-assigned IDs from MatrixMarket).
192+ The [ ` set_node_map() ` ] ( src/graph/inmemory.rs:67 ) method allows bulk-installing a node mapping,
193+ which is used by the MatrixMarket loader.
194+
188195### Format parsers
189196
190- [ ` Csv<R> ` ] ( src/formats/csv.rs:52 ) is the only built-in parser. It yields
191- ` Iterator<Item = Result<Edge, FormatError>> ` and is directly pluggable into
192- ` GraphBuilder::load() ` via its ` GraphSource<InMemoryBuilder> ` impl.
197+ Two built-in parsers are available:
198+
199+ #### CSV format
200+
201+ [ ` Csv<R> ` ] ( src/formats/csv.rs:52 ) yields ` Iterator<Item = Result<Edge, FormatError>> ` and is
202+ directly pluggable into ` GraphBuilder::load() ` via its ` GraphSource<InMemoryBuilder> ` impl.
193203
194204Configuration is via [ ` CsvConfig ` ] ( src/formats/csv.rs:17 ) :
195205
@@ -204,6 +214,27 @@ Configuration is via [`CsvConfig`](src/formats/csv.rs:17):
204214[ ` ColumnSpec ` ] ( src/formats/csv.rs:11 ) is either ` Index(usize) ` or ` Name(String) ` .
205215Name-based lookup requires ` has_header: true ` .
206216
217+ #### MatrixMarket directory format
218+
219+ [ ` MatrixMarket ` ] ( src/formats/mm.rs:160 ) loads an edge-labeled graph from a directory with:
220+
221+ - ` vertices.txt ` — one line per node: ` <node_name> <1-based-index> `
222+ - ` edges.txt ` — one line per label: ` <label_name> <1-based-index> `
223+ - ` <n>.txt ` — MatrixMarket adjacency matrix for label with index ` n `
224+
225+ The loader uses [ ` LAGraph_MMRead ` ] ( src/lagraph_sys.rs ) to parse each ` .txt ` file into a
226+ ` GrB_Matrix ` , then wraps it in an ` LAGraph_Graph ` . Node IDs from ` vertices.txt ` are
227+ installed via [ ` InMemoryBuilder::set_node_map() ` ] ( src/graph/inmemory.rs:67 ) .
228+
229+ Helper functions:
230+
231+ - [ ` load_mm_file(path) ` ] ( src/formats/mm.rs:64 ) — reads a single MatrixMarket file into a
232+ ` GrB_Matrix ` .
233+ - [ ` parse_index_map(path) ` ] ( src/formats/mm.rs:99 ) — parses ` <name> <index> ` mapping files.
234+
235+ ` MatrixMarket ` implements ` GraphSource<InMemoryBuilder> ` at
236+ [ ` src/graph/inmemory.rs:429 ` ] ( src/graph/inmemory.rs:429 ) .
237+
207238### FFI layer
208239
209240[ ` lagraph_sys ` ] ( src/lagraph_sys.rs ) exposes raw C bindings for GraphBLAS and
0 commit comments