Defined in File SubgraphIsomorphism.hpp
public NetworKit::Algorithm (Class Algorithm)
public NetworKit::VF2 (Class VF2)
Abstract base class for subgraph isomorphism algorithms.
The algorithms find every match of a small pattern graph in a large target graph. A match maps the pattern nodes injectively to target nodes and every pattern edge to a target edge. Under Semantics::INDUCED, the default, it also maps every pattern non-edge to a target non-edge. The search finds an occurrence once per automorphism of the pattern, so a triangle occurs six times.
Pattern and target must both be directed or both be undirected, and the pattern must not contain self-loops. The search ignores edge weights and target self-loops, and it collapses parallel edges. The algorithm holds both graphs by reference, so they must outlive it. Since the graphs may change after construction, run() validates them and the labels each time.
Subclassed by NetworKit::VF2
Public Types
Values:
Pattern edges map to target edges and pattern non-edges map to target non-edges.
Pattern edges map to target edges. Additional target edges are allowed.
Public Functions
Runs the search. If a callback throws or CTRL+C interrupts the search, run() stops and rethrows, and the results stay unavailable.
std::runtime_error – If the graphs break the requirements above, or if the labels do not fit the graphs.
Restricts matches to map every pattern node to a target node with the same label. The label none matches any label, and two empty spans remove the labels. The labels are copied. Call this before run(), which throws if a span is shorter than the node id bound of its graph.
patternNodeLabels – Labels of the pattern nodes, indexed by node id.
targetNodeLabels – Labels of the target nodes, indexed by node id.
Restricts matches to map every pattern edge to a target edge with the same label. The label none matches any label, and two empty spans remove the labels. The labels are copied. Call this before run(), which throws if a graph has no edge ids (see Graph::indexEdges()), if a span is shorter than the edge id bound of its graph, or for parallel edges with different labels.
patternEdgeLabels – Labels of the pattern edges, indexed by edge id.
targetEdgeLabels – Labels of the target edges, indexed by edge id.
Passes every match to callback instead of storing it, so getMatches() throws. Replaces an earlier callback. Call this before run().
Sets whether matches are stored. Pass false to only count them, so getMatches() throws. Call this before run().
Returns the matches of the last run(). Throws if run() has not finished, or if that run did not store the matches because a callback was set or matches were only counted.
Returns whether a match was found. Pass maxMatches = 1 to stop at the first one.
Protected Functions
std::invalid_argument – If semantics is not a known value.
Records one match. Returns false once the cap is reached.
Marks the run as finished.