GithubHelp home page GithubHelp logo

Comments (2)

szhorvat avatar szhorvat commented on June 20, 2024

For context on this, please see igraph/rigraph#571. It's not quite settled yet how this will be dealt with in igraph. The original fix restricts the Johnson method to using only mode='out' on directed graphs. The failure here was caused by using mode='in'.

All this said, the test used in sfnetwork does not achieve anything, and I recommend removing or changing it. Johnson's algorithm is intended specifically for directed graphs with some negative edge weights. When there are no negative weights, igraph will just use Dijsktra's algorithm, even if you specified Johnson. Thus the test, in its current form, compares Dijsktra against Dijkstra and can never fail.

Why does igraph just use Dijkstra when there are no negative weights? This makes perfect sense if we look at how Johnson's algorithm works: it simply transforms edge weights to ensure that they are all non-negative, allowing the use of Dijkstra's method instead of the Bellman-Ford algorithm, which has worse asymptotic complexity.

To sum up, I recommend removing the test that @krlmlr referenced, irrespective of how this will be dealt with in igraph 1.3.6. Comparing results between Johnson and Dijkstra makes no sense as the former is only used with negative edge weights, while the latter is only used with non-negative ones.

from sfnetworks.

loreabad6 avatar loreabad6 commented on June 20, 2024

Hi @krlmlr and @szhorvat, thank you for pointing us to this failing test. The aim of the test is jsut to check that parameters are passed correctly onto igraph::distances(), and during creating this test we probably overlooked the conceptual theory of the algorithms. To keep the test alive, I switched the algorithm to unweighted, which should definitely result in different distances.

from sfnetworks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.