public int getPathLengthInEdges ( Category node1 , Category node2 ) { if ( this . graph . containsVertex ( node1 . getPageId ( ) ) && this . graph . containsVertex ( node2 . getPageId ( ) ) ) { if ( node1 . getPageId ( ) == node2 . getPageId ( ) ) { return 0 ; } // get the path from root node to node 1 List edgeList = DijkstraShortestPath . findPathBetween ( undirectedGraph , node1 . getPageId ( ) , node2 . getPageId ( ) ) ; if ( edgeList == null ) { return - 1 ; } else { return edgeList . size ( ) ; } } // if the given nodes are not in the category graph, return -1 else { return - 1 ; } }
Gets the path length between two category nodes - measured in edges .