Skip to content

Group various elements with repeating tags into the minimum number of groups

Notifications You must be signed in to change notification settings

im-mou/group-elements-by-tags

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Sort elements by tags

This algorithm help group diferents elements with repeating tags into the minimum number of groups neceseary.

It can do this taking the tags with highest usage or the lowest.

The script takes an input file as input in which the first line indicates the number of tags in total and after that each line (index) belongs to the element (index) and it contains the tags folowed by the letter "G" (although it can be any letter).

ex.:
8
G1,G6
G1,G7
G1,G6,G8
G2,G7
G3,G6,G7
G3,G6,G8
G4,G7
G4,G8

To execute the script run the following command in you command line tool:

Criterion: Max

go run ./main.go assignments.txt max

Criterion: Min

go run ./main.go assignments.txt mix

Result

The result should look something like this (max criterion):

It indicates the element number and the tag group it belongs to.

T1 -> G6
T2 -> G7
T3 -> G6
T4 -> G7
T5 -> G6
T6 -> G6
T7 -> G7
T8 -> G8

About

Group various elements with repeating tags into the minimum number of groups

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages