Skip to content

Commit 88113f8

Browse files
committed
Revert "fix: filter reachable vertecies in nfarpq"
This reverts commit 13284b4.
1 parent 13284b4 commit 88113f8

5 files changed

Lines changed: 12 additions & 68 deletions

File tree

build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ fn regenerate_bindings() {
7171
.allowlist_function("GrB_Vector_new")
7272
.allowlist_function("GrB_Vector_free")
7373
.allowlist_function("GrB_Vector_setElement_BOOL")
74-
.allowlist_function("GrB_Vector_extractElement_BOOL")
7574
.allowlist_function("GrB_Vector_nvals")
7675
.allowlist_function("GrB_Vector_extractTuples_BOOL")
7776
.allowlist_function("GrB_vxm")

src/graph/mod.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,6 @@ impl GraphblasVector {
149149
Ok(nvals)
150150
}
151151

152-
/// Checks if a specific index has a stored value.
153-
pub fn contains(&self, i: GrB_Index) -> Result<bool, GraphError> {
154-
let mut value: bool = false;
155-
let info = unsafe { GrB_Vector_extractElement_BOOL(&mut value, self.inner, i) };
156-
match info {
157-
GrB_Info::GrB_SUCCESS => Ok(true),
158-
GrB_Info::GrB_NO_VALUE => Ok(false),
159-
_ => Err(GraphError::GraphBlas(info)),
160-
}
161-
}
162-
163-
/// Stores a boolean value at the given index.
164-
pub fn set_bool(&mut self, i: GrB_Index, value: bool) -> Result<(), GraphError> {
165-
grb_ok!(GrB_Vector_setElement_BOOL(self.inner, value, i))
166-
}
167-
168152
/// Extracts all stored indices from boolean vector.
169153
pub fn indices(&self) -> Result<Vec<GrB_Index>, GraphError> {
170154
let nvals = self.nvals()?;

src/lagraph_sys_generated.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,6 @@ unsafe extern "C" {
139139
unsafe extern "C" {
140140
pub fn GrB_Vector_setElement_BOOL(w: GrB_Vector, x: bool, i: GrB_Index) -> GrB_Info;
141141
}
142-
unsafe extern "C" {
143-
pub fn GrB_Vector_extractElement_BOOL(x: *mut bool, v: GrB_Vector, i: GrB_Index) -> GrB_Info;
144-
}
145142
unsafe extern "C" {
146143
pub fn GrB_Vector_extractTuples_BOOL(
147144
I_: *mut GrB_Index,

src/rpq/nfarpq.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
use crate::graph::{GraphDecomposition, GraphblasVector, LagraphGraph, ensure_grb_init};
44
use crate::la_ok;
5-
use crate::lagraph_sys::LAGraph_Kind;
65
use crate::lagraph_sys::*;
6+
use crate::lagraph_sys::LAGraph_Kind;
77
use crate::rpq::{Endpoint, PathExpr, RpqError, RpqEvaluator, RpqQuery};
88
use rustfst::algorithms::closure::{ClosureType, closure};
99
use rustfst::algorithms::concat::concat;
@@ -223,7 +223,7 @@ impl RpqEvaluator for NfaRpqEvaluator {
223223
let nfa_matrices = nfa.build_lagraph_matrices()?;
224224

225225
let src_id = resolve_endpoint(&query.subject, graph)?;
226-
let dst_id = resolve_endpoint(&query.object, graph)?;
226+
let _dst_id = resolve_endpoint(&query.object, graph)?;
227227

228228
let n = graph.num_nodes();
229229

@@ -258,24 +258,8 @@ impl RpqEvaluator for NfaRpqEvaluator {
258258

259259
let result_vec = GraphblasVector { inner: reachable };
260260

261-
let filtered_vec = match dst_id {
262-
Some(target_idx) => {
263-
let target = target_idx as GrB_Index;
264-
let is_reachable = result_vec.contains(target)?;
265-
266-
let mut filtered = unsafe { GraphblasVector::new_bool(n as GrB_Index) }?;
267-
268-
if is_reachable {
269-
filtered.set_bool(target, true)?;
270-
}
271-
272-
filtered
273-
}
274-
None => result_vec,
275-
};
276-
277261
Ok(NfaRpqResult {
278-
reachable: filtered_vec,
262+
reachable: result_vec,
279263
})
280264
}
281265
}

tests/nfarpq_tests.rs

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ fn run_la_n_egg_case(case_name: &str) {
9090

9191
let actual_nnz = result.reachable.nvals().expect("failed to get nvals");
9292
assert_eq!(
93-
actual_nnz, *expected_nnz,
93+
actual_nnz,
94+
*expected_nnz,
9495
"case '{case_name}' query #{i} nnz mismatch\n query: {query:?}\n expected: {expected_nnz}\n actual: {actual_nnz}",
9596
);
9697
}
@@ -142,10 +143,7 @@ fn test_single_label_named_source() {
142143
.evaluate(&rq(named_ep("A"), label("knows"), var("y")), &graph)
143144
.expect("evaluate should succeed");
144145

145-
let indices = result
146-
.reachable
147-
.indices()
148-
.expect("failed to extract indices");
146+
let indices = result.reachable.indices().expect("failed to extract indices");
149147
let b_id = graph.get_node_id("B").expect("B should exist");
150148
assert!(
151149
indices.contains(&(b_id as GrB_Index)),
@@ -183,10 +181,7 @@ fn test_sequence_path_named_source() {
183181
.evaluate(&rq(named_ep("A"), path, var("y")), &graph)
184182
.expect("evaluate should succeed");
185183

186-
let indices = result
187-
.reachable
188-
.indices()
189-
.expect("failed to extract indices");
184+
let indices = result.reachable.indices().expect("failed to extract indices");
190185
let c_id = graph.get_node_id("C").expect("C should exist");
191186
assert!(
192187
indices.contains(&(c_id as GrB_Index)),
@@ -207,10 +202,7 @@ fn test_alternative_path() {
207202
.evaluate(&rq(named_ep("A"), path, var("y")), &graph)
208203
.expect("evaluate should succeed");
209204

210-
let indices = result
211-
.reachable
212-
.indices()
213-
.expect("failed to extract indices");
205+
let indices = result.reachable.indices().expect("failed to extract indices");
214206
let b_id = graph.get_node_id("B").expect("B should exist");
215207
let c_id = graph.get_node_id("C").expect("C should exist");
216208
assert!(
@@ -236,10 +228,7 @@ fn test_zero_or_more_path() {
236228
.evaluate(&rq(named_ep("A"), path, var("y")), &graph)
237229
.expect("evaluate should succeed");
238230

239-
let indices = result
240-
.reachable
241-
.indices()
242-
.expect("failed to extract indices");
231+
let indices = result.reachable.indices().expect("failed to extract indices");
243232
let a_id = graph.get_node_id("A").expect("A should exist");
244233
let b_id = graph.get_node_id("B").expect("B should exist");
245234
let c_id = graph.get_node_id("C").expect("C should exist");
@@ -271,10 +260,7 @@ fn test_one_or_more_path() {
271260
.evaluate(&rq(named_ep("A"), path, var("y")), &graph)
272261
.expect("evaluate should succeed");
273262

274-
let indices = result
275-
.reachable
276-
.indices()
277-
.expect("failed to extract indices");
263+
let indices = result.reachable.indices().expect("failed to extract indices");
278264
let a_id = graph.get_node_id("A").expect("A should exist");
279265
let b_id = graph.get_node_id("B").expect("B should exist");
280266
let c_id = graph.get_node_id("C").expect("C should exist");
@@ -306,10 +292,7 @@ fn test_zero_or_one_path() {
306292
.evaluate(&rq(named_ep("A"), path, var("y")), &graph)
307293
.expect("evaluate should succeed");
308294

309-
let indices = result
310-
.reachable
311-
.indices()
312-
.expect("failed to extract indices");
295+
let indices = result.reachable.indices().expect("failed to extract indices");
313296
let a_id = graph.get_node_id("A").expect("A should exist");
314297
let b_id = graph.get_node_id("B").expect("B should exist");
315298
let c_id = graph.get_node_id("C").expect("C should exist");
@@ -419,10 +402,7 @@ fn test_complex_path() {
419402
.evaluate(&rq(named_ep("A"), path, var("y")), &graph)
420403
.expect("evaluate should succeed");
421404

422-
let indices = result
423-
.reachable
424-
.indices()
425-
.expect("failed to extract indices");
405+
let indices = result.reachable.indices().expect("failed to extract indices");
426406
let d_id = graph.get_node_id("D").expect("D should exist");
427407
assert!(
428408
indices.contains(&(d_id as GrB_Index)),

0 commit comments

Comments
 (0)