This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From Wikipedia: Prim's algorithm is a greedy algorithm that | |
// finds a minimum spanning tree for a connected weighted undirected graph. | |
// This means it finds a subset of the edges that forms a tree that | |
// includes every vertex, where the total weight of all the edges in the tree is minimized. | |
void Prim(int n, int[][] W, int[] nearest) | |
{ | |
int[]distance | |
for( i = 1; i<=n; i++) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Wikipedia: a way of coloring the vertices of a graph such that no two | |
// adjacent vertices share the same color; this is called a vertex coloring. | |
// Similarly, an edge coloring assigns a color to each edge so that no two adjacent | |
// edges share the same color, and a face coloring of a planar graph assigns a color to | |
// each face or region so that no two faces that share a boundary have the same color. | |
// In NP-complete | |
boolean mcolor(int i, int m, int n, bool [][] W, int [] vcolor, int n) | |
{ | |
// i: last colored vertex | |
// m: number of colors |
NewerOlder