API Documentation¶
-
class
cliquematch.Graph¶ -
-
get_max_clique()¶ Finds a maximum clique in graph within the given bounds
- Parameters
lower_bound (int) – set a lower bound on the clique size. default is 1.
upper_bound (int) – set an upper bound on the clique size. default is 65535.
time_limit (float) – set a time limit for the search: a nonpositive value implies there is no time limit (use in conjunction with
continue_search). default is -1.use_heuristic (bool) – if
True, use the heuristic-based search to obtain a large clique quickly. Good for obtaining an initial lower bound. default isTrue.use_dfs (bool) – if
True, use the depth-first to obtain the clique. default isTrue.continue_search (bool) – set as
Trueto continue a clique search interrupted bytime_limit. default isFalse.
- Returns
the vertices in the maximum clique
- Return type
- Raises
RuntimeError – if the graph is empty or a clique could not be found
-
reset_search()¶ Reset the search space for
get_max_clique.- Raises
RuntimeError – if the graph is empty
-
all_cliques(size)¶ Iterate through all cliques of a given size in the
Graph.- Parameters
size (int) – size of a clique to search for.
- Return type
- Raises
RuntimeError – if the graph is empty
-
static
from_file()¶ Constructs
Graphinstance from reading a Matrix Market file- Parameters
filename (str) –
- Returns
the loaded
Graph- Raises
RuntimeError – if the file could not be read
-
static
from_edgelist()¶ Constructs
Graphinstance from the given edge list. Note that vertex indices must start from 1.- Parameters
edgelist (numpy.ndarray) – shape
(n,2)num_vertices (int) –
- Returns
the loaded
Graph- Raises
RuntimeError – if any value in
edgelistis greater thannum_verticesRuntimeError – if value in
edgelistis0
-
static
from_matrix()¶ Constructs
Graphinstance from the given boolean adjacency matrix- Parameters
adjmat (numpy.ndarray) –
boolsquare matrix- Returns
the loaded
Graph- Raises
RuntimeError – if
adjmatis not square or the edges could not be constructed
-
static
from_adjlist()¶ Constructs
Graphinstance from the given adjacency list. Note that the first element of the list must be an emptyset, vertex indices start at 1.
-
to_file()¶ Exports
Graphinstance to a Matrix Market file- Parameters
filename (str) –
- Raises
RuntimeError – if the file could not be opened, or if the graph is empty
-
to_edgelist()¶ Exports
Graphinstance to an edge list- Returns
(n,2)numpy.ndarrayof edges- Raises
RuntimeError – if the graph is empty
-
to_matrix()¶ Exports
Graphinstance to a boolean matrix- Returns
square
numpy.ndarrayofbools- Raises
RuntimeError – if the graph is empty
-
to_adjlist()¶ Exports
Graphinstance to an adjacency list- Returns
- Raises
RuntimeError – if the graph is empty
-
-
class
cliquematch.NWGraph¶ -
-
get_max_clique()¶ Finds a maximum clique in graph within the given bounds
- Parameters
lower_bound (float) – set a lower bound on the clique size. default is 1.
upper_bound (float) – set an upper bound on the clique size. default is 65535.
use_heuristic (bool) – if
True, use the heuristic-based search to obtain a large clique quickly. Good for obtaining an initial lower bound. default isTrue.use_dfs (bool) – if
True, use the depth-first to obtain the clique. default isTrue.
- Returns
the vertices in the maximum clique
- Return type
- Raises
RuntimeError – if the graph is empty or a clique could not be found
-
reset_search()¶ Reset the search space for
get_max_clique.- Raises
RuntimeError – if the graph is empty
-
all_cliques(size)¶ Iterate through all cliques of a given size in the
NWGraph.- Parameters
size (float) – size of a clique to search for.
- Return type
- Raises
RuntimeError – if the graph is empty
-
get_clique_weight(clique)¶ Return the weight of the provided clique.
- Parameters
clique (list) – a clique obtained via
get_max_clique.- Return type
-
static
from_edgelist()¶ Constructs
NWGraphinstance from the given edge list. Note that vertex indices must start from 1.- Parameters
edgelist (numpy.ndarray) – shape
(n,2)num_vertices (int) –
- Returns
the loaded
NWGraph- Raises
RuntimeError – if any value in
edgelistis greater thannum_verticesRuntimeError – if value in
edgelistis0
-
static
from_matrix()¶ Constructs
NWGraphinstance from the given boolean adjacency matrix- Parameters
adjmat (numpy.ndarray) –
boolsquare matrix- Returns
the loaded
NWGraph- Raises
RuntimeError – if
adjmatis not square or the edges could not be constructed
-
static
from_adjlist()¶ Constructs
NWGraphinstance from the given adjacency list. Note that the first element of the list must be an emptyset, vertex indices start at 1.
-
to_edgelist()¶ Exports
NWGraphinstance to an edge list- Returns
(n,2)numpy.ndarrayof edges- Raises
RuntimeError – if the graph is empty
-
to_matrix()¶ Exports
NWGraphinstance to a boolean matrix- Returns
square
numpy.ndarrayofbools- Raises
RuntimeError – if the graph is empty
-
to_adjlist()¶ Exports
NWGraphinstance to an adjacency list- Returns
- Raises
RuntimeError – if the graph is empty
-
-
class
cliquematch.A2AGraph(set1, set2, d1=None, d2=None, is_d1_symmetric=True, is_d2_symmetric=True)¶ Correspondence Graph wrapper for array-to-array mappings.
-
S1¶ array elements are converted to
numpy.float64- Type
-
S2¶ array elements are converted to
numpy.float64- Type
-
d1¶ distance metric for elements in
S1, defaults to Euclidean metric ifNone.- Type
callable(numpy.ndarray,int,int) ->float
-
d2¶ distance metric for elements in
S2, defaults to Euclidean metric ifNone- Type
callable(numpy.ndarray,int,int) ->float
-
all_correspondences(size, return_indices=True)¶ Find all correspondences of a given size.
- Parameters
- Returns
a wrapped
CorrespondenceIteratorobject, which yields correspondences as perreturn_indices.- Return type
- Raises
RuntimeError – if called before edges have been constructed
-
build_edges()¶ Build edges of the correspondence graph using distance metrics.
Checks
d1andd2for defaults before passing to base class.- Raises
RuntimeError – if
d1ord2are invalid functions- Returns
Trueif construction was successful- Return type
-
build_edges_with_condition(condition_func, use_cfunc_only)¶ Build edges of the correspondence graph using a given condition function.
- Parameters
- Returns
Trueif construction was successful- Raises
RuntimeError – if
d1,d2, orcondition_funcare invalid functions
-
get_correspondence(lower_bound=1, upper_bound=65535, time_limit=- 1.0, use_heuristic=True, use_dfs=True, continue_search=False, return_indices=True)¶ Get corresponding subsets between the
S1andS2. Callsget_max_cliqueinternally.- Parameters
lower_bound (
int) – set a lower bound for the sizeupper_bound (
int) – set an upper bound for the sizetime_limit (
float) – set a time limit for the search: a nonpositive value implies there is no time limit (use in conjunction withcontinue_search).use_heuristic (
bool) – ifTrue, use the heuristic-based search to obtain a large clique quickly. Good for obtaining an initial lower bound.use_dfs (
bool) – ifTrue, use the depth-first to obtain the clique. default isTrue.continue_search (
bool) – set asTrueto continue a clique search interrupted bytime_limit.return_indices (
bool) – ifTruereturn the indices of the corresponding elements, else return the elements
- Raises
RuntimeError – if called before edges are constructed
RuntimeError – if search parameters are invalid / clique is not found
RuntimeError – if obtained correspondence is invalid
-
-
class
cliquematch.L2LGraph(set1, set2, d1=None, d2=None, is_d1_symmetric=True, is_d2_symmetric=True)¶ Correspondence Graph wrapper for list-to-list mappings.
Any
objectcan be passed forS1andS2; the user is required to define how the elements are accessed.-
S1¶ array elements are converted to
numpy.float64- Type
-
S2¶ array elements are converted to
numpy.float64- Type
-
all_correspondences(size, return_indices=True)¶ Find all correspondences of a given size.
- Parameters
- Returns
a wrapped
CorrespondenceIteratorobject, which yields correspondences as perreturn_indices.- Return type
- Raises
RuntimeError – if called before edges have been constructed
-
build_edges()¶ Build edges of the correspondence graph using distance metrics.
Checks
d1andd2for defaults before passing to base class.- Raises
RuntimeError – if
d1ord2are invalid functions- Returns
Trueif construction was successful- Return type
-
build_edges_with_condition(condition_func, use_cfunc_only)¶ Build edges of the correspondence graph using a given condition function.
- Parameters
- Returns
Trueif construction was successful- Raises
RuntimeError – if
d1,d2, orcondition_funcare invalid functions
-
get_correspondence(lower_bound=1, upper_bound=65535, time_limit=- 1.0, use_heuristic=True, use_dfs=True, continue_search=False, return_indices=True)¶ Get corresponding subsets between the
S1andS2. Callsget_max_cliqueinternally.- Parameters
lower_bound (
int) – set a lower bound for the sizeupper_bound (
int) – set an upper bound for the sizetime_limit (
float) – set a time limit for the search: a nonpositive value implies there is no time limit (use in conjunction withcontinue_search).use_heuristic (
bool) – ifTrue, use the heuristic-based search to obtain a large clique quickly. Good for obtaining an initial lower bound.use_dfs (
bool) – ifTrue, use the depth-first to obtain the clique. default isTrue.continue_search (
bool) – set asTrueto continue a clique search interrupted bytime_limit.return_indices (
bool) – ifTruereturn the indices of the corresponding elements, else return the elements
- Raises
RuntimeError – if called before edges are constructed
RuntimeError – if search parameters are invalid / clique is not found
RuntimeError – if obtained correspondence is invalid
-
-
class
cliquematch.L2AGraph(set1, set2, d1=None, d2=None, is_d1_symmetric=True, is_d2_symmetric=True)¶ Correspondence Graph wrapper for list-to-array mappings.
Any general object can be passed for
S1; the user is required to define how elements are accessed.-
S2¶ array elements are converted to
numpy.float64- Type
-
d2¶ distance metric for elements in
S2, defaults to Euclidean metric ifNone- Type
callable(numpy.ndarray,int,int) ->float
-
all_correspondences(size, return_indices=True)¶ Find all correspondences of a given size.
- Parameters
- Returns
a wrapped
CorrespondenceIteratorobject, which yields correspondences as perreturn_indices.- Return type
- Raises
RuntimeError – if called before edges have been constructed
-
build_edges()¶ Build edges of the correspondence graph using distance metrics.
Checks
d1andd2for defaults before passing to base class.- Raises
RuntimeError – if
d1ord2are invalid functions- Returns
Trueif construction was successful- Return type
-
build_edges_with_condition(condition_func, use_cfunc_only)¶ Build edges of the correspondence graph using a given condition function.
- Parameters
- Returns
Trueif construction was successful- Raises
RuntimeError – if
d1,d2, orcondition_funcare invalid functions
-
get_correspondence(lower_bound=1, upper_bound=65535, time_limit=- 1.0, use_heuristic=True, use_dfs=True, continue_search=False, return_indices=True)¶ Get corresponding subsets between the
S1andS2. Callsget_max_cliqueinternally.- Parameters
lower_bound (
int) – set a lower bound for the sizeupper_bound (
int) – set an upper bound for the sizetime_limit (
float) – set a time limit for the search: a nonpositive value implies there is no time limit (use in conjunction withcontinue_search).use_heuristic (
bool) – ifTrue, use the heuristic-based search to obtain a large clique quickly. Good for obtaining an initial lower bound.use_dfs (
bool) – ifTrue, use the depth-first to obtain the clique. default isTrue.continue_search (
bool) – set asTrueto continue a clique search interrupted bytime_limit.return_indices (
bool) – ifTruereturn the indices of the corresponding elements, else return the elements
- Raises
RuntimeError – if called before edges are constructed
RuntimeError – if search parameters are invalid / clique is not found
RuntimeError – if obtained correspondence is invalid
-
-
class
cliquematch.A2LGraph(set1, set2, d1=None, d2=None, is_d1_symmetric=True, is_d2_symmetric=True)¶ Correspondence Graph wrapper for array-to-list mappings.
Any general object can be passed for
S2; the user is required to define how elements are accessed.-
S1¶ array elements are converted to
numpy.float64- Type
-
d1¶ distance metric for elements in
S1, defaults to Euclidean metric ifNone- Type
callable(numpy.ndarray,int,int) ->float
-
all_correspondences(size, return_indices=True)¶ Find all correspondences of a given size.
- Parameters
- Returns
a wrapped
CorrespondenceIteratorobject, which yields correspondences as perreturn_indices.- Return type
- Raises
RuntimeError – if called before edges have been constructed
-
build_edges()¶ Build edges of the correspondence graph using distance metrics.
Checks
d1andd2for defaults before passing to base class.- Raises
RuntimeError – if
d1ord2are invalid functions- Returns
Trueif construction was successful- Return type
-
build_edges_with_condition(condition_func, use_cfunc_only)¶ Build edges of the correspondence graph using a given condition function.
- Parameters
- Returns
Trueif construction was successful- Raises
RuntimeError – if
d1,d2, orcondition_funcare invalid functions
-
get_correspondence(lower_bound=1, upper_bound=65535, time_limit=- 1.0, use_heuristic=True, use_dfs=True, continue_search=False, return_indices=True)¶ Get corresponding subsets between the
S1andS2. Callsget_max_cliqueinternally.- Parameters
lower_bound (
int) – set a lower bound for the sizeupper_bound (
int) – set an upper bound for the sizetime_limit (
float) – set a time limit for the search: a nonpositive value implies there is no time limit (use in conjunction withcontinue_search).use_heuristic (
bool) – ifTrue, use the heuristic-based search to obtain a large clique quickly. Good for obtaining an initial lower bound.use_dfs (
bool) – ifTrue, use the depth-first to obtain the clique. default isTrue.continue_search (
bool) – set asTrueto continue a clique search interrupted bytime_limit.return_indices (
bool) – ifTruereturn the indices of the corresponding elements, else return the elements
- Raises
RuntimeError – if called before edges are constructed
RuntimeError – if search parameters are invalid / clique is not found
RuntimeError – if obtained correspondence is invalid
-
-
class
cliquematch.IsoGraph(set1, set2)¶ Correspondence graph for finding subgraph isomorphisms.
-
S1¶ - Type
-
S2¶ - Type
-
build_edges()¶ Build edges of the correspondence graph.
-
get_correspondence(lower_bound=1, upper_bound=65535, time_limit=- 1.0, use_heuristic=True, use_dfs=True, continue_search=False, return_indices=True)¶ Obtain the corresponding vertices in the subgraph isomorphism.
- Parameters
lower_bound (
int) – set a lower bound for the sizeupper_bound (
int) – set an upper bound for the sizetime_limit (
float) – set a time limit for the search: a nonpositive value implies there is no time limit (use in conjunction withcontinue_search).use_heuristic (
bool) – ifTrue, use the heuristic-based search to obtain a large clique quickly. Good for obtaining an initial lower bound.use_dfs (
bool) – ifTrue, use the depth-first to obtain the clique. default isTrue.continue_search (
bool) – set asTrueto continue a clique search interrupted bytime_limit.return_indices (
bool) – ifTruereturn the vertices of the corresponding subgraphs, else returndicts for each corresponding subgraph and adictmapping the vertices.
- Raises
RuntimeError – if called before edges are constructed
RuntimeError – if search parameters are invalid / clique is not found
RuntimeError – if obtained correspondence is invalid
-
all_correspondences(size, return_indices=True)¶ Find all correspondences of a given size.
- Parameters
- Returns
a wrapped
CorrespondenceIteratorobject, which yields correspondences as perreturn_indices.- Return type
- Raises
RuntimeError – if called before edges are constructed
-
-
class
cliquematch.AlignGraph(set1, set2)¶ Correspondence graph for aligning images using obtained interest points.
Uses a mask-based filtering method as a conditon function during construction of the graph. Default Euclidean metrics are used as distance metrics.
-
S1¶ array elements are converted to
numpy.float64- Type
-
S2¶ array elements are converted to
numpy.float64- Type
-
build_edges_with_filter(control_points, filter_mask, percentage)¶ Uses control points and a binary mask to filter out invalid mappings and construct a correspondence graph.
- Parameters
control_points (
numpy.ndarray) – control points to use in every alignment testfilter_mask (
numpy.ndarray) – a boolean mask showing valid regions in the target imagepercentage (
float) – an alignment is valid if the number of control points that fall within the mask are greater than this value
-
get_correspondence(lower_bound=1, upper_bound=65535, time_limit=- 1.0, use_heuristic=True, use_dfs=True, continue_search=False, return_indices=True)¶ Find correspondence between the sets of points
S1andS2. Callsget_max_cliqueinternally.- Parameters
lower_bound (
int) – set a lower bound for the sizeupper_bound (
int) – set an upper bound for the sizetime_limit (
float) – set a time limit for the search: a nonpositive value implies there is no time limit (use in conjunction withcontinue_search).use_heuristic (
bool) – ifTrue, use the heuristic-based search to obtain a large clique quickly. Good for obtaining an initial lower bound.use_dfs (
bool) – ifTrue, use the depth-first to obtain the clique. default isTrue.continue_search (
bool) – set asTrueto continue a clique search interrupted bytime_limit.return_indices (
bool) – ifTruereturn the indices of the corresponding elements, else return the belowdict
- Returns
The two sets of corresponding points and the rotation/translation required to transform
S1toS2(obtained via Kabsch Algorithm)- Return type
- Raises
RuntimeError – if called before edges are constructed
RuntimeError – if search parameters are invalid / clique is not found
RuntimeError – if obtained correspondence is invalid
-
-
class
cliquematch._WrappedIterator¶ Wrapper for a
CorrespondenceIteratorobject to provide results as perreturn_indices. Satisfies theiter/nextprotocol.
-
class
cliquematch.core.CliqueIterator¶ A class satisfying the
iter/nextprotocol to produces cliques of a given size from aGraph.