Graph mining: matching

Hello everyone, Please can you help me, i want to write a python script using POO to answer this tasks:
*From an empty graph add one node, two nodes

  • Add an edge
    *Check the matching { subgraph}
  • if no matching go back i.e using recursivity
    I did the matching part, this is the code:

Pleaaase help me i’m struggling.
Thank you in advance