Skip to content

Conversation

@Driolar
Copy link
Contributor

@Driolar Driolar commented Sep 20, 2025

Description

This PR contributes with the implementation of the Greedy Matching Algorithm.

The algorithm class can be instantiated for

  • greedy maximum weighted matching (in weighted graphs)
  • greedy minimum weighted matching (in weighted graphs)
  • greedy maximum cardinality matching (in weighted or unweighted graphs).

Changes

  • Added AIGreedyMatching class with Greedy Matching Algorithm implementation.
  • Added AIGreedyMatchingTest class with tests.

@Ducasse
Copy link
Contributor

Ducasse commented Sep 20, 2025

Thank you.
@jordanmontt seb do you have a look?

@jordanmontt
Copy link
Member

Hello, thanks for the PR!

If I understood correctly, this is a greedy algorithm for producing a minimal spanning tree, right?

I think that it will be better if we rename the classes because people can get confused. We can have different types of greedy algorithms, as a greedy algorithm is an algorithm that takes the best decision at each step

@Driolar
Copy link
Contributor Author

Driolar commented Sep 23, 2025

Hello, thanks for the answer.

No, it is not about a minimal spanning tree but about matching as explained here: https://en.wikipedia.org/wiki/Matching_(graph_theory)

As far as I could see, matching is the usual term mostly used in graph theory. Alternative name: independent edge set.
So this is a greedy algorithm for the matching problem. There are more expensive but exact algorithms like the Blossom algorithm that could perhaps occasionally enrich the (new) "Matching" category in the AI-Algorithms-Graph package.

So in my opinion, the name AIGreedyMatching is adequate, the more so as the class comment explains the concept. The name AIGreedyIndependentEdgeSet may be too heavy but acceptable.

@jordanmontt
Copy link
Member

I see, I got confused too! I propose to name it AIGraphMatchingAlgorithm; what do you think? We can put in the class comment that the current implementation uses a greedy algorithm technique.

I would not like to put "Greedy" in the name as it can mean several things and we have several different algos

@Driolar
Copy link
Contributor Author

Driolar commented Sep 24, 2025

I respect the reasons for not using the term greedy in the class name, although some graph library does so.

So I would definitely use the proposed name AIGraphMatchingAlgorithm, which is pretty comprehensive. Maybe we could rename it in the future still to AIGraphMatchingGreedyAlgorithm if other more elaborated graph matching algorithms are added. I also would rename the category Matching into Graph Matching, since matching is a quite general term.

I am going to prepare the next draft including the renamings and modified comments.

@Driolar Driolar marked this pull request as draft September 24, 2025 17:58
@Ducasse
Copy link
Contributor

Ducasse commented Sep 24, 2025

Tx Driolar this is super nice to have people improving. I'm quite lame with Graph.
If you want after we can enhance the booklet on graph we have and include your work.
One day I would like to get it published :)

Copy link
Contributor Author

@Driolar Driolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Renamed classes into AIGraphMatchingAlgorithm and AIGraphMatchingAlgorithmTest as discussed.
  • Renamed category "Matching" into "Graph Matching" as proposed.
  • Improved comments.
  • Minor improvements in a few methods.
  • Added a single test.

@Driolar Driolar marked this pull request as ready for review September 24, 2025 20:16
@jordanmontt
Copy link
Member

Hello, thanks for the fixes! and for the discussion I will integrate this PR.

Maybe we could rename it in the future still to AIGraphMatchingGreedyAlgorithm if other more elaborated graph matching algorithms are added.

I totally agree with this. If we add more matching algos we can do the renaming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants