use super::super::*;
fn hyperlink() -> EdgeAssertion {
EdgeAssertion::Semantic {
sub_kind: SemanticSubKind::Hyperlink,
label: None,
}
}
fn user_grouped(label: Option<&str>) -> EdgeAssertion {
EdgeAssertion::Semantic {
sub_kind: SemanticSubKind::UserGrouped,
label: label.map(str::to_string),
}
}
fn cites() -> EdgeAssertion {
EdgeAssertion::Semantic {
sub_kind: SemanticSubKind::Cites,
label: None,
}
}
#[test]
fn test_graph_new() {
let graph = Graph::new();
assert_eq!(graph.node_count(), 0);
assert_eq!(graph.edge_count(), 0);
}
#[test]
fn revision_advances_on_structural_change_only() {
let mut graph = Graph::new();
assert_eq!(graph.revision(), 0, "a fresh graph starts at revision 0");
let a = graph.add_node("https://a.example".to_string(), Point2D::new(0.0, 0.0));
let after_a = graph.revision();
assert!(after_a > 0, "adding a node advances the revision");
let b = graph.add_node("https://b.example".to_string(), Point2D::new(1.0, 0.0));
assert!(
graph.revision() > after_a,
"a second node advances it again"
);
let before_edge = graph.revision();
graph.assert_relation(a, b, hyperlink());
let after_edge = graph.revision();
assert!(after_edge > before_edge, "a new edge advances the revision");
graph.update_node_url(a, "https://a2.example".to_string());
assert_eq!(
graph.revision(),
after_edge,
"a url edit is content, not structure"
);
let url_groups = graph.url_grouping_revision();
graph.update_node_url(a, "https://a2.example/another-page".to_string());
assert_eq!(
graph.url_grouping_revision(),
url_groups,
"a same-host URL edit does not move a host-grouped projection"
);
graph.update_node_url(a, "https://other.example/".to_string());
assert!(
graph.url_grouping_revision() > url_groups,
"a host move advances the narrow URL-grouping dependency"
);
let url_groups = graph.url_grouping_revision();
graph.update_node_url(a, "https://other.example:8443/".to_string());
assert!(
graph.url_grouping_revision() > url_groups,
"a port is part of Canvas's site authority grouping"
);
graph.remove_node(b);
assert!(
graph.revision() > after_edge,
"removing a node advances the revision"
);
}
#[test]
fn content_revision_advances_on_node_text_and_membership_only() {
let mut graph = Graph::new();
assert_eq!(graph.content_revision(), 0);
let a = graph.add_node("https://a.example".to_string(), Point2D::new(0.0, 0.0));
let b = graph.add_node("https://b.example".to_string(), Point2D::new(1.0, 0.0));
let added = graph.content_revision();
assert!(added >= 2, "each added node is new text");
let structure = graph.revision();
graph.assert_relation(a, b, hyperlink());
assert!(graph.revision() > structure, "the edge is structure");
assert_eq!(graph.content_revision(), added, "an edge is not content");
let structure = graph.revision();
assert!(graph.set_node_title(a, "Saturn's rings".to_string()));
let titled = graph.content_revision();
assert!(titled > added, "a title edit is content");
assert_eq!(graph.revision(), structure, "a title edit is not structure");
assert!(!graph.set_node_title(a, "Saturn's rings".to_string()));
assert_eq!(
graph.content_revision(),
titled,
"an unchanged title is not an edit"
);
graph.update_node_url(b, "https://b.example/page".to_string());
let moved = graph.content_revision();
assert!(moved > titled, "a URL move is content");
graph.update_node_url(b, "https://b.example/page".to_string());
assert_eq!(
graph.content_revision(),
moved,
"the same URL is not a move"
);
assert!(graph.insert_node_tag(a, "astronomy".to_string()));
assert_eq!(graph.content_revision(), moved, "a tag is not title or URL");
graph.remove_node(b);
assert!(
graph.content_revision() > moved,
"removing a node is content"
);
}
#[test]
fn visit_revision_advances_on_visit_history_only() {
use crate::graph::apply::{GraphDelta, apply_graph_delta};
let mut graph = Graph::new();
let a = graph.add_node("https://a.example".to_string(), Point2D::new(0.0, 0.0));
let b = graph.add_node("https://b.example".to_string(), Point2D::new(1.0, 0.0));
let added = graph.visit_revision();
assert!(added >= 2, "each added node's creation visit is a visit");
let (structure, content) = (graph.revision(), graph.content_revision());
assert!(graph.set_node_last_visited_at_ms(a, 1_000));
let visited = graph.visit_revision();
assert!(visited > added, "a visit is a visit");
assert_eq!(graph.revision(), structure, "a visit is not structure");
assert_eq!(graph.content_revision(), content, "a visit is not text");
assert!(!graph.set_node_last_visited_at_ms(a, 1_000));
assert_eq!(graph.visit_revision(), visited, "an unchanged visit");
graph.assert_relation(a, b, hyperlink());
assert!(graph.set_node_title(a, "Saturn".to_string()));
assert!(graph.insert_node_tag(a, "astronomy".to_string()));
assert_eq!(graph.visit_revision(), visited, "not a visit");
let node_id = graph.get_node(b).unwrap().id;
apply_graph_delta(
&mut graph,
GraphDelta::ReplayTouchNodeLastVisitedById {
node_id,
timestamp_ms: 2_000,
},
);
let replayed = graph.visit_revision();
assert!(replayed > visited, "the replay delta is a visit");
apply_graph_delta(
&mut graph,
GraphDelta::SetNodeFacet {
key: b,
facet: "custom.note".to_string(),
value: serde_json::json!({"text": "hello"}),
},
);
assert_eq!(graph.visit_revision(), replayed, "another facet");
apply_graph_delta(
&mut graph,
GraphDelta::ReplaySetNodeFacetById {
node_id,
facet: crate::graph::node_facets::VISIT_HISTORY.to_string(),
value: serde_json::json!({"last_visited_ms": 3_000, "last_session_visited": 0}),
},
);
let generic = graph.visit_revision();
assert!(generic > replayed, "a generic write of visit history");
assert_eq!(
graph
.node_last_visited(b)
.and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok())
.map(|d| d.as_millis()),
Some(3_000),
"the generic write is the one the reader sees"
);
let _ = graph.facets_mut();
assert!(graph.visit_revision() > generic, "raw facet access");
}
#[test]
fn url_grouping_key_matches_site_kanban_authority() {
assert_eq!(
Graph::url_grouping_key("https://example.test:8443/a?b#c"),
"example.test:8443"
);
assert_eq!(Graph::url_grouping_key("mere:opaque"), "mere:opaque");
}
#[test]
fn test_add_node() {
let mut graph = Graph::new();
let pos = Point2D::new(100.0, 200.0);
let key = graph.add_node("https://example.com".to_string(), pos);
let node = graph.get_node(key).unwrap();
assert_eq!(node.url(), "https://example.com");
assert_eq!(node.title, "https://example.com");
assert_eq!(graph.node_is_pinned(key), Some(false));
}
#[test]
fn node_namespace_id_is_deterministic_v5() {
let a = Graph::node_namespace_id("https://example.com/x");
let b = Graph::node_namespace_id("https://example.com/x");
assert_eq!(a, b, "same URL yields the same id on any host");
assert_eq!(a.get_version_num(), 5, "a name-based UUIDv5, not random");
assert_ne!(
a,
Graph::node_namespace_id("https://example.com/y"),
"a different URL gets a different id",
);
}
#[test]
fn test_add_multiple_nodes() {
let mut graph = Graph::new();
let key1 = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let key2 = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
let key3 = graph.add_node("https://c.com".to_string(), Point2D::new(2.0, 2.0));
assert_eq!(graph.node_count(), 3);
assert!(graph.get_node(key1).is_some());
assert!(graph.get_node(key2).is_some());
assert!(graph.get_node(key3).is_some());
}
#[test]
fn test_duplicate_url_nodes_have_distinct_ids() {
let mut graph = Graph::new();
let key1 = graph.add_node("https://same.com".to_string(), Point2D::new(0.0, 0.0));
let key2 = graph.add_node("https://same.com".to_string(), Point2D::new(10.0, 10.0));
assert_ne!(key1, key2);
let node1 = graph.get_node(key1).unwrap();
let node2 = graph.get_node(key2).unwrap();
assert_ne!(node1.id, node2.id);
assert_eq!(graph.get_nodes_by_url("https://same.com").len(), 2);
}
#[test]
fn test_get_node_by_url() {
let mut graph = Graph::new();
graph.add_node("https://example.com".to_string(), Point2D::new(0.0, 0.0));
let (_, node) = graph.get_node_by_url("https://example.com").unwrap();
assert_eq!(node.url(), "https://example.com");
assert!(graph.get_node_by_url("https://notfound.com").is_none());
}
#[test]
fn test_get_node_mut() {
let mut graph = Graph::new();
let key = graph.add_node("https://example.com".to_string(), Point2D::new(0.0, 0.0));
assert!(graph.set_node_pinned(key, true));
assert_eq!(graph.node_is_pinned(key), Some(true));
}
#[test]
fn test_assert_relation() {
let mut graph = Graph::new();
let node1 = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let node2 = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
graph.assert_relation(node1, node2, hyperlink()).unwrap();
assert_eq!(graph.projected_relations_between(node1, node2).count(), 1);
assert!(
!graph.has_edge_between(node1, node2),
"Surface adjacency remains explicit"
);
assert!(!graph.has_edge_between(node2, node1));
assert_eq!(graph.projected_outgoing_relations(node1).count(), 1);
assert_eq!(graph.projected_incoming_relations(node2).count(), 1);
}
#[test]
fn test_assert_relation_invalid_nodes() {
let mut graph = Graph::new();
let node1 = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let invalid_key = NodeIndex::new(999);
assert!(
graph
.assert_relation(invalid_key, node1, hyperlink())
.is_none()
);
assert!(
graph
.assert_relation(node1, invalid_key, hyperlink())
.is_none()
);
}
#[test]
fn test_assert_multiple_relations() {
let mut graph = Graph::new();
let node1 = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let node2 = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
let node3 = graph.add_node("https://c.com".to_string(), Point2D::new(2.0, 2.0));
graph.assert_relation(node1, node2, hyperlink()).unwrap();
graph.assert_relation(node1, node3, hyperlink()).unwrap();
graph.assert_relation(node2, node3, hyperlink()).unwrap();
assert_eq!(graph.resource_relations().count(), 3);
assert_eq!(graph.projected_outgoing_relations(node1).count(), 2);
assert_eq!(graph.projected_incoming_relations(node3).count(), 2);
}
#[test]
fn test_retract_relation_by_sub_kind_between_nodes() {
let mut graph = Graph::new();
let a = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let b = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
graph.assert_relation(a, b, hyperlink()).unwrap();
graph.assert_relation(a, b, user_grouped(None)).unwrap();
let removed = graph.retract_relations(
a,
b,
RelationSelector::Semantic(SemanticSubKind::UserGrouped),
);
assert_eq!(removed, 1);
assert_eq!(
graph.edge_count(),
1,
"withdrawn Surface assertion remains in history"
);
let surface = graph
.find_edge_key(a, b)
.expect("retained Surface tombstone");
assert!(
graph.get_edge(surface).unwrap().semantic_statements()[0]
.withdrawn
.is_some()
);
let (edge_key, payload) = graph
.projected_relations_between(a, b)
.next()
.expect("remaining Resource hyperlink");
assert!(matches!(edge_key, RelationKey::Resource(_)));
assert!(payload.has_relation(RelationSelector::Semantic(SemanticSubKind::Hyperlink)));
assert!(!payload.has_relation(RelationSelector::Semantic(SemanticSubKind::UserGrouped)));
}
#[test]
fn projected_neighbors_reads_both_strata_and_a_self_loop_once() {
let mut graph = Graph::new();
let [a, b, c, d] = ["a", "b", "c", "d"]
.map(|name| graph.add_node(format!("https://{name}.com"), Point2D::new(0.0, 0.0)));
graph.assert_relation(a, b, user_grouped(None)).unwrap();
graph.assert_relation(c, a, hyperlink()).unwrap();
graph.assert_relation(a, a, user_grouped(None)).unwrap();
graph.assert_relation(d, d, hyperlink()).unwrap();
let neighbors = |key| {
let mut found: Vec<_> = graph.projected_neighbors(key).collect();
found.sort_by_key(|node| node.index());
found
};
assert_eq!(
neighbors(a),
vec![a, b, c],
"Surface b, Resource c, itself once"
);
assert_eq!(neighbors(c), vec![a]);
assert_eq!(
neighbors(d),
vec![d],
"a Resource self-loop is read once too"
);
assert_eq!(
graph.neighbors_undirected(a).count(),
2,
"the Surface reader alone sees b and itself"
);
}
#[test]
fn retract_relations_where_leaves_what_the_predicate_refuses() {
use crate::graph::{EdgeFamily, Retraction, SemanticStatementSpec, predicate_iri};
use crate::types::GraphScope;
let mut graph = Graph::new();
let a = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let b = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
for (sub_kind, graph_scope) in [
(SemanticSubKind::Cites, GraphScope::User),
(SemanticSubKind::Quotes, GraphScope::Source),
] {
let spec = SemanticStatementSpec {
predicate: predicate_iri(sub_kind).into(),
recognized_sub_kind: Some(sub_kind),
graph_scope,
..Default::default()
};
graph.try_assert_semantic_statement(a, b, spec).unwrap();
}
assert_eq!(
graph.resource_relations().count(),
1,
"both live on the Resource stratum"
);
let semantic = RelationSelector::Family(EdgeFamily::Semantic);
let done = graph.retract_relations_where(a, b, semantic, |s| s.graph_scope == GraphScope::User);
assert_eq!(
done,
Retraction {
withdrawn: 1,
refused: 1
}
);
let held: Vec<_> = graph
.projected_assertions()
.map(|(_, _, _, statement)| statement.recognized_sub_kind)
.collect();
assert_eq!(held, vec![Some(SemanticSubKind::Quotes)]);
let again = graph.retract_relations_where(a, b, semantic, |_| false);
assert_eq!(
again,
Retraction {
withdrawn: 0,
refused: 1
}
);
}
#[test]
fn statement_assert_dedups_by_content_and_retracts_by_id() {
use crate::graph::SemanticStatementSpec;
use crate::types::GraphScope;
let mut graph = Graph::new();
let a = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let b = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
let cites = SemanticStatementSpec {
predicate: "http://purl.org/spar/cito/cites".to_string(),
graph_scope: GraphScope::User,
provenance_iri: Some("mere://persona/mark".to_string()),
asserted_at_ms: Some(1_000),
..Default::default()
};
let (edge, first) = graph
.assert_semantic_statement(a, b, cites.clone())
.unwrap();
assert!(first.changed, "fresh statement asserts");
let source_scope = SemanticStatementSpec {
graph_scope: GraphScope::Source,
..cites.clone()
};
let (edge2, second) = graph.assert_semantic_statement(a, b, source_scope).unwrap();
assert_eq!(edge, edge2, "one pair bucket");
assert!(second.changed);
assert_ne!(first.statement_id, second.statement_id);
assert_eq!(
graph
.get_relation(edge)
.unwrap()
.semantic_statements()
.len(),
2
);
let (_, again) = graph
.assert_semantic_statement(a, b, cites.clone())
.unwrap();
assert_eq!(again.statement_id, first.statement_id);
assert!(!again.changed, "identical statement is a no-op");
let relabeled = SemanticStatementSpec {
label: Some("cited in the intro".to_string()),
..cites
};
let (_, updated) = graph.assert_semantic_statement(a, b, relabeled).unwrap();
assert_eq!(updated.statement_id, first.statement_id);
assert!(updated.changed);
assert!(graph.retract_semantic_statement(a, b, &first.statement_id));
assert_eq!(
graph
.get_relation(edge)
.unwrap()
.held_semantic_statements()
.count(),
1
);
assert!(
!graph.retract_semantic_statement(a, b, &first.statement_id),
"retract is idempotent per id"
);
assert!(graph.retract_semantic_statement(a, b, &second.statement_id));
assert!(
graph.get_relation(edge).is_some() && graph.resource_relations().count() == 1,
"withdrawal keeps its exact Resource bucket until compaction"
);
}
#[test]
fn test_assert_relation_keeps_surface_and_resource_semantics_separate() {
let mut graph = Graph::new();
let a = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let b = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
let resource = graph.assert_relation(a, b, hyperlink()).unwrap();
graph
.assert_relation(a, b, user_grouped(Some("tab-group")))
.unwrap();
assert_eq!(graph.edge_count(), 1);
let edge_key = graph.find_edge_key(a, b).unwrap();
let payload = graph.get_edge(edge_key).unwrap();
assert!(!payload.has_relation(RelationSelector::Semantic(SemanticSubKind::Hyperlink)));
let content = graph.get_relation(resource).unwrap();
assert!(content.has_relation(RelationSelector::Semantic(SemanticSubKind::Hyperlink)));
assert!(!content.has_relation(RelationSelector::Semantic(SemanticSubKind::UserGrouped)));
assert!(payload.has_relation(RelationSelector::Semantic(SemanticSubKind::UserGrouped)));
assert_eq!(payload.label(), Some("tab-group"));
assert_eq!(graph.relations().count(), 1);
assert_eq!(graph.resource_relations().count(), 1);
assert_eq!(graph.projected_relations().count(), 2);
}
#[test]
fn test_statement_bucket_keeps_multiple_predicates_on_one_stored_edge() {
let mut graph = Graph::new();
let a = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let b = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
let key = graph.assert_relation(a, b, cites()).unwrap();
graph
.assert_semantic_predicate(a, b, "https://schema.org/citation".to_string())
.unwrap();
assert_eq!(graph.edge_count(), 0);
assert_eq!(graph.resource_relations().count(), 1);
let payload = graph.get_relation(key).unwrap();
assert_eq!(payload.semantic_statements().len(), 2);
assert!(payload.semantic_statements().iter().any(|statement| {
statement.recognized_sub_kind == Some(SemanticSubKind::Cites)
&& statement.predicate == "https://mere.computer/ns/rel#cites"
}));
assert!(payload.semantic_statements().iter().any(|statement| {
statement.recognized_sub_kind.is_none()
&& statement.predicate == "https://schema.org/citation"
}));
}
#[test]
fn test_assert_relation_preserves_generic_semantic_subkind() {
let mut graph = Graph::new();
let a = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let b = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
let edge_key = graph
.assert_relation(
a,
b,
EdgeAssertion::Semantic {
sub_kind: SemanticSubKind::SameEntityAs,
label: Some("identity".to_string()),
},
)
.expect("semantic relation should be asserted");
assert!(matches!(edge_key, RelationKey::Resource(_)));
assert!(graph.find_edge_key(a, b).is_none());
let payload = graph
.get_relation(edge_key)
.expect("semantic payload should exist");
assert!(payload.has_relation(RelationSelector::Semantic(SemanticSubKind::SameEntityAs)));
assert_eq!(payload.label(), Some("identity"));
let semantic_edges = graph
.projected_relations()
.map(|(_, row)| row)
.collect::<Vec<_>>();
assert!(semantic_edges.iter().any(|edge| {
edge.from == a
&& edge.to == b
&& edge.kind == RelationKind::Semantic(SemanticSubKind::SameEntityAs)
}));
}
#[test]
fn test_remove_node() {
let mut graph = Graph::new();
let n1 = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let n2 = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
let resource = graph.assert_relation(n1, n2, hyperlink()).unwrap();
graph.assert_relation(n1, n2, user_grouped(None)).unwrap();
assert_eq!(graph.node_count(), 2);
assert_eq!(graph.edge_count(), 1);
assert!(graph.remove_node(n1));
assert_eq!(graph.node_count(), 1);
assert_eq!(graph.edge_count(), 0); assert!(graph.get_node(n1).is_none());
assert!(graph.get_node_by_url("https://a.com").is_none());
assert!(
graph
.get_relation(resource)
.unwrap()
.has_relation(RelationSelector::Semantic(SemanticSubKind::Hyperlink)),
"removing a Surface leaves Resource content held"
);
assert_eq!(graph.resource_relations().count(), 1);
assert!(graph.get_node(n2).is_some());
}
#[test]
fn test_remove_nonexistent_node() {
let mut graph = Graph::new();
assert!(!graph.remove_node(NodeIndex::new(999)));
}
#[test]
fn test_nodes_iterator() {
let mut graph = Graph::new();
graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
graph.add_node("https://c.com".to_string(), Point2D::new(2.0, 2.0));
let urls: Vec<String> = graph.nodes().map(|(_, n)| n.url().to_string()).collect();
assert_eq!(urls.len(), 3);
assert!(urls.contains(&"https://a.com".to_string()));
assert!(urls.contains(&"https://b.com".to_string()));
assert!(urls.contains(&"https://c.com".to_string()));
}
#[test]
fn test_relations_iterator() {
let mut graph = Graph::new();
let node1 = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let node2 = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
let node3 = graph.add_node("https://c.com".to_string(), Point2D::new(2.0, 2.0));
let _ = graph.assert_relation(node1, node2, hyperlink());
let _ = graph.assert_relation(node1, node3, hyperlink());
graph
.assert_relation(node2, node3, user_grouped(None))
.unwrap();
assert_eq!(graph.relations().count(), 1);
let relation_count = graph.resource_relations().count();
assert_eq!(relation_count, 2);
assert!(graph.resource_relations().all(|(_, _, _, payload)| {
payload.has_relation(RelationSelector::Semantic(SemanticSubKind::Hyperlink))
}));
}
#[test]
fn test_empty_graph_operations() {
let graph = Graph::new();
assert_eq!(graph.node_count(), 0);
assert_eq!(graph.edge_count(), 0);
assert!(graph.get_node_by_url("https://example.com").is_none());
let invalid_key = NodeIndex::new(999);
assert!(graph.get_node(invalid_key).is_none());
}
#[test]
fn test_node_count() {
let mut graph = Graph::new();
assert_eq!(graph.node_count(), 0);
graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
assert_eq!(graph.node_count(), 1);
graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
assert_eq!(graph.node_count(), 2);
}
#[test]
fn test_edge_count() {
let mut graph = Graph::new();
let node1 = graph.add_node("https://a.com".to_string(), Point2D::new(0.0, 0.0));
let node2 = graph.add_node("https://b.com".to_string(), Point2D::new(1.0, 1.0));
assert_eq!(graph.edge_count(), 0);
let _ = graph.assert_relation(node1, node2, hyperlink());
assert_eq!(graph.edge_count(), 0);
assert_eq!(graph.resource_relations().count(), 1);
let _ = graph.assert_relation(node2, node1, hyperlink());
assert_eq!(graph.edge_count(), 0);
assert_eq!(graph.resource_relations().count(), 2);
graph
.assert_relation(node1, node2, user_grouped(None))
.unwrap();
assert_eq!(graph.edge_count(), 1);
assert_eq!(graph.resource_relations().count(), 2);
}