@deepika and @giuseppe_villan, thanks for your answers. As I previously mentioned that I'm using the neovis.js library, so I also dug down some of its core functions that it provides while we create the instance for the graph. So, with the help of its core functions add() I can able to add nodes on the graph as per my requirement. Let me share here what approach I did so if anyone in future comes here, it'll be handy for them.
As I said, I got the neovis instance passing the config here -
const vis = new NeoVis(config);
So by using this vis instance, I can get various methods and properties nodes and edges, this instance provides. Further using the properties vis.nodes and vis.edges which also provides some of its methods like add, remove, getIds and more.
On click of any node, I can get its id and other information, so I added the node with some of its parent node properties like this -
const nodeInfo = getNodeRawInfo(nodeIdToAdd); // my custom function which provides node info
const newNode = vis.nodes.add({
// id: <NODE_ID_YOU_WANT>, if not pass it'll create UUID for the node
borderWidthSelected: 2,
title: 'title_goes_here', // shows on hover of node
label: 'label_goes_here', // shows inside of the node
scaling: {
label: true
},
size: 50,
shape: 'circle',
font: {
size: 16,
color:"#ffffff",
strokeWidth: 0,
strokeColor: 'transparent',
multi: 'html'
},
color: {
border: '#fff',
background: '#333',
}
});
vis.edges.add({
from: newNode[0],
to: nodeIdToAdd,
scaling:{
label: true,
},
smooth: true,
color: '#fefefe'
})
So the above code adds the node to the current graph and connects it through the edge. Neovis.js library built on top of the vis.js (network) in. So, this is the way I fulfil my requirement. @deepika and @giuseppe_villan, I also thankful for your answers again and it might be really helpful also. I appreciate your effort.
Useful links that might be really helpful if someone follows my approach -
Neovis.js Library
vis-network library examples
vis-network documentation
Thanks,
Krishna Vishwakarma