Skip to content

Commit 6a08410

Browse files
committed
tweak components to return nodes in discovery order
1 parent 0bbef59 commit 6a08410

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

raphtory/src/algorithms/components/in_components.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ use crate::{
2020
errors::GraphError,
2121
prelude::GraphViewOps,
2222
};
23+
use indexmap::{map::Entry, IndexMap};
2324
use serde::{Deserialize, Serialize};
2425
use std::{
25-
collections::{hash_map::Entry, HashMap, HashSet, VecDeque},
26+
collections::{HashMap, HashSet, VecDeque},
2627
fmt::Debug,
2728
};
2829

@@ -194,7 +195,7 @@ where
194195
F: CreateFilter + 'graph,
195196
F::EntityFiltered<'graph, G, F::FilteredGraph<'graph, G>>: GraphViewOps<'graph>,
196197
{
197-
let mut in_components = HashMap::new();
198+
let mut in_components = IndexMap::with_hasher(ahash::RandomState::new());
198199
let mut to_check_stack = VecDeque::new();
199200
let filtered = node.filter(filter)?;
200201
filtered.in_neighbours().iter().for_each(|node| {

raphtory/src/algorithms/components/out_components.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ use crate::{
2020
errors::GraphError,
2121
prelude::GraphViewOps,
2222
};
23+
use indexmap::{map::Entry, IndexMap};
2324
use serde::{Deserialize, Serialize};
24-
use std::collections::{hash_map::Entry, HashMap, HashSet, VecDeque};
25+
use std::collections::{HashMap, HashSet, VecDeque};
2526

2627
#[derive(Clone, PartialEq, Serialize, Deserialize, Debug, Default)]
2728
pub struct OutState {
@@ -191,7 +192,7 @@ where
191192
F: CreateFilter + 'graph,
192193
F::EntityFiltered<'graph, G, F::FilteredGraph<'graph, G>>: GraphViewOps<'graph>,
193194
{
194-
let mut out_components = HashMap::new();
195+
let mut out_components = IndexMap::with_hasher(ahash::RandomState::new());
195196
let mut to_check_stack = VecDeque::new();
196197
let filtered = node.filter(filter)?;
197198
filtered.out_neighbours().iter().for_each(|node| {

raphtory/src/db/api/state/generic_node_state.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ use std::{
5454
collections::HashMap,
5555
fmt::{Debug, Formatter},
5656
fs::File,
57-
hash::BuildHasher,
5857
marker::PhantomData,
5958
path::Path,
6059
sync::Arc,
@@ -1311,9 +1310,9 @@ impl<'graph, G: GraphViewOps<'graph>> GenericNodeState<'graph, G> {
13111310
}
13121311

13131312
/// create a new NodeState from a HashMap of values
1314-
pub fn new_from_map<R: NodeStateValue, S: BuildHasher, V: NodeStateValue>(
1313+
pub fn new_from_map<R: NodeStateValue, V: NodeStateValue>(
13151314
graph: G,
1316-
values: HashMap<VID, R, S>,
1315+
values: impl IntoIterator<Item = (VID, R)>,
13171316
map: impl Fn(R) -> V,
13181317
node_cols: Option<
13191318
HashMap<
@@ -1330,9 +1329,9 @@ impl<'graph, G: GraphViewOps<'graph>> GenericNodeState<'graph, G> {
13301329
}
13311330

13321331
/// create a new NodeState from a HashMap of values
1333-
pub fn new_from_map_with_schema<R: NodeStateValue, S: BuildHasher, V: NodeStateValue>(
1332+
pub fn new_from_map_with_schema<R: NodeStateValue, V: NodeStateValue>(
13341333
graph: G,
1335-
values: HashMap<VID, R, S>,
1334+
values: impl IntoIterator<Item = (VID, R)>,
13361335
map: impl Fn(R) -> V,
13371336
node_cols: Option<
13381337
HashMap<

0 commit comments

Comments
 (0)