Perform the force generated by the Hooke's attraction.
[Hx,Hy]=NARVAL_G_HookeForce(kh,i,j,nx,ny,l)
Hooke coefficient.
starting node.
ending node.
current x-coordinates vector of nodes.
current y-coordinates vector of nodes.
edge length at the equilibrium.
x-coordinate of the Hooke's attraction.
y-coordinate of the Hooke's attraction.
NARVAL_G_HookeForce performs the Hooke's attraction [Hx,Hy] between two nodes [i,j] of a graph after their displacement. The position of all nodes is assumed to be stored in [nx,ny]. The edge length at the equilibrium is l. In respect with the Wikipedia definition, the Hooke's law of elasticity is an approximation that states that the extension of a spring is in direct proportion with the load applied to it.
n=3;//network size l0=5;//a maximum of 5 links are created for any created node L=1000;//network square area side kh=0.1;//Hooke's coefficient [g,d]=NARVAL_T_BarabasiAlbert(n,l0,L);//generation of the topology n=g.node_number; l=length(g.head); nx=g.node_x;//current position ny=g.node_y; li=NARVAL_F_AleaNombre(l);//selection of a link [nd,nf]=NARVAL_G_Edge2Nodes(g,li); le=50;//edge length at the equilibrium [Hx,Hy]=NARVAL_G_HookeForce(kh,nd,nf,nx,ny,le);//application of NARVAL_G_HookeForce Hx Hy | ![]() | ![]() |