How many pair of nodes
in the
following graph
are there such that the shortest path between
and
is length
?
Details and Assumptions
The length of a path is the number of edges it has.
The graph is given in an adjacency matrix representation .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
This adjacency matrix represents a cube. There are 6 unique paths that have a distance of 2 from any given node on this figure, however these paths can be paired up to trace out the 1 face of the cube, and thus both go to the same node. Thus there are 3 nodes that have a distance of two from any given node.
There are 8 nodes, so there are 8*3=24 such pairs.
Note: You will have the each pair of nodes represented twice: once as (a,b) and once as (b,a). So this problem is a little ambiguous in that it doesn't say ordered pairs of points, thus 12 could be argued as a correct answer as well.