GithubHelp home page GithubHelp logo

graph's Introduction

Simple Graph Traversal

This project implements DFS, BFS, Djikstra algo.

Geting Started

Prerequites

Things you need to install this software

CMake

Installing on Unix Terminal

A step by step series of commands to get a development env running

git clone https://github.com/theorist17/graph
cd graph
mkdir build
cd build
cmake ..
make

Installing on Microsoft Visual Studio

For MSVC, built-target and input text file has to manually located.

1. Open VS
2. File -> Clone or check out code ..
3. Set Repository location = https://github.com/theorist17/graph (you need to setup github on VS first)
4. After building, move input.txt and input2.txt into the /out/build/ directory

Running the tests

Setup input.txt

3       (# of vertices)
1 2 3   (for each vertex, enumerate its adjacent vertex)
2 1 3
3 1 2
2       (# of vertices, for another graph)
1 2
2 1
4       (another graph)
1 2 3
2 4
3 2
4       (4\n)
        (eof)

Run BFS & DFS

Execution

./traversal
or
traversal.exe

Output

----------------------------
Graph 1
----------------------------
Vertex
3
----------------------------
Edges
1 2 3
2 1 3
3 1 2
----------------------------
Adjacency matrix
0 1 1
1 0 1
1 1 0
----------------------------
Depth first search
1 2 3
----------------------------
Breadth first search
1 2 3
----------------------------

Run Dijkstra

Execution

./shortest_path
or 
traversal.exe

Output

----------------------------
Graph 1
----------------------------
Vertex
5
----------------------------
Edges
1 2 10 4 30 5 100
2 3 50
3 5 10
4 3 20 5 60
5
----------------------------
Adjacency list
node 1 : 2 (10) 4 (30) 5 (100)
node 2 : 3 (50)
node 3 : 5 (10)
node 4 : 3 (20) 5 (60)
node 5 :
----------------------------
Dijkstra algorithm
Starting vertex : 1
Vertex 2 : 1 - 2, distance : 10
Vertex 3 : 1 - 4 - 3, distance : 50
Vertex 4 : 1 - 4, distance : 30
Vertex 5 : 1 - 4 - 3 - 5, distance : 60
----------------------------

Authors

Acknowledgements

graph's People

Contributors

theorist17 avatar

Watchers

 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.