pylibmgm.GmModel
- class pylibmgm.GmModel
Pairwise graph matching (GM) model.
Represents a matching problem between two graphs with unary assignment costs and pairwise edge costs. This is the core data structure for single pairwise graph matching problems.
Methods
__init__(*args, **kwargs)Overloaded function.
add_assignment(node1, node2, cost)Add an assignment with its unary cost.
add_edge(*args, **kwargs)Overloaded function.
costs()Access the cost hashmap.
Get number of assignments.
no_edges()Get number of edges.
Attributes
Name
Type
Description
assignment_list
list[tuple[int, int]]
List of all assignments. Index is assignment ID.
graph1
First graph in the matching.
graph2
Second graph in the matching.
- __init__(graph1: Graph, graph2: Graph, no_assignments: int, no_edges: int) None
Create a GM model with pre-allocation.
- add_edge(assignment1: int, assignment2: int, cost: float) None
Add an edge via two assignment IDs.
- Parameters:
assignment1 (int) – First assignment ID.
assignment2 (int) – Second assignment ID.
cost (float) – Pairwise cost of this edge.
- add_edge(assignment1_left: int, assignment1_right: int, assignment2_left: int, assignment2_right: int, cost: float) None
Add an edge via four node IDs.
- Parameters:
assignment1_left (int) – First node of first assignment.
assignment1_right (int) – Second node of first assignment.
assignment2_left (int) – First node of second assignment.
assignment2_right (int) – Second node of second assignment.
cost (float) – Pairwise cost of this edge.
- add_assignment(node1: int, node2: int, cost: float) None
Add an assignment with its unary cost.
- Parameters:
node1 (int) – Node from graph1.
node2 (int) – Node from graph2.
cost (float) – Unary cost of this assignment.
- costs() pylibmgm.CostMap
Access the cost hashmap.
- Returns:
The cost hashmap containing all unary and pairwise costs.
- Return type:
- no_assignments() int
Get number of assignments.
- Returns:
Number of assignments in the model.
- Return type:
int
- no_edges() int
Get number of edges.
- Returns:
Number of edges in the model.
- Return type:
int