$cluster_heap
$cluster_heap : \seekquarry\yioop\library\indexing_plugins\MaxWeightedEdgeHeap
Maintains a priority queue of edges ordered by max weight
Class to define Minimum Spanning tree for recipes. constructMST constructs the minimum spanning tree using heap. formCluster forms clusters by deleting the most expensive edge. BreadthFirstSearch is used to traverse the MST.
$cluster_heap : \seekquarry\yioop\library\indexing_plugins\MaxWeightedEdgeHeap
Maintains a priority queue of edges ordered by max weight
makeClusters() : array
Forms the clusters from $this->cluster_heap by removing maximum weighted edges. $this->cluster_heap is initially a weighted tree as edges are removed it becomes a forest. Once the number of trees in the forest reaches $num_recipes * RecipePlugin::CLUSTER_RATIO, the trees are treated as the clusters to be returned.
$clusters each element of $clusters is an array of recipe names
addMostCommonIngredientClusters(array $clusters, array $ingredients) : array
Adds to each element of an array of recipe clusters, a field ingredient containing the string name of the most common, non-basic ingredient found in that cluster.
array | $clusters | clusters of recipes. |
array | $ingredients | array of ingredients of recipes. |
$new_clusters clusters with common ingredient appended.