Giter Club home page Giter Club logo

hw2-bfs's Introduction

Assignment 2

Breadth-first search

Assignment Overview

The purpose of this assignment is to get you comfortable working with graph structures and to implement a breadth-first search function to traverse the graph and find the shortest path between nodes.

Assignment Tasks

Coding Assessment

In search/graph.py:

  • Define the function bfs that takes in a graph, start node, and optional node and:
    • If no end node is provided, returns a list of nodes in order of breadth-first search traversal from the given start node
    • If an end node is provided and a path exists, returns a list of nodes in order of the shortest path to the end node
    • If an end node is provided and a path does not exist, returns None
  • Be sure that your code can handle possible edge cases, e.g.:
    • running bfs traversal on an empty graph
    • running bfs traversal on an unconnected graph
    • running bfs from a start node that does not exist in the graph
    • running bfs search for an end node that does not exist in the graph
    • any other edge cases you can think of

In test/test_bfs.py:

  • Write unit tests for breadth-first traversal and breadth-first search
  • You may use the two networks provided in the data folder or create your own for testing
  • Test at least 2 possible edge cases (listed above)
  • Include a test case that fails and raises an exception

HW2 - BFS

Breadth First Search (BFS)

Breadth First Search (BFS) is a graph search method that traverses nodes on a graph given a start node in a "layer first" fashion. This method of traversal allows for shortest path determination (in conjugation with dijkstra algorithm). Here, I wrote an implementation of both BFS and shortest path search using NetworkX package.

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.