@Reference(authors="R. C. Prim", title="Shortest connection networks and some generalizations", booktitle="Bell System Technical Journal, 36 (1957)", url="https://doi.org/10.1002/j.1538-7305.1957.tb01515.x", bibkey="doi:10.1002/j.1538-7305.1957.tb01515.x") public class PrimsMinimumSpanningTree extends java.lang.Object
Implementation for dense graphs, represented as distance matrix.
Reference:
R. C. Prim
Shortest connection networks and some generalizations
Bell System Technical Journal 36
Modifier and Type | Class and Description |
---|---|
static interface |
PrimsMinimumSpanningTree.Adapter<T>
Adapter interface to allow use with different data representations.
|
static class |
PrimsMinimumSpanningTree.Array2DAdapter
Adapter for a simple 2d double matrix.
|
static interface |
PrimsMinimumSpanningTree.Collector
Interface for collecting edges.
|
Modifier and Type | Field and Description |
---|---|
static PrimsMinimumSpanningTree.Array2DAdapter |
ARRAY2D_ADAPTER
Adapter class for double[][] matrixes.
|
Constructor and Description |
---|
PrimsMinimumSpanningTree() |
Modifier and Type | Method and Description |
---|---|
static int[] |
processDense(double[][] mat)
Process a k x k distance matrix.
|
static <T> int[] |
processDense(T data,
PrimsMinimumSpanningTree.Adapter<T> adapter)
Run Prim's algorithm on a dense graph.
|
static <T> void |
processDense(T data,
PrimsMinimumSpanningTree.Adapter<T> adapter,
PrimsMinimumSpanningTree.Collector collector)
Run Prim's algorithm on a dense graph.
|
static int[] |
pruneTree(int numnodes,
int[] tree,
int minDegree)
Prune the minimum spanning tree, removing all edges to nodes that have a
degree below
minDegree . |
public static final PrimsMinimumSpanningTree.Array2DAdapter ARRAY2D_ADAPTER
public static int[] processDense(double[][] mat)
mat
- Distance matrixpublic static <T> int[] processDense(T data, PrimsMinimumSpanningTree.Adapter<T> adapter)
data
- Data setadapter
- Adapter instancepublic static <T> void processDense(T data, PrimsMinimumSpanningTree.Adapter<T> adapter, PrimsMinimumSpanningTree.Collector collector)
data
- Data setadapter
- Adapter instancecollector
- Edge collectorpublic static int[] pruneTree(int numnodes, int[] tree, int minDegree)
minDegree
.numnodes
- Number of nodes (MUST use numbers 0 to numnodes-1
)tree
- Original spanning treeminDegree
- Minimum node degreeCopyright © 2019 ELKI Development Team. License information.