- case STATIONARY:
- return 100;
-
- case PORTABLE:
- return 3;
- }
-
- return 3;
-}
-
-bool dclass_ccounts_satisfied(dclass_t dclass, splay_tree_t* counts, int total_count)
-{
- // lookup keys
- dclass_ccount_t key_portable;
- key_portable.dclass = PORTABLE;
-
- dclass_ccount_t key_stationary;
- key_stationary.dclass = STATIONARY;
-
- dclass_ccount_t key_backbone;
- key_backbone.dclass = BACKBONE;
-
- // check num of portable devices
- dclass_ccount_t* portable = splay_search(counts, &key_portable);
-
- if(portable)
- {
- if(portable->ccount > 9)
- return true;
- }
-
- // check num of stationary devices
- dclass_ccount_t* stationary = splay_search(counts, &key_stationary);
-
- if(stationary)
- {
- if(stationary->ccount > 6)
- return true;
- }
-
- // check num of backbone devices
- dclass_ccount_t* backbone = splay_search(counts, &key_backbone);
-
- if(backbone)
- {
- if(backbone->ccount > 3)
- return true;
- }
-
- // fallback
- if(total_count >= max_ccount_from_dclass(dclass))
- return true;
-
- return false;
-}
-
-int dclass_ccount_compare(const void *a, const void *b)
-{
- const dclass_ccount_t* da = a;
- const dclass_ccount_t* db = b;
-
- return da->dclass - db->dclass;
-}
-
-dclass_ccount_t* dclass_ccount_alloc()
-{
- return xzalloc(sizeof(dclass_ccount_t));
-}
-
-void dclass_ccount_delete(void *c)
-{
- free(c);
-}
+/// Device class
+dev_class_traits_t dev_class_traits[_DEV_CLASS_MAX +1] = {
+ { .min_connects = 3, .max_connects = 10000, .edge_weight = 1 }, // DEV_CLASS_BACKBONE
+ { .min_connects = 3, .max_connects = 100, .edge_weight = 3 }, // DEV_CLASS_STATIONARY
+ { .min_connects = 3, .max_connects = 3, .edge_weight = 6 }, // DEV_CLASS_PORTABLE
+ { .min_connects = 1, .max_connects = 1, .edge_weight = 9 }, // DEV_CLASS_UNKNOWN
+};