Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C# Data Structures and Algorithms

You're reading from  C# Data Structures and Algorithms

Product type Book
Published in Apr 2018
Publisher Packt
ISBN-13 9781788833738
Pages 292 pages
Edition 1st Edition
Languages
Author (1):
Marcin Jamro Marcin Jamro
Profile icon Marcin Jamro
Toc

Coloring


The topic of finding the MST is not the only graph-related problem. Among others, node coloring exists. Its aim is to assign colors (numbers) to all nodes to comply with the rule that there cannot be an edge between two nodes with the same color. Of course, the number of colors should be as low as possible. Such a problem has some real-world applications, such as for coloring a map, which is the topic of the example shown later.

Note

Did you know that the nodes of each planar graph can be colored with no more than four colors? If you are interested in this topic, take a look at the four-color theorem (http://mathworld.wolfram.com/Four-ColorTheorem.html). The implementation of the coloring algorithm shown in this chapter is simple and in some cases could use more colors than really necessary.

Let's take a look at the following diagram:

The first diagram (shown on the left) presents a graph that is colored using four colors: red (index equal to 0), green (1), blue (2), and violet (3)...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime