use crate::graph::Graph;
use crate::Result;
use super::{
ComponentResult,
parsing::{extract_algo_array, extract_node_id, extract_user_id, extract_int},
};
impl Graph {
pub fn wcc(&self) -> Result<Vec<ComponentResult>> {
let result = self.connection().cypher("RETURN wcc()")?;
let rows = extract_algo_array(result.iter().collect::<Vec<_>>().as_slice());
let mut components = Vec::new();
for row in rows.iter() {
if let Some(node_id) = extract_node_id(row) {
components.push(ComponentResult {
node_id,
user_id: extract_user_id(row),
component: extract_int(row, "component"),
});
}
}
Ok(components)
}
pub fn scc(&self) -> Result<Vec<ComponentResult>> {
let result = self.connection().cypher("RETURN scc()")?;
let rows = extract_algo_array(result.iter().collect::<Vec<_>>().as_slice());
let mut components = Vec::new();
for row in rows.iter() {
if let Some(node_id) = extract_node_id(row) {
components.push(ComponentResult {
node_id,
user_id: extract_user_id(row),
component: extract_int(row, "component"),
});
}
}
Ok(components)
}
}