Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortest Paths algorithm #2

Open
lucaspg96 opened this issue Apr 15, 2019 · 1 comment
Open

Shortest Paths algorithm #2

lucaspg96 opened this issue Apr 15, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@lucaspg96
Copy link
Member

Implement the Minimal Paths (MP) algorithm over a graph

@lucaspg96 lucaspg96 added the enhancement New feature or request label Apr 15, 2019
castelojb pushed a commit that referenced this issue Apr 17, 2019
castelojb added a commit that referenced this issue Apr 17, 2019
castelojb pushed a commit that referenced this issue Apr 17, 2019
castelojb pushed a commit that referenced this issue Apr 24, 2019
…th size 1, 1 node, 1 node and 1 edge paths, with 2 nodes and no edges
castelojb pushed a commit that referenced this issue Apr 29, 2019
lucaspg96 pushed a commit that referenced this issue Apr 29, 2019
castelojb pushed a commit that referenced this issue May 6, 2019
@lucaspg96
Copy link
Member Author

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)

  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant