The K-1 Coloring algorithm assigns colors to each node such that no two adjacent nodes share the same color and the number of colors used is minimized.
A coloring of a graph often refers to a proper node coloring, namely a labeling of the graph's nodes with colors such that no two nodes sharing the same edge have the same color. Graph coloring is a fundamental problem in computer science used in applications such as scheduling, register allocation, and wireless channel assignment.

Graph coloring is NP-complete It is NP-complete to decide if a given graph admits a k-coloring and NP-hard to compute the chromatic number. As a result, greedy algorithm is often used to solve graph coloring problem for large graphs. In fact, such approach does not guarantee the optimal solution and may color neighboring nodes the same. However, increasing the number of iterations can improve accuracy.
algo(k1_coloring)Name | Type | Spec | Default | Optional | Description |
|---|---|---|---|---|---|
| loop_num | int | >=1 | 5 | Yes | Number of iterations |
| version | int | 1, 2 | 2 | Yes | 1 for serial greedy coloring algorithm, 2 for iterative parallel greedy coloring algorithm |
The example graph is as follows:

| Spec | Content | Description |
|---|---|---|
| filename_community_id | _id,community_id | Node and its community ID |
| filename_ids | community_id,_id,_id,... | Community ID and the ID of nodes in it |
| filename_num | community_id,count | Community ID and the number of nodes in it |
| Spec | Content | Write to | Data Type |
|---|---|---|---|
| property | community_id | Node property | uint32??? 不是string吗 |
Alias Ordinal | Type | Description | Columns |
|---|---|---|---|
| 0 | []perNode | Node and its community ID | _uuid, community_id |
| 1 | KV | Number of communities, modularity | community_count, modularity |
| Spec | Content | Alias Ordinal | Type | Description | Columns |
|---|---|---|---|---|---|
| mode | 1 or if not set | 0 | []perNode | Node and its community ID | _uuid, community_id |
2 | []perCommunity | Community and the number of nodes in it | community_id, count |
Alias Ordinal | Type | Description | Columns |
|---|---|---|---|
| 0 | KV | Number of communities | community_count |