See the comments for the ugraphs library.
Graph is a labeled graph of Type terms.
This one is a copy of the same procedure in library(wgraphs) except for the definition of min/3 (ah! - the polimorphism!).
It would only be needed if there are multi-edges, i.e., several edges between the same two vertices.