Code Monkey home page Code Monkey logo

graphcoloringproject's Introduction

Graph Coloring Project

This is an exercise in finding an efficient algorithm that takes in a file containing the edges of an undirected graph and finds out if it is two-colorable. I chose to use a modified Depth-First-Search that, instead of keeping track of start and finish times, assigns each vertex a color that is the opposite of its parent. When the end of the recursive DFS-Visit is reached, it must be checked for a cycle. This is accomplished by looking at the next outgoing edge to see if the vertex has the same color. If it does, that is the start of the odd length cycle. The number of that vertex is stored and, as the recursion peels back, each subsequent vertex is added to a linked list of vertices in the odd cycle. When the origin vertex of the odd cycle is reached, the recursion is stopped and the list of vertices is written to a file. If the algorithm completes with- out finding any odd cycles, then the graph is two-colorable and it is output showing the coloring created by the algorithm.

Run Time Analysis

If V is the number of vertices and E is the number of edges, this algorithm runs at O(|V|+|E|).

Running the project from Terminal/Command Line

This program can be run from an IDE such as Eclipse or Netbeans. If that is done, the VM flag, Xss25m must be set in the run/build configuration. After it is built, it can be run from the command line:

$ java Xss25m -jar GraphColoring.jar <Insert filename here>

If no filename is provided as an argument, it will use the three sample files.

graphcoloringproject's People

Watchers

James Cloos avatar Jess Hendricks 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.