/Greedy-graph-coloring

Greedy graph coloring - comparison of programming paradigms - logic programming vs functional programming

Primary LanguageJavaScript

Greedy-graph-coloring

Simple comparison of logic and functional programming paradigm using graph coloring problem for programming paradigms course.
Sequential greedy coloring algorithm: https://en.wikipedia.org/wiki/Greedy_coloring

Algorithm
1.Color first vertex with first color.
2.Do following for remaining V-1 vertices.
---Consider the currently picked vertex and color it with the
---lowest numbered color that has not been used on any previously
---colored vertices adjacent to it. If all previously used colors
---appear on vertices adjacent to v, assign a new color to it.

Logical programming - Prolog
Functional programming - JavaScript

In this case,this is not pure functional programming, but mix of functional and OOP because of implementation of a graph, but coloring algorithm uses main properties of functional paradigm.
For this problem and similar problems that require searching techniques logic programming seems to be better solution regarding code complexity because of the various search implementations in Prolog.