RelationshipQuery.h header

#include <ew/app/RelationshipQuery.h>

Namespace ew::app

Enumerations

enum class RelationshipDirection { Both, Outgoing, Incoming }

The direction relationships are followed when measuring distance from a focus entity. Both treats every reference as undirected ("everyone connected to Aria within N hops"); Outgoing follows references the focus makes (who the focus points at); Incoming follows them in reverse (who points at the focus).

Functions

RelationshipGraph ew::app::dropIsolatedNodes(const RelationshipGraph &graph)

The graph with every node that has no incident edge removed; every edge is kept. This is the "hide unconnected entities" option, applied after the other filters have dropped edges.

RelationshipGraph ew::app::filterByCategories(const RelationshipGraph &graph, const std::set< ew::core::CategoryId > &keptCategoryIds)

The sub-graph of graph keeping only the nodes whose category is in keptCategoryIds, and the edges of graph both of whose endpoints are kept. This is the category filter ("only characters", "characters + cities"). Membership is by the node's RelationshipNode::categoryId; to include uncategorized entities, put a null CategoryId in the set.

RelationshipGraph ew::app::filterByEdgeLabels(const RelationshipGraph &graph, const std::set< QString > &hiddenLabels)

The graph with every edge whose label is in hiddenLabels removed; every node is kept. This is the relationship-type filter (hide "Spouse" links, etc.).

RelationshipGraph ew::app::neighborhood(const RelationshipGraph &graph, ew::core::ContentId focusId, int depth, RelationshipDirection direction)

The sub-graph of graph within depth hops of focusId in direction: every node whose nodeDepths distance is at most depth (or every reachable node when depth is kAllDepths / negative), and the edges of graph both of whose endpoints are kept. Node data (name, category) is preserved. An empty graph when focusId is not a node of graph.

std::map< ew::core::ContentId, int > ew::app::nodeDepths(const RelationshipGraph &graph, ew::core::ContentId focusId, RelationshipDirection direction)

The hop distance from focusId to every reachable node in graph, following edges in the chosen direction (Both = undirected). The focus itself maps to 0; nodes not reachable in that direction are absent. An empty map when focusId is not a node of graph.

std::vector< ew::core::ContentId > ew::app::shortestRelationshipPath(const RelationshipGraph &graph, ew::core::ContentId a, ew::core::ContentId b)

The shortest chain of relationships connecting a to b, as the sequence of node ids from a to b inclusive (edges are treated as undirected — a relationship connects both ways). Returns {a} when a == b and a is a node; an empty vector when either id is not a node of graph or no path exists. Used by the Find Path feature (breadth-first, so the chain has the fewest hops).

Constants

int ew::app::kAllDepths = -1

The depth passed to neighborhood to mean "the whole reachable component" (no hop bound).