Git Product home page Git Product logo

dijkstras-algorithm's People

Contributors

cbloodsworth avatar chocti avatar juur avatar kinow avatar mathieunls avatar mburst avatar theyak avatar zabio3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dijkstras-algorithm's Issues

How to operate on 2d array

Hi, I'm wondering if I can use this algorithm for a 2d array, I have a matrix: Node[][], and I'm trying to get the shortest route between 2 points

class Node{
   index: {
     x: number,
     y: number
   },
   isAvailable: boolean        //trees are false
}

capture

I tried this, but doesn't seem that I'm filling the graph correctly

const graph = new Dijkstra();

//convert the matrix (2d array) to graph
matrix.map((row) => {
  row.map((node: Node) => {
     let x = node.index.x;
     let y = node.index.y;
     graph.addVertex(x + ":" + y, {x: x, y: y}); 
  });
});
console.log(graph.shortestPath('0:0', '5:5'));
//output is ["0:0"]

Is it possible to get the shortest path using the algorithm?

License?

Just wondering how this repo is licensed... thanks!

Add .editorconfig file with commom coding styles

I realised that the algoritms are very different in coding design style.

This can make things harder for newbies, cause the scripts look too different.

Similar scripts will increase the recognition capability between different languages will and make things easier to understand in a generic approach.

How SORT function is working in this program?

nodes.Sort((x, y) => distances[x] - distances[y]);

What is this line in the program is doing. Yes i know that it is sorting the list Nodes but the statement inside the brackets. Can anybody tell me how this line is working in program in detail.

Error

Java
System.out.println(g.getShortestPath('B', 'A'));
[A, B, C, D, E, F, G, H]
WTH?

And many errors:
A -> B
[B]

A -> C
[C]

A -> D
[D, F, B]

A -> E
[E, H, F, B]

A -> F
[F, B]

A -> G
[G, C]

A -> H
[H, F, B]

B -> A
[A, B, C, D, E, F, G, H]

B -> C
[]

B -> D
[A, B, C, D, E, F, G, H]

B -> E
[A, B, C, D, E, F, G, H]

B -> F
[A, B, C, D, E, F, G, H]

B -> G
[A, B, C, D, E, F, G, H]

B -> H
[A, B, C, D, E, F, G, H]

C -> A
[A]

C -> B
[B, F]

C -> D
[D, F]

C -> E
[E, H, F]

C -> F
[F]

C -> G
[G]

C -> H
[H, F]

D -> A
[A, B, C, D, E, F, G, H]

D -> B
[A, B, C, D, E, F, G, H]

D -> C
[]

D -> E
[A, B, C, D, E, F, G, H]

D -> F
[A, B, C, D, E, F, G, H]

D -> G
[A, B, C, D, E, F, G, H]

D -> H
[A, B, C, D, E, F, G, H]

E -> A
[A, B, C, D, E, F, G, H]

E -> B
[A, B, C, D, E, F, G, H]

E -> C
[]

E -> D
[A, B, C, D, E, F, G, H]

E -> F
[A, B, C, D, E, F, G, H]

E -> G
[A, B, C, D, E, F, G, H]

E -> H
[A, B, C, D, E, F, G, H]

F -> A
[]

F -> B
[A, B, C, D, E, F, G, H]

F -> C
[A, B, C, D, E, F, G, H]

F -> D
[A, B, C, D, E, F, G, H]

F -> E
[A, B, C, D, E, F, G, H]

F -> G
[A, B, C, D, E, F, G, H]

F -> H
[A, B, C, D, E, F, G, H]

G -> A
[]

G -> B
[A, B, C, D, E, F, G, H]

G -> C
[A, B, C, D, E, F, G, H]

G -> D
[A, B, C, D, E, F, G, H]

G -> E
[A, B, C, D, E, F, G, H]

G -> F
[A, B, C, D, E, F, G, H]

G -> H
[A, B, C, D, E, F, G, H]

H -> A
[A, B, C, D, E, F, G, H]

H -> B
[A, B, C, D, E, F, G, H]

H -> C
[]

H -> D
[A, B, C, D, E, F, G, H]

H -> E
[A, B, C, D, E, F, G, H]

H -> F
[A, B, C, D, E, F, G, H]

H -> G
[A, B, C, D, E, F, G, H]

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.