pylibmgm.GmSolution

class pylibmgm.GmSolution

Solution to a pairwise graph matching problem.

Represents an assignment of nodes from graph1 to nodes in graph2 (or unmatched). The labeling uses -1 to indicate that a node is unmatched.

Methods

__init__(*args, **kwargs)

Overloaded function.

evaluate()

Evaluate objective value of this solution.

evaluate_static(model, labeling)

Evaluate objective value for a given model and labeling.

labeling()

Get the labeling as a list.

to_list_with_none()

Convert labeling to Python list with None for unmatched nodes.

Attributes

Name

Type

Description

model

GmModel

The GM model for this solution.

__init__() None

Create an empty GM solution.

__init__(model: GmModel) None

Create a GM solution for a model.

Parameters:

model (GmModel) – The GM model this solution belongs to.

__init__(model: GmModel, labeling: list[int]) None

Create a GM solution with initial labeling.

Parameters:
  • model (GmModel) – The GM model this solution belongs to.

  • labeling (list[int]) – Initial labeling. For each node i in graph1, labeling[i] is the matched node in graph2, or -1 if unmatched.

evaluate() float

Evaluate objective value of this solution.

Returns:

Total objective value.

Return type:

float

static evaluate_static(model: pylibmgm.GmModel, labeling: List[int]) float

Evaluate objective value for a given model and labeling.

Parameters:
  • model (GmModel) – Graph matching model.

  • labeling (list[int]) – Node assignments.

Returns:

Total objective value (sum of unary and pairwise costs).

Return type:

float

labeling() List[int]

Get the labeling as a list.

Index indicates node ID of graph1. Value is node ID of graph2. Value of -1 indicates an unmatched node.

Returns:

Node assignments.

Return type:

list[int]

to_list_with_none() list

Convert labeling to Python list with None for unmatched nodes.

Returns:

Labeling where -1 is replaced with None.

Return type:

list