Class ShortestPathFinder


  • public class ShortestPathFinder
    extends Object
    Implements the shortest path finder class. The shortest path between two concepts c1 and c2 is a path that includes a common subsumer of c1 and c2 (a concept that is a hypernym of both c1 and c2) and has the shortest length.
    Author:
    Kleanthi Georgala (georgala@informatik.uni-leipzig.de)
    • Constructor Detail

      • ShortestPathFinder

        public ShortestPathFinder()
    • Method Detail

      • shortestPath

        public static int shortestPath​(ArrayList<ArrayList<edu.mit.jwi.item.ISynsetID>> synset1Tree,
                                       ArrayList<ArrayList<edu.mit.jwi.item.ISynsetID>> synset2Tree)
        Computes the shortest path between two concepts using their hypernym paths. For each pair of hypernym paths, it traverses both the paths simultaneously, starting from the root and until they share no more common concepts. Then it calculates the path length between the two concepts, as the number of the concepts that they do not have in common. In case the distance between the two concepts is smaller than the previously found one, the algorithm sets it as the new shortest path.
        Parameters:
        synset1Tree - , the hypernym paths of the first concept
        synset2Tree - , the hypernym paths of the second concept
        Returns:
        the length of the shortest path between two concepts