T
- The type of nodes valuepublic class Graph<T> extends Object implements GraphInterface<T>
Modifier and Type | Field and Description |
---|---|
protected int |
k |
protected HashMap<Node<T>,NeighborList> |
map |
protected SimilarityInterface<T> |
similarity |
Modifier and Type | Method and Description |
---|---|
ArrayList<Graph<T>> |
connectedComponents()
Split the graph in connected components (usually you will first prune the
graph to remove "weak" edges).
|
boolean |
containsKey(Node node) |
Iterable<Map.Entry<Node<T>,NeighborList>> |
entrySet() |
NeighborList |
get(Node node)
Get the neighborlist of this node
|
int |
getK() |
Iterable<Node<T>> |
getNodes() |
SimilarityInterface<T> |
getSimilarity() |
void |
prune(double threshold)
Remove from the graph all edges with a similarity lower than threshold
|
NeighborList |
put(Node<T> node,
NeighborList neighborlist) |
NeighborList |
search(T query,
int K) |
NeighborList |
search(T query,
int K,
double speedup)
Improved implementation of Graph Nearest Neighbor Search (GNNS) algorithm
from paper "Fast Approximate Nearest-Neighbor Search with k-Nearest
Neighbor Graph" by Hajebi et al.
|
NeighborList |
search(T query,
int K,
double speedup,
double expansion)
Improved implementation of Graph Nearest Neighbor Search (GNNS) algorithm
from paper "Fast Approximate Nearest-Neighbor Search with k-Nearest
Neighbor Graph" by Hajebi et al.
|
NeighborList |
searchExhaustive(T query,
int K) |
void |
setK(int k) |
void |
setSimilarity(SimilarityInterface<T> similarity) |
int |
size() |
ArrayList<Graph<T>> |
stronglyConnectedComponents()
Computes the strongly connected sub-graphs (where every node is reachable
from every other node) using Tarjan's algorithm, which has computation
cost O(n).
|
void |
writeGEXF(String filename)
Writes the graph as a GEXF file (to be used in Gephi, for example)
|
protected HashMap<Node<T>,NeighborList> map
protected SimilarityInterface<T> similarity
protected int k
public SimilarityInterface<T> getSimilarity()
getSimilarity
in interface GraphInterface<T>
public void setSimilarity(SimilarityInterface<T> similarity)
setSimilarity
in interface GraphInterface<T>
public int getK()
getK
in interface GraphInterface<T>
public void setK(int k)
setK
in interface GraphInterface<T>
public NeighborList get(Node node)
get
in interface GraphInterface<T>
node
- public void prune(double threshold)
prune
in interface GraphInterface<T>
threshold
- public ArrayList<Graph<T>> connectedComponents()
connectedComponents
in interface GraphInterface<T>
public ArrayList<Graph<T>> stronglyConnectedComponents()
stronglyConnectedComponents
in interface GraphInterface<T>
public NeighborList put(Node<T> node, NeighborList neighborlist)
put
in interface GraphInterface<T>
public boolean containsKey(Node node)
containsKey
in interface GraphInterface<T>
public int size()
size
in interface GraphInterface<T>
public Iterable<Map.Entry<Node<T>,NeighborList>> entrySet()
entrySet
in interface GraphInterface<T>
public NeighborList searchExhaustive(T query, int K) throws InterruptedException, ExecutionException
searchExhaustive
in interface GraphInterface<T>
query
- K
- InterruptedException
ExecutionException
public NeighborList search(T query, int K)
search
in interface GraphInterface<T>
public NeighborList search(T query, int K, double speedup)
search
in interface GraphInterface<T>
query
- K
- search K neighborsspeedup
- (default: 4)public NeighborList search(T query, int K, double speedup, double expansion)
search
in interface GraphInterface<T>
query
- query pointK
- number of neighbors to find (the K from K-nn search)expansion
- (default: 1.01)public void writeGEXF(String filename) throws FileNotFoundException, IOException
writeGEXF
in interface GraphInterface<T>
filename
- FileNotFoundException
IOException
Copyright © 2016. All rights reserved.