Skip to content

Shortest Paths algorithm #2

Open

Description

@lucaspg96

Implement the Minimal Paths (MP) algorithm over a graph

Activity

  1. added 9 commits that reference this issue on Apr 17, 2019
  2. added a commit that references this issue on Apr 29, 2019
  3. added 3 commits that reference this issue on Apr 29, 2019
  4. lucaspg96 commented on May 8, 2019

    @lucaspg96
    MemberAuthor

    Divergence between MinimalPaths result and Dijkstra. To identify the error, just run:

    def main(args: Array[String]): Unit = {
        val graph = NTripleParser.parse("src/main/resources/dbpedia.nt")
        
        val fromNode = graph.getNodeByURI("person@en")
        val toNode = graph.getNodeByURI("Tony Award@en")
        
        val nodes = List(fromNode, toNode)
    
        graph.getLinksAsStream
          .foreach(link => link match {
            case Relation(_, l, t) =>
              if ((l.uri.endsWith("#type") && (t.uri.endsWith("#Class") || t.uri.endsWith("Property"))) ||
                (l.uri.endsWith("#range") && t.uri.contains("XMLSchema#")))
                link.setWeight(100)
              else if (l.uri.contains("rdf-schema#subClassOf"))
                link.setWeight(1)
              else if (l.uri.contains("rdf-schema#sub"))
                link.setWeight(10)
    
            case Attribute(_, l, _) =>
              if(l.uri.endsWith("#label"))
                link.setWeight(10)
    
            case _ =>
          })
    
        MinimalPathsClosure(graph)(nodes)
    
        val path = new DijkstraStrategy(graph).run(nodes.head.getId, nodes(1).getId)
    
        print("Dijkstra cost: "+path.getDistance(nodes(1).getId)+"| Path: ")
        path.printPathTo(nodes(1).getId)
    
      }
    
  5. added a commit that references this issue on May 8, 2019
  6. added a commit that references this issue on May 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions