graphANNIS icon indicating copy to clipboard operation
graphANNIS copied to clipboard

GraphStorage::find_connected shows no results (unlike CycleSafeDFS)

Open MartinKl opened this issue 3 years ago • 0 comments

Consider the following code snippet:

let c = AnnotationComponent::new(AnnotationComponentType::Ordering, smartstring::alias::String::from(ANNIS_NS), smartstring::alias::String::from(order_name));
if let Some(ordering) = graph.get_graphstorage(&c) {                
	let start_node = ordering.source_nodes().find(|n| ordering.get_ingoing_edges(*n.as_ref().unwrap()).count() == 0).unwrap()?;                
	let mut nodes: Vec<u64> = Vec::new();
	for entry in ordering.find_connected(start_node, 1, Bound::Excluded(usize::MAX)) {
		nodes.push(entry?);
	}
	if nodes.is_empty() {
		let dfs = CycleSafeDFS::new(ordering.as_edgecontainer(), start_node, 1, usize::MAX);
		let more_nodes = dfs.collect_vec();
		panic!("No nodes for ordering `{}` could be retrieved. (dfs: {})", order_name, more_nodes.len());
	}
}

This results in the following:

thread '<unnamed>' panicked at 'No nodes for ordering `norm` could be retrieved. (dfs: 142)'

While the dfs gathers 142 nodes, which is the expected result, find_connected() finds 0.

MartinKl avatar Dec 09 '22 12:12 MartinKl