@@ -32,6 +32,7 @@ use crate::stitching::Database;
3232use crate :: stitching:: DatabaseCandidates ;
3333use crate :: stitching:: ForwardPartialPathStitcher ;
3434use crate :: stitching:: GraphEdgeCandidates ;
35+ use crate :: stitching:: StitcherConfig ;
3536use crate :: CancellationError ;
3637use crate :: CancellationFlag ;
3738
@@ -1173,6 +1174,7 @@ pub extern "C" fn sg_partial_path_arena_find_partial_paths_in_file(
11731174 partials : * mut sg_partial_path_arena ,
11741175 file : sg_file_handle ,
11751176 partial_path_list : * mut sg_partial_path_list ,
1177+ config : sg_stitcher_config ,
11761178 cancellation_flag : * const usize ,
11771179) -> sg_result {
11781180 let graph = unsafe { & ( * graph) . inner } ;
@@ -1185,6 +1187,7 @@ pub extern "C" fn sg_partial_path_arena_find_partial_paths_in_file(
11851187 graph,
11861188 partials,
11871189 file,
1190+ & config. into ( ) ,
11881191 & AtomicUsizeCancellationFlag ( cancellation_flag) ,
11891192 |_graph, partials, path| {
11901193 let mut path = path. clone ( ) ;
@@ -1210,6 +1213,7 @@ pub extern "C" fn sg_partial_path_arena_find_all_complete_paths(
12101213 starting_node_count : usize ,
12111214 starting_nodes : * const sg_node_handle ,
12121215 path_list : * mut sg_partial_path_list ,
1216+ config : sg_stitcher_config ,
12131217 cancellation_flag : * const usize ,
12141218) -> sg_result {
12151219 let graph = unsafe { & ( * graph) . inner } ;
@@ -1221,6 +1225,7 @@ pub extern "C" fn sg_partial_path_arena_find_all_complete_paths(
12211225 ForwardPartialPathStitcher :: find_all_complete_partial_paths (
12221226 & mut GraphEdgeCandidates :: new ( graph, partials, None ) ,
12231227 starting_nodes. iter ( ) . copied ( ) . map ( sg_node_handle:: into) ,
1228+ & config. into ( ) ,
12241229 & AtomicUsizeCancellationFlag ( cancellation_flag) ,
12251230 |graph, _partials, path| {
12261231 if path. is_complete ( graph) {
@@ -1391,6 +1396,19 @@ pub struct sg_forward_partial_path_stitcher {
13911396 pub is_complete : bool ,
13921397}
13931398
1399+ // Configuration for partial path stitchers.
1400+ #[ repr( C ) ]
1401+ pub struct sg_stitcher_config {
1402+ /// Enables similar path detection during stiching.
1403+ pub detect_similar_paths : bool ,
1404+ }
1405+
1406+ impl Into < StitcherConfig > for sg_stitcher_config {
1407+ fn into ( self ) -> StitcherConfig {
1408+ unsafe { std:: mem:: transmute ( self ) }
1409+ }
1410+ }
1411+
13941412// This is the Rust equivalent of a common C trick, where you have two versions of a struct — a
13951413// publicly visible one and a private one containing internal implementation details. In our case,
13961414// `sg_forward_partial_path_stitcher` is the public struct, and
@@ -1443,6 +1461,7 @@ pub extern "C" fn sg_forward_partial_path_stitcher_from_nodes(
14431461 partials : * mut sg_partial_path_arena ,
14441462 count : usize ,
14451463 starting_nodes : * const sg_node_handle ,
1464+ config : sg_stitcher_config ,
14461465) -> * mut sg_forward_partial_path_stitcher {
14471466 let graph = unsafe { & ( * graph) . inner } ;
14481467 let partials = unsafe { & mut ( * partials) . inner } ;
@@ -1457,7 +1476,12 @@ pub extern "C" fn sg_forward_partial_path_stitcher_from_nodes(
14571476 p
14581477 } )
14591478 . collect :: < Vec < _ > > ( ) ;
1460- let stitcher = ForwardPartialPathStitcher :: from_partial_paths ( graph, partials, initial_paths) ;
1479+ let stitcher = ForwardPartialPathStitcher :: from_partial_paths (
1480+ graph,
1481+ partials,
1482+ initial_paths,
1483+ & config. into ( ) ,
1484+ ) ;
14611485 Box :: into_raw ( Box :: new ( InternalForwardPartialPathStitcher :: new (
14621486 stitcher, partials,
14631487 ) ) ) as * mut _
@@ -1471,6 +1495,7 @@ pub extern "C" fn sg_forward_partial_path_stitcher_from_partial_paths(
14711495 partials : * mut sg_partial_path_arena ,
14721496 count : usize ,
14731497 initial_partial_paths : * const sg_partial_path ,
1498+ config : sg_stitcher_config ,
14741499) -> * mut sg_forward_partial_path_stitcher {
14751500 let graph = unsafe { & ( * graph) . inner } ;
14761501 let partials = unsafe { & mut ( * partials) . inner } ;
@@ -1480,6 +1505,7 @@ pub extern "C" fn sg_forward_partial_path_stitcher_from_partial_paths(
14801505 graph,
14811506 partials,
14821507 initial_partial_paths. to_vec ( ) ,
1508+ & config. into ( ) ,
14831509 ) ;
14841510 Box :: into_raw ( Box :: new ( InternalForwardPartialPathStitcher :: new (
14851511 stitcher, partials,
0 commit comments