Giter Site home page Giter Site logo

breadth-first-search's Introduction

Breadth-First-Search

Problem Definition:

Construct a graph using give vertices and edges. Determine the shortest path using Breadth-First-Search

Input:

(a) The specification of a set of vertices starts with 'V', followed by a space, followed by a positive integer, all in one single line. If the integer that follows the V is i, then we assume that the vertices are identified by 0, ... , i - 1.

e.g.
V 15

(b) The specification for a set of edges starts with 'E'. It then has a space, followed by the set of edges in a single line delimited by '{' and '}'. The two vertices of an edge are delimited by '<' and '>' and separated by a comma. The edges in the set are also separated by a comma. There are no whitespace characters within the {}.

e.g.
E {<2,6>,<2,8>,<2,5>,<6,5>,<5,8>,<6,10>,<10,8>}

(c) The input starts with an 's'. It asks for a shortest path from the first vertex to the second that is specified after the s. The s is followed by a space, a vertex ID, another space, and a second vertex ID.

e.g.
s 2 10 # Find the shortest path between vertex 2 and vertex 10 2-8-10 # Path 2 -> 8 -> 10 is the shortest path

Note:

The graph is specified by the specification of the set of vertices V followed by the set of edges E, in that order. V and E always occur together. There is no relationship between subsequent graph specifications; when a new V specification starts, all previous information will be forgotten. After the specification of the graph there can be zero or more shortest-path queries s. For each s query, only one shortest path is outputed; multiple shortest paths might exist and an arbitrary choice is made. Note that there is no self loop in the graph.

breadth-first-search's People

Contributors

eason-sun avatar

Watchers

James Cloos avatar  avatar

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.