\seekquarry\yioop\library\indexing_pluginsRecipeClusterer

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.

Summary

Methods
Properties
Constants
__construct()
makeClusters()
getNextVertex()
addMostCommonIngredientClusters()
$cluster_heap
$vertices
$adjacency_matrix
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$vertices

$vertices : array

Array of Vertices (Recipes)

Type

array

$adjacency_matrix

$adjacency_matrix : array

Adjacency matrix of whether recipes are adjacent to each other

Type

array

Methods

__construct()

__construct(array  $edges) 

Constructs a tree suitable for building containing a Minimal Spanning Tree for Kruskal clustering

Parameters

array $edges

vertices and edge weights of MST

makeClusters()

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.

Returns

array —

$clusters each element of $clusters is an array of recipe names

getNextVertex()

getNextVertex(string  $vertex) : \seekquarry\yioop\library\indexing_plugins\adjacent

Gets the next vertex from the adjacency matrix for a given vertex

Parameters

string $vertex

vertex

Returns

\seekquarry\yioop\library\indexing_plugins\adjacent —

vertex if it has otherwise -1.

addMostCommonIngredientClusters()

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.

Parameters

array $clusters

clusters of recipes.

array $ingredients

array of ingredients of recipes.

Returns

array —

$new_clusters clusters with common ingredient appended.