Graph algorithm to match labled edges to sequence of labled edges

I’m looking for a standard algorithm to solve a particular type of graph matching problem. Consider the following two graphs:

Graph 1 1 --A--> 3 1 --B--> 2 2 --C--> 3 4 --A--> 8 4 --B--> 5 5 --C--> 6  Graph 2 1 --X--> 3 4 --X--> 6 

When these are matched, I’m looking for a result as follows:

Graph 1:    a --B--> ? --C--> b             == Graph 2:    a --X--> b 

That is, edge X of Graph 2 maps to path BC of Graph 1. The reason is that the start and end vertices joined with edge X in Graph 2 are same as the start and end vertices joined by path BC in Graph 1. Edges labeled A in Graph 1 represent extraneous connections.

Is there a standard algorithm to solve this, especially one implemented in Python? If so, what is it called?