Code Monkey home page Code Monkey logo

godijkstra's Introduction

Go-Dijkstra

Build Status

Description

This is a library for the Go programming language implementing the Dijkstra, Dijkstra bidirectional and Yen's graph search algorithms. It works with any graph object implementing the GraphObject interface, having therefore means of getting the successors and predecessors of any graph node and the weight of any edge in the graph.

Installation

This package can be installed with the go get command:

go get github.com/kirves/godijkstra/dijkstra

Example

After creating a graph object it is simply a matter of calling the desired search algorithm function:

path, valid := dijkstra.SearchPath(graph, "START", "END", dijkstra.VANILLA)

for standard Dijkstra algorithm

or

path, valid := dijkstra.SearchPath(graph, "START", "END", dijkstra.BIDIR)

for the bidirectional version of the algorithm.

Yen's algorithm returns the k-shortest paths from a graph, using both a search algorithm and a deviation algorithm:

paths := yen.Yen(graph, "START", "END", k, searchFunc)

where k is the number of paths to find and searchFunc is the search algorithm to use (the Dijkstra algorithm implemented in this package is fine).

Documentation

API documentation can be found here: http://godoc.org/github.com/kirves/godijkstra/dijkstra

godijkstra's People

Contributors

kirves avatar

Stargazers

 avatar Alex Rios avatar Dimitrii Lopanov avatar Colin Nicholson avatar lantiao avatar

Watchers

 avatar

godijkstra's Issues

What is the meaning about GraphObject struct?

I would like to use this package, but I am confused about GraphObject. What is successors and predecessors ?

// GraphObject interface defines the minimum requirements for an object to be considered a graph by Go-Dijkstra.
// It must implement three functionalities:
// getting the successors for a given node,
// getting the predecessors for a given node (this functionality is not required for the standard Dijkstra algorithm and can be a stub)
// and returning the non-negative edge weight associated to two nodes.
type GraphObject interface {
    SuccessorsForNode(node string) []Connection    // get successors for node
    PredecessorsFromNode(node string) []Connection // get predecessors for node
    EdgeWeight(n1, n2 string) int                  // get edge weight
}

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.