I have a graph that can be composed of 2 types of algorithms: Cluster and Normal.
I need a way to find out wish type of node is my normal node based on its nearest node of type cluster:
- So for example in pic above, I want to know what type is Node (A) bases on its nearest node of type cluster.
- As you can see normal
node A
has a distance of 1 edge/link to nodeCluster 1
. - Also, node A**
strong text
** has distance of 2 edges/links to nodeCluster 2
. - Since distance to Cluster 1 is less than distance to Cluster 2. Node (a) is Type 1.
- if distance to Cluster 2 was shorter than distance to Cluster 1 then it would be type 2.
I'm using javascript + d3 for this graph.
I searched on the internet and found that Djikastra's algorithm might be what I need but Djikastras need an initial node and a goal node.
My problem is:
That all of my Cluster type nodes are my goals and I need to find for each normal type node which type it would be based on its nearest cluster.
Is Djikstra's the best algorithm for this? I'm not sure if in a fairly complex graph with hundreds of nodes that algorithm will perform efficiently.
This is more or less how my nodes and links look:
Node A = {
name: A,
type: normal,
id: node_1
}
Node Cluster 1 = {
name: Cluster 1,
type: cluster,
id: node_2
}
Edge or link = {
from= node_1,
to= node_2
}