# min distance in a graph

How would I find the min distance between two vertices in a graph.

What function should I use?

For example, in the above, $d(2,4)=2$ and $d(2,3)=1$

• By "min distance", do you mean the length of the minimum path between to specified vertices? – m_goldberg May 1 '16 at 3:17

You can use GraphDistance to do that:
g = Graph[{1 <-> 2, 2 <-> 3, 3 <-> 1, 1 <-> 4}];