getRelationsBetween method

  1. @override
Iterable<Relation> getRelationsBetween(
  1. String fromNodeId,
  2. String toNodeId, {
  3. bool bothDirections = true,
})
override

Get relations from a given node to another (by id)

Implementation

@override
Iterable<Relation> getRelationsBetween(String fromNodeId, String toNodeId,
    {bool bothDirections = true}) {
  List<Relation> side1, side2;
  side1 = _relations
      .where((relation) =>
          relation.toNodeId == toNodeId && relation.fromNodeId == fromNodeId)
      .toList(growable: false);

  if (bothDirections) {
    side2 = _relations
        .where((relation) =>
            relation.fromNodeId == toNodeId &&
            relation.toNodeId == fromNodeId)
        .toList(growable: false);
  } else {
    side2 = [];
  }

  return side1 + side2;
}