As I noted in the SO comment for the question, I will help guide you to a possible solution but you will be writing the code so expect do some leg work.
Since the goal is to translate the execution of the Prolog code into a graph with the edges being calls to goals and the nodes being goals (statements) you will need a way to capture the steps as they occur. One common way is to use a meta interpreter but trying to create one that works for all of the SWI-Prolog code is not easy. What I find easier is to use prolog_trace_interception/4.
See: Example of prolog_trace_interception/4.
Get the example working and ask questions if necessary.
Some questions I have about your diagram.
Did you make this or is it from somewhere? I ask because if it is from somewhere then there may be code that can be reused.
Can you explain the meaning of the edge labels. I have an idea but it is more of a guess than knowing.
What means do you plan to use to represent the graph?
Some I know are GraphViz, Cytoscape.js and Visio.
It does not need to be know at this moment but it does have a big impact on about half of the code that needs to be written.