2
$\begingroup$

These two poker hands are graph isomorphic via a trivial suit-shifting function f:

G = Ah Kc Qd Js Th

H = Ac Kd Qs Jh Tc

V(H) = f(V(G)) where f shifts the suits

Question: how do I represent these hands as graphs such that I can test for isomophism algorithmically? I assume the ranks and suits will have to form a bipartite graph, but I'm not sure how the different cards within the hand should be modeled as nodes.

===EDIT - clarifying the isomorphism===

I would like for the following two hands not to be isomorphic.

G = Ah Kc Qd Js Th

H = Ah Kc Qd Js Tc

Is there any way to restrict the model such that the first case above would be isomorphic but this second case wouldn't?

Put another way, is there any way to constrain the isomorphism tests so that they only allow for suit shifting and not rank shifting functions?

1 Answers 1

2

You should get a complete bipartite graph $G$ where $V(G) = V_1 \cup V_2$ where $V_1 = \left\{ 2,3,\ldots,10,J,Q,K,A \right\}$ and $V_2 = \left\{ Club, Heart, Diamond, Spade \right\}$. Thus a hand of 5 cards can be represented as E' \subset E(G) s.t. |E'|=5. Thus if you can find an isomorphism between two hands, $E_1$ and $E_2$, in the graphs $G_1 = (V,E_1)$ and $G_2 = (V,E_2)$ the two hands will be the same.

  • 0
    @Nicolas Villanueva: No, I only want f(x) where x is a suit, not a rank. Poker hands are only really suit isomorphic, not rank isomorphic, even if the second example appears "equivalent". For example, the following two hands are "isomorphic" by your definition: AcKcQcJcTc and AcKcQcJc9c, with f(T) = 9, but they are not equivalent poker ranks.2011-05-03