pylibmgm.MgmSolution
- class pylibmgm.MgmSolution
Solution to a multi-graph matching problem.
Represents a consistent set of pairwise matchings across multiple graphs. The solution can be inspected as a labeling (given for all pairwise models) or as the cycle-consistent set of cliques.
Methods
__init__(model)Create an MGM solution.
cliques()Get the clique structure of the solution.
Create an empty labeling structure fitting the solutions underlying model.
evaluate(*args, **kwargs)Overloaded function.
labeling()Get the full labeling as a dictionary.
set_solution(*args, **kwargs)Overloaded function.
Convert labeling to dictionary with None for unmatched nodes.
Attributes
Name
Type
Description
model
The MGM model for this solution.
- evaluate() float
Evaluate total objective value across all pairwise models.
- Returns:
Total objective value.
- Return type:
float
- evaluate(graph_id: int) float
Evaluate objective restricted to models involving a specific graph.
- Parameters:
graph_id (int) – Graph ID to evaluate.
- Returns:
Objective value for models involving this graph.
- Return type:
float
- set_solution(labeling: dict[tuple[int, int], list[int]]) None
Set solution from a labeling dictionary.
- set_solution(graph_pair: tuple[int, int], labeling: list[int]) None
Set solution for a specific pairwise model.
- set_solution(gm_solution: GmSolution) None
Update solution with a pairwise GM solution.
- __init__(model: pylibmgm.MgmModel) None
Create an MGM solution.
- Parameters:
model (MgmModel) – The MGM model this solution belongs to.
- cliques() list
Get the clique structure of the solution.
- Returns:
List of cliques, each representing matched nodes across graphs.
- Return type:
list[dict]
- create_empty_labeling() Dict[Tuple[int, int], List[int]]
Create an empty labeling structure fitting the solutions underlying model.
- Returns:
Empty labeling dictionary with correct structure.
- Return type:
dict[tuple[int, int], list[int]]
- labeling() Dict[Tuple[int, int], List[int]]
Get the full labeling as a dictionary.
- Returns:
Dictionary mapping (graph1_id, graph2_id) to list of assignments.
- Return type:
dict[tuple[int, int], list[int]]
- to_dict_with_none() dict
Convert labeling to dictionary with None for unmatched nodes.
- Returns:
Labeling dictionary where -1 is replaced with None.
- Return type:
dict