From 02c2ad864b9d42504da9d76b8c863390141b84c9 Mon Sep 17 00:00:00 2001
From: Pitchaya Boonsarngsuk <2285135b@student.gla.ac.uk>
Date: Mon, 5 Feb 2018 11:37:13 +0000
Subject: [PATCH] Readme finish Link force doc
---
README.md | 38 +++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 667b5b8..c3aff94 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ Based on [d3-force](https://github.com/d3/d3-force) by Mike Bostock under BSD 3-
### Reference
- Chalmers, M. ["A linear iteration time layout algorithm for visualising high-dimensional data."](http://dl.acm.org/citation.cfm?id=245035) Proceedings of the 7th conference on Visualization'96. IEEE Computer Society Press, 1996.
- Morrison, A., Ross, G. & Chalmers, M. ["A Hybrid Layout Algorithm for Sub-Quadratic Multidimensional Scaling."](https://dl.acm.org/citation.cfm?id=857191.857738) INFOVIS '02 Proceedings of the IEEE Symposium on Information Visualization, 2002
-- Morrison, A. & Chalmers, M. ["proving hybrid MDS with pivot-based searching."](https://dl.acm.org/citation.cfm?id=1947387) INFOVIS'03 Proceedings of the Ninth annual IEEE conference on Information visualization, 2003
+- Morrison, A. & Chalmers, M. ["Improving hybrid MDS with pivot-based searching."](https://dl.acm.org/citation.cfm?id=1947387) INFOVIS'03 Proceedings of the Ninth annual IEEE conference on Information visualization, 2003
## Usage
@@ -55,9 +55,37 @@ See [package.json](package.json) for more details.
## API Reference
-#### Spring Model
+### Spring Model
-#### Neighbour and Sampling - TO REWRITE
+The model connect every nodes together with a "spring", a link force that pushes linked nodes together or apart according to the desired distance. The strength of the "spring" force is proportional to the difference between the linked nodes’ distance and the target distance.
+
+The implementation is based on [d3.forceLink()](https://github.com/d3/d3-force#forceLink) with the list of springs locked down so that every nodes are connected to each other. This comes with the benefit of huge memory usage decrease and lower the initialization time.
+
+# d3.**forceLinkFullyConnected**() [<>](src/link.js "Source")
+
+Creates a new link force with default parameters.
+
+# *springLink*.**distance**([distance])
+
+If *distance* is specified, sets the distance accessor to the specified number or function, re-evaluates the distance accessor for each link, and returns this force. If *distance* is not specified, returns the current distance accessor, which defaults to:
+
+```js
+function distance() {
+ return 30;
+}
+```
+
+The distance accessor is invoked for each pair of node, being passed the two nodes as two arguments as follow:
+```js
+function distance(nodeA, nodeB) { return NumberDistanceBetweenAandB; }
+```
+The resulting number is then stored internally, such that the distance of each link is only recomputed when the force is initialized or when this method is called with a new *distance*, and not on every application of the force.
+
+# *springLink*.**iterations**([*iterations*])
+
+If *iterations* is specified, sets the number of iterations per application to the specified number and returns this force. If *iterations* is not specified, returns the current iteration count which defaults to 1. Increasing the number of iterations greatly increases the rigidity of the constraint, but also increases the runtime cost to evaluate the force.
+
+### Neighbour and Sampling - TO REWRITE
The Neighbour and Sampling algorithm tries to group the nodes based on the distance between them. If the nodes have a low distance, then the force attracts them to each other. If the nodes have a high distance, then the repulsive force pushes them further apart from each other.
@@ -67,7 +95,7 @@ In order for it to work properly, a distance function should be specified.
Initializes the Neighbour and Sampling algorithm with default parameters.
-# *neighbourSampling*.**id**([*id*]) [<>](src/neighbourSampling.js#L218 "Source")
+# *neighbourSampling*.**id**([*id*])
If *id* is specified, sets the node id accessor to the specified function and returns this force. If *id* is not specified, returns the current node id accessor, which defaults to the numeric *node*.index:
@@ -105,4 +133,4 @@ Returns the stress of the layout.
Returns the average velocity of the iteration.
-#### Hybrid Layout
+### Hybrid Layout